through2-map
Advanced tools
Comparing version 1.3.0 to 1.4.0
10
index.js
@@ -5,2 +5,3 @@ "use strict"; | ||
module.exports.ctor = ctor | ||
module.exports.objCtor = objCtor | ||
module.exports.obj = obj | ||
@@ -30,2 +31,11 @@ | ||
function objCtor(options, fn) { | ||
if (typeof options === "function") { | ||
fn = options | ||
options = {} | ||
} | ||
options = xtend({objectMode: true, highWaterMark: 16}, options) | ||
return ctor(options, fn) | ||
} | ||
function obj(options, fn) { | ||
@@ -32,0 +42,0 @@ if (typeof options === "function") { |
{ | ||
"name": "through2-map", | ||
"version": "1.3.0", | ||
"version": "1.4.0", | ||
"description": "A through2 to create an Array.prototype.map analog for streams.", | ||
@@ -38,11 +38,11 @@ "main": "index.js", | ||
"devDependencies": { | ||
"tape": "~2.4.0", | ||
"stream-spigot": "~3.0.3", | ||
"concat-stream": "~1.4.1" | ||
"tape": "~2.13.2", | ||
"stream-spigot": "~3.0.4", | ||
"concat-stream": "~1.4.6" | ||
}, | ||
"dependencies": { | ||
"terminus": "~1.0.8", | ||
"through2": "~0.4.1", | ||
"terminus": "~1.0.10", | ||
"through2": "~0.5.1", | ||
"xtend": "^3.0.0" | ||
} | ||
} |
@@ -61,3 +61,3 @@ through2-map | ||
`require("through2-map")(options, fn)` | ||
`require("through2-map")([options,] fn)` | ||
--- | ||
@@ -67,3 +67,3 @@ | ||
`var Tx = require("through2-map").ctor(options, fn)` | ||
`var Tx = require("through2-map").ctor([options,] fn)` | ||
--- | ||
@@ -73,3 +73,3 @@ | ||
`require("through2-map").obj(options, fn)` | ||
`require("through2-map").obj([options,] fn)` | ||
--- | ||
@@ -79,2 +79,7 @@ | ||
`require("through2-map").objCtor([options,] fn)` | ||
--- | ||
Just like ctor, but with `objectMode: true` defaulting to true. | ||
Options | ||
@@ -81,0 +86,0 @@ ------- |
@@ -58,2 +58,27 @@ "use strict"; | ||
test("objCtor", function (t) { | ||
t.plan(7) | ||
var Map = map.objCtor(function (record) { | ||
t.equals(this.options.objectMode, true, "can see options") | ||
record.foo.toUpperCase() | ||
return record | ||
}) | ||
function combine(records) { | ||
t.equals(records.length, 5, "Correct number of remaining records") | ||
t.notOk(records.filter(function (r) { /^[A-Z]$/.exec(r.foo) }).length, "Everything uppercased") | ||
} | ||
spigot({objectMode: true}, [ | ||
{foo: "bar"}, | ||
{foo: "baz"}, | ||
{foo: "bif"}, | ||
{foo: "blah"}, | ||
{foo: "buzz"}, | ||
]) | ||
.pipe(new Map({objectMode: true})) | ||
.pipe(concat({objectMode: true}, combine)) | ||
}) | ||
test("ctor buffer wantStrings index", function (t) { | ||
@@ -60,0 +85,0 @@ t.plan(1) |
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
10040
203
91
+ Addedthrough2@0.5.1(transitive)
- Removedobject-keys@0.4.0(transitive)
- Removedthrough2@0.4.2(transitive)
- Removedxtend@2.1.2(transitive)
Updatedterminus@~1.0.10
Updatedthrough2@~0.5.1