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

pull-write

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pull-write - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

39

index.js

@@ -14,5 +14,10 @@ //another idea: buffer 2* the max, but only call write with half of that,

reduce = reduce || append
var ended
return function (read) {
var ended, _cb, _read
function reader (read) {
var queue = null, writing = false, length = 0
_read = read
if(ended) return read(ended, function (err) {
cb(err)
_cb && _cb()
})

@@ -27,3 +32,6 @@ function flush () {

if(ended === true && !length) cb(err)
else if(ended && ended !== true) cb(err || ended)
else if(ended && ended !== true) {
cb(ended)
_cb && _cb()
}
else if(err) read(ended = err, cb) //abort upstream.

@@ -34,2 +42,3 @@ else if(length) flush()

}
function next (end, data) {

@@ -46,6 +55,28 @@ if(ended) return

}
reader.abort = function (__cb) {
_cb = function (end) {
__cb && __cb()
}
read(ended = new Error('aborted'), function (end) {
end = end === true ? null : end
if(!writing) {
cb && cb(end)
_cb && _cb(end)
}
})
}
read(null, next)
}
reader.abort = function (cb) {
ended = new Error('aborted before connecting')
_cb = function (err) {
cb && cb()
}
}
return reader
}

2

package.json
{
"name": "pull-write",
"description": "",
"version": "1.0.2",
"version": "1.1.0",
"homepage": "https://github.com/dominictarr/pull-write",

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

@@ -139,2 +139,56 @@ var tape = require('tape')

tape('abort', function (t) {
t.plan(2)
var output = [], writer = createWrite(function write(data, cb) {
if(data == null) throw new Error('data cannot be null')
setImmediate(function () {
output = output.concat(data); cb()
})
}, function (a, b) {
if(!(b%2)) return a
return (a||[]).concat(b)
}, 10, function (err) {
t.ok(err)
})
pull(
pull.count(30),
writer
)
writer.abort(function (err) {
t.notOk(err)
t.end()
})
})
tape('abort', function (t) {
t.plan(2)
var writer = createWrite(function write(data, cb) {
if(data == null) throw new Error('data cannot be null')
setImmediate(function () {
output = output.concat(data); cb()
})
}, function (a, b) {
if(!(b%2)) return a
return (a||[]).concat(b)
}, 10, function (err) {
t.ok(err)
})
writer.abort(function (err) {
t.notOk(err)
t.end()
})
pull(
pull.count(30),
writer
)
})
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