Skip to content
This repository has been archived by the owner on Dec 1, 2023. It is now read-only.

Add(concat): prefix and suffix options (fix #48) #57

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Riotpiaole
Copy link
Collaborator

@Riotpiaole Riotpiaole commented Jul 9, 2017

Relevant issues & PRs

See #48.

Checklist

  • This affects the tests of the project.
  • I have updated the tests as needed.

@@ -0,0 +1,3 @@
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The .vscode folder should not be pushed to git. Remove this & add it to the .gitignore in the root directory.

*
* suffix and prefix features
* @param suffix || null @param prefix || null
* appending additional suffix and prefix to each data.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This JSDoc comment is incorrect:

  • Each param definition should be on its own line
  • Description should only be before the param comments start

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if i add the comment like:

  /**
   * options assign
   *  @param suffix adding string at the end of the each file
   *  @param prefix adding string at the beginning of the first packet
   */
  var opts = Object.assign({}, ctx.args[0] || {})

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The opts i will fix it

var opts = Object.assign({}, ctx.args[0] || {})

// suffix
if (opts.suffix) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefix should only be added if this data packet is the first packet (which it will not always be).

Check if it is the first data piece before adding a prefix.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do i know how many packets are coming, can i modified the ctx which will store a count?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no way to know how many packets but you don't need a count. You just need to know what the first one is & what the last one is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel stupid, which props i can check is the first or the last?

/**
* options assign
*/
var opts = Object.assign({}, ctx.args[0] || {})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only necessary if you are going to modify the opts object, which you aren't. Since you are not modifying the opts, you can just do this: const opts = ctx.args[0]

Also avoid using var in ES2015 code. Use let or const.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If i changed to javascript const opts=ctx.args[0] would be an error of suffix undefined. so i changed javascript const opts =ctx.args[0] || {}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(y)

// suffix
if (opts.suffix) {
data.size += opts.suffix.length
data.body = Buffer.from(opts.suffix + data.body.toString())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Providing a Buffer is unnecessary. You can just provide a string like this:

data.body = opts.suffix + data.body.toString()

data.body = Buffer.from(opts.suffix + data.body.toString())
}

// prefix
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefix should be before data and suffix should be after.

}

// prefix
if (opts.prefix) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suffix should only be added if data.end is true (i.e. it is the last piece of data)

@karimsa karimsa changed the title Added prefix and suffix for bundle Add prefix and suffix to concat (fix #48) Jul 9, 2017
@hoppjs hoppjs deleted a comment from codecov-io Jul 9, 2017
@codecov-io
Copy link

codecov-io commented Jul 9, 2017

Codecov Report

Merging #57 into master will decrease coverage by 0.03%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #57      +/-   ##
=========================================
- Coverage    7.57%   7.53%   -0.04%     
=========================================
  Files          61      61              
  Lines        2692    2706      +14     
=========================================
  Hits          204     204              
- Misses       2488    2502      +14
Impacted Files Coverage Δ
packages/hopp-plugin-concat/dist/index.js 0% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eb3d596...ae9ea89. Read the comment docs.

@karimsa karimsa changed the title Add prefix and suffix to concat (fix #48) Add(concat): prefix and suffix options (fix #48) Jul 9, 2017
@Riotpiaole
Copy link
Collaborator Author

So what am i fixing next? @karimsa

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants