Socket
Socket
Sign inDemoInstall

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 2.5.1 to 2.6.0

12

docs/throughs.md

@@ -65,9 +65,13 @@ # Throughs

## group (len)
## group (length)
chunk incoming data into arrays of max length `len`,
(the last item may be shorter than len)
Group incoming data into arrays of max length `length`,
(the last item may be shorter than `length`)
Useful for items you can handle in batches.
Useful for data you can handle in batches.
## flatten ()
Turn a stream of arrays into a stream of their items, (undoes group).
## highWaterMark (n)

@@ -74,0 +78,0 @@

{
"name": "pull-stream",
"description": "minimal pull stream",
"version": "2.5.1",
"version": "2.6.0",
"homepage": "https://github.com/dominictarr/pull-stream",

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

@@ -27,1 +27,19 @@ var pull = require('../')

})
require('tape')('flatten (ungroup)', function (t) {
pull.count()
.pipe(pull.take(20))
.pipe(pull.group(7))
.pipe(pull.group(3))
.pipe(pull.through(console.log))
.pipe(pull.flatten())
.pipe(pull.through(console.log))
.pipe(pull.flatten())
.pipe(pull.collect(function (err, ary) {
console.log(ary)
t.deepEqual(ary, [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])
t.end()
}))
})

@@ -137,2 +137,21 @@ function prop (map) {

var flatten = exports.flatten = function (read) {
var chunk
return function (end, cb) {
//this means that the upstream is sending an error.
if(end) return read(ended = end, cb)
if(chunk && chunk.length)
return cb(null, chunk.shift())
read(null, function (err, data) {
if(err) return cb(err)
chunk = data
if(chunk && chunk.length)
return cb(null, chunk.shift())
})
}
}
var nextTick = process.nextTick

@@ -139,0 +158,0 @@

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