Comparing version 0.8.1 to 0.9.0
1.0.0 - Released 2015/10/08 | ||
0.9.0 - Released 2016/10/02 | ||
1. revised README for clarity | ||
2. changed `objectMode` use to `readableObjectMode` | ||
3. allow `readableObjectMode` option to override default of true | ||
4. add `readableObjectMode` example to README | ||
0.8.1 - Released 2016/01/28 | ||
1. updated dependencies | ||
0.8.0 - Released 2015/11/04 | ||
1. changed to use `stream-search-helper` | ||
0.7.0 - Released 2015/10/08 | ||
1. initial working version with tests |
@@ -1,2 +0,2 @@ | ||
// Generated by CoffeeScript 1.10.0 | ||
// Generated by CoffeeScript 1.11.0 | ||
var EachPart, Transform, buildSearch, | ||
@@ -54,8 +54,8 @@ extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | ||
var part; | ||
part = { | ||
part = this.options.readableObjectMode ? { | ||
string: string, | ||
delim: delim | ||
}; | ||
} : string; | ||
this.push(part); | ||
return this.emit('part', part); | ||
return this.emit('part', part, delim); | ||
}; | ||
@@ -66,7 +66,9 @@ | ||
if (options != null) { | ||
options.objectMode = true; | ||
if (options.readableObjectMode == null) { | ||
options.readableObjectMode = true; | ||
} | ||
this.options = options; | ||
} else { | ||
this.options = { | ||
objectMode: true | ||
readableObjectMode: true | ||
}; | ||
@@ -73,0 +75,0 @@ } |
{ | ||
"name": "each-part", | ||
"version": "0.8.1", | ||
"version": "0.9.0", | ||
"description": "Transform stream which emits each part and pushes object with part", | ||
@@ -22,6 +22,6 @@ "main": "lib", | ||
"devDependencies": { | ||
"coffee-script": "^1.10.0", | ||
"mocha": "^2.4.4", | ||
"coffee-script": "^1.11.0", | ||
"mocha": "^2.5.3", | ||
"strung": "^1.0.4", | ||
"through2": "^2.0.0" | ||
"through2": "^2.0.1" | ||
}, | ||
@@ -28,0 +28,0 @@ "dependencies": { |
@@ -19,9 +19,19 @@ # each-part | ||
```coffeescript | ||
eachLine = require 'each-part' | ||
buildEach = require 'each-part' | ||
each = eachLine() | ||
each.on 'part', (part) -> # do something with the part | ||
each.on 'error', (error) -> # do something with the error... | ||
each.on 'finish', (error) -> # all done... | ||
# uses newline or carriage return by default | ||
# outputs `part` object by default, which contains `string` and `delim` | ||
eachLine = buildEach() | ||
eachLine.on 'part', (part, delim) -> | ||
# do something with the part. | ||
# when readableObjectMode is true, the default, then `part` is an object | ||
# with two properties: `string` and `delim` | ||
# when it's not true (you specify it as false in options) then `part` is the | ||
# string. The second arg is always `delim` | ||
eachLine.on 'error', (error) -> # do something with the error... | ||
eachLine.on 'finish', (error) -> # all done... | ||
# part is also passed on as an object to the next stream using objectMode:true | ||
@@ -33,11 +43,19 @@ targetStream = require('through2') (part, _, next) -> | ||
someStream.pipe(each) | ||
someStream.pipe(eachLine) | ||
# can provide options to override the delimiter used: | ||
each = eachLine delim:'|' | ||
eachPipe = buildEach delim:'|' | ||
# can be a regular expression: | ||
each = eachLine delim:/blah/ | ||
eachBlah = buildEach delim:/blah/ | ||
# to pass `string` to the next stream, set readableObjectMode to false: | ||
eachLine = buildEach readableObjectMode:false | ||
# when you do that, then: | ||
# 1. the stream it pipes to will receive strings as chunks | ||
# 2. the 'part' event will provide the string as the first arg, not an object | ||
# Note: this means the next stream will not know the delimiter found | ||
``` | ||
## MIT License |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7161
80
60