pull-stream
Advanced tools
Comparing version 2.26.1 to 2.27.0
{ | ||
"name": "pull-stream", | ||
"description": "minimal pull stream", | ||
"version": "2.26.1", | ||
"version": "2.27.0", | ||
"homepage": "https://github.com/dominictarr/pull-stream", | ||
@@ -6,0 +6,0 @@ "repository": { |
@@ -7,6 +7,13 @@ | ||
function abortCb(cb, abort, onAbort) { | ||
cb(abort) | ||
onAbort && onAbort(abort === true ? null: abort) | ||
return | ||
} | ||
var once = exports.once = | ||
function (value) { | ||
function (value, onAbort) { | ||
return function (abort, cb) { | ||
if(abort) return cb(abort) | ||
if(abort) | ||
return abortCb(cb, abort, onAbort) | ||
if(value != null) { | ||
@@ -21,6 +28,7 @@ var _value = value; value = null | ||
var values = exports.values = exports.readArray = | ||
function (array) { | ||
function (array, onAbort) { | ||
if(!array) | ||
return function (abort, cb) { | ||
return cb(abort || true) | ||
if(abort) return abortCb(cb, abort, onAbort) | ||
return cb(true) | ||
} | ||
@@ -32,5 +40,5 @@ if(!Array.isArray(array)) | ||
var i = 0 | ||
return function (end, cb) { | ||
if(end) | ||
return cb && cb(end) | ||
return function (abort, cb) { | ||
if(abort) | ||
return abortCb(cb, abort, onAbort) | ||
cb(i >= array.length || null, array[i++]) | ||
@@ -37,0 +45,0 @@ } |
@@ -28,1 +28,21 @@ | ||
}) | ||
tape('values, abort', function (t) { | ||
t.plan(3) | ||
var err = new Error('intentional') | ||
var read = pull.values([1,2,3], function (err) { | ||
t.end() | ||
}) | ||
read(null, function (_, one) { | ||
t.notOk(_) | ||
t.equal(one, 1) | ||
read(err, function (_err) { | ||
t.equal(_err, err) | ||
}) | ||
}) | ||
}) |
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
50356
1462