Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pull-stream

Package Overview
Dependencies
Maintainers
1
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pull-stream - npm Package Compare versions

Comparing version 3.0.1 to 3.1.0

test/drain-abort.js

2

package.json
{
"name": "pull-stream",
"description": "minimal pull stream",
"version": "3.0.1",
"version": "3.1.0",
"homepage": "https://github.com/dominictarr/pull-stream",

@@ -6,0 +6,0 @@ "repository": {

@@ -88,10 +88,12 @@ # pull-stream

//read source and log it.
var logger = function (read) {
read(null, function next(end, data) {
if(end === true) return
if(end) throw end
var logger = function () {
return function (read) {
read(null, function next(end, data) {
if(end === true) return
if(end) throw end
console.log(data)
read(null, next)
})
console.log(data)
read(null, next)
})
}
}

@@ -103,3 +105,3 @@ ```

```js
var rand = random())
var rand = random()
var log = logger()

@@ -106,0 +108,0 @@

@@ -17,5 +17,7 @@ 'use strict'

var drain = exports.drain = function (op, done) {
var read, abort
return function (read) {
function sink (_read) {
read = _read
if(abort) return sink.abort()
//this function is much simpler to write if you

@@ -25,29 +27,35 @@ //just use recursion, but by using a while loop

;(function next() {
var loop = true, cbed = false
while(loop) {
cbed = false
read(null, function (end, data) {
cbed = true
if(end) {
var loop = true, cbed = false
while(loop) {
cbed = false
read(null, function (end, data) {
cbed = true
if(end = end || abort) {
loop = false
if(done) done(end === true ? null : end)
else if(end && end !== true)
throw end
}
else if(op && false === op(data) || abort) {
loop = false
read(abort || true, done || function () {})
}
else if(!loop){
next()
}
})
if(!cbed) {
loop = false
if(done) done(end === true ? null : end)
else if(end && end !== true)
throw end
return
}
else if(op && false === op(data)) {
loop = false
read(true, done || function () {})
}
else if(!loop){
next()
}
})
if(!cbed) {
loop = false
return
}
}
})()
})()
}
sink.abort = function (err) {
abort = err || true
if(read) return read(abort, function () {})
}
return sink
}

@@ -110,1 +118,5 @@

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