Socket
Socket
Sign inDemoInstall

pull-cat

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pull-cat - npm Package Compare versions

Comparing version 1.1.8 to 1.1.9

25

index.js

@@ -1,5 +0,4 @@

var pull = require('pull-core')
var noop = function () {}
function all(ary, abort, cb) {
function abortAll(ary, abort, cb) {
var n = ary.length

@@ -19,7 +18,7 @@ if(!n) return cb(abort)

module.exports = pull.Source(function (streams) {
module.exports = function (streams) {
return function (abort, cb) {
;(function next () {
if(abort)
all(streams, abort, cb)
abortAll(streams, abort, cb)
else if(!streams.length)

@@ -32,11 +31,5 @@ cb(true)

if(err) {
streams.shift()
if(err !== true) {
abort = err
//abort all streams
while(streams.length)
(streams.shift() || noop)(err, noop)
cb(err)
}
next()
streams.shift() //drop the first, has already ended.
if(err === true) next()
else abortAll(streams, err, cb)
}

@@ -48,2 +41,6 @@ else

}
})
}
{
"name": "pull-cat",
"description": "concatenate pull-streams",
"version": "1.1.8",
"version": "1.1.9",
"homepage": "https://github.com/dominictarr/pull-cat",

@@ -10,10 +10,7 @@ "repository": {

},
"dependencies": {
"pull-core": "~1.0.0"
},
"devDependencies": {
"pull-stream": "~2.20",
"tape": "~1.0",
"pull-abortable": "~4.1.0",
"pull-pushable": "~1.1.4",
"pull-abortable": "~4.1.0"
"pull-stream": "^3.1.0",
"tape": "^4.4.0"
},

@@ -20,0 +17,0 @@ "scripts": {

@@ -5,2 +5,11 @@ # pull-cat

construct a new source stream from a sequential list of source streams,
reading from each one in turn until it ends, then the next, etc.
If one stream errors, then the rest of the streams are aborted immediately.
If the cat stream is aborted (i.e. if it's sink errors) then all the streams
are aborted.
A cat stream is a moderately challenging stream to implement,
especially in the context of error states.
# example

@@ -11,4 +20,6 @@

var pull = require('pull-stream')
cat([pull.values([1,2,3]), pull.values([4,5,6])])
.pipe(...)
pull(
cat([pull.values([1,2,3]), pull.values([4,5,6])]),
sink...
)
```

@@ -18,2 +29,4 @@

If a stream errors, stop all the streams.
if the concatenated stream is aborted, abort all the streams,
then callback to the aborter.

@@ -23,1 +36,3 @@ ## License

MIT

@@ -73,2 +73,3 @@

pull.collect(function (_err) {
console.log('COLLECT END', _err)
t.equal(_err, err)

@@ -128,1 +129,23 @@ t.end()

})
test('abort streams after error', function (t) {
var err = new Error('test error')
var aborted = false
pull(
cat([pull.values([1,2,3]), function (_, cb) {
cb(err)
}, function (_err, cb) {
//this stream should be aborted.
aborted = true
t.strictEqual(_err, err)
cb()
}]),
pull.collect(function (_err) {
t.equal(aborted, true)
t.equal(_err, err)
t.end()
})
)
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc