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.6.3 to 3.6.4

2

package.json
{
"name": "pull-stream",
"description": "minimal pull stream",
"version": "3.6.3",
"version": "3.6.4",
"homepage": "https://pull-stream.github.io",

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

@@ -28,5 +28,5 @@ # pull-stream

```
Note that `pull(a, b, c)` is basically the same as `a.pipe(b).pipe(c)`.
note that `pull(a, b, c)` is basically the same as `a.pipe(b).pipe(c)`.
To grok how pull-streams work, read through [pull-streams by example](https://github.com/dominictarr/pull-stream-examples)
to grok how pull-streams work, read through [pull-streams by example](https://github.com/dominictarr/pull-stream-examples)

@@ -38,3 +38,3 @@ ## How do I do X with pull-streams?

Check the [pull-stream FAQ](https://github.com/pull-stream/pull-stream-faq)
and post an issue if you have a question that is not covered.
and post an issue if you have a question that is not on that.

@@ -60,13 +60,13 @@ ## Compatibily with node streams

### Source (readable stream that produces values)
### Source (aka, Readable)
A Source is a function `read(end, cb)`,
The readable stream is just a `function read(end, cb)`,
that may be called many times,
and will (asynchronously) call `cb(null, data)` once for each call.
and will (asynchronously) `cb(null, data)` once for each call.
To signify an end state, the stream eventually returns `cb(err)` or `cb(true)`.
When signifying an end state, `data` *must* be ignored.
When indicating a terminal state, `data` *must* be ignored.
The `read` function *must not* be called until the previous call has called back.
Unless, it is a call to abort the stream due to an error (`read(truthy, cb)`).
Unless, it is a call to abort the stream (`read(truthy, cb)`).

@@ -86,7 +86,6 @@ ```js

### Sink (reader or writable stream that consumes values)
### Sink; (aka, Reader, "writable")
A Sink is a function `reader(read)` that calls a Source (`read(null, cb`),
until it decides to stop (by calling `read(true, cb)`), or the readable ends (`read` calls
`cb(Error || true)`
A sink is just a `reader` function that calls a Source (read function),
until it decideds to stop, or the readable ends. `cb(err || true)`

@@ -110,3 +109,3 @@ All [Throughs](./docs/throughs/index.md)

Since Sources and Sinks are functions, you can pass them to each other!
Since these are just functions, you can pass them to each other!

@@ -151,5 +150,6 @@ ```js

A through stream is both a reader (consumes values) and a readable (produces values).
It's a function that takes a `read` function (a Sink),
and returns another `read` function (a Source).
A through stream is a reader on one end and a readable on the other.
It's Sink that returns a Source.
That is, it's just a function that takes a `read` function,
and returns another `read` function.

@@ -156,0 +156,0 @@ ```js

@@ -93,2 +93,25 @@ var pull = require('../')

tape("async map should pass it's own error", function (t) {
var i = 0
var error = new Error('error on last call')
pull(
function (end, cb) {
end ? cb(true) : cb(null, i+1)
},
pull.asyncMap((data, cb) => {
setTimeout(() => {
if(++i < 5) cb(null, data)
else {
cb(error)
}
}, 100)
}),
pull.collect(function (err, five) {
t.equal(err, error, 'should return err')
t.deepEqual(five, [1,2,3,4], 'should skip failed item')
t.end()
})
)
})

@@ -120,46 +120,22 @@ var pull = require('../')

test('take when abort on the first message', function (t) {
var read = pull(
function (err, cb) {
t.ok(err)
cb(err)
},
pull.take(5)
test('take should throw error on last read', function (t) {
var i = 0
var error = new Error('error on last call')
pull(
pull.values([1,2,3,4,5,6,7,8,9,10]),
pull.take(function(n) {return n<5}, {last: true}),
// pull.take(5),
pull.asyncMap((data, cb) => {
setTimeout(() => {
if(++i < 5) cb(null, data)
else cb(error)
}, 100)
}),
pull.collect(function (err, five) {
t.equal(err, error, 'should return err')
t.deepEqual(five, [1,2,3,4], 'should skip failed item')
t.end()
})
)
read(true, function (err) {
t.ok(err)
t.end()
})
})
test('take when abort on the first message', function (t) {
var cbs = []
var read = pull(
function (err, cb) {
cbs.push(cb)
},
pull.take(5)
)
read(null, function () {
})
read(true, function (err) {
t.ok(err)
t.end()
})
t.equal(cbs.length, 2)
var abort_cb = cbs.pop()
abort_cb(true)
})

@@ -15,4 +15,8 @@ 'use strict'

aborted = abort
if(!busy) read(abort, cb)
else read(abort, function () {
if(!busy) read(abort, function (err) {
//incase the source has already ended normally,
//we should pass our own error.
cb(abort)
})
else read(abort, function (err) {
//if we are still busy, wait for the mapper to complete.

@@ -45,1 +49,6 @@ if(busy) abortCb = cb

@@ -24,3 +24,3 @@ 'use strict'

return function (end, cb) {
if(ended) last ? terminate(cb) : cb(ended)
if(ended && !end) last ? terminate(cb) : cb(ended)
else if(ended = end) read(ended, cb)

@@ -27,0 +27,0 @@ else

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