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 3.4.5 to 3.5.0

12

docs/glossary.md

@@ -25,10 +25,14 @@ # Glossary

## Source
## [Source](sources/index.md)
The first stream in the pipeline. The Source is not writable.
The first stream in the pipeline. The Source is not a reader (not writable).
## Sink
## [Sink](sinks/index.md)
The last Stream in the pipeline. The Sink is not readable.
The last stream in the pipeline. The Sink is not readable.
## [Through](throughs/index.md)
The stream (or streams) in the middle of the pipeline, between your source and sink. A through is a reader and readable.
## Push vs Pull

@@ -35,0 +39,0 @@

# pull-stream/throughs/flatten
## usage
### `flatten = require('pull-stream/throughs/flatten')`
### `flatten(streams)`
Turn a stream of streams or a stream of arrays into a stream of their items, (undoes group).
### `flatten()`
Turn a stream of arrays into a stream of their items, (undoes group).
## example
```js
test('flatten arrays', function (t) {
pull(
pull.values([
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]),
pull.flatten(),
pull.collect(function (err, numbers) {
t.deepEqual([1, 2, 3, 4, 5, 6, 7, 8, 9], numbers)
t.end()
})
)
})
test('flatten stream of streams', function (t) {
pull(
pull.values([
pull.values([1, 2, 3]),
pull.values([4, 5, 6]),
pull.values([7, 8, 9])
]),
pull.flatten(),
pull.collect(function (err, numbers) {
t.deepEqual([1, 2, 3, 4, 5, 6, 7, 8, 9], numbers)
t.end()
})
)
})
```
{
"name": "pull-stream",
"description": "minimal pull stream",
"version": "3.4.5",
"version": "3.5.0",
"homepage": "https://pull-stream.github.io",

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

@@ -5,4 +5,5 @@ 'use strict'

module.exports = function reduce (reducer, acc, cb) {
return drain(function (data) {
module.exports = function reduce (reducer, acc, cb ) {
if(!cb) cb = acc, acc = null
var sink = drain(function (data) {
acc = reducer(acc, data)

@@ -12,3 +13,12 @@ }, function (err) {

})
if (arguments.length === 2)
return function (source) {
source(null, function (end, data) {
//if ended immediately, and no initial...
if(end) return cb(end === true ? null : end)
acc = data; sink(source)
})
}
else
return sink
}

@@ -15,3 +15,13 @@

test('reduce without initial value', function (t) {
pull(
pull.values([1,2,3]),
pull.reduce(function (a, b) {return a + b}, function (err, val) {
t.equal(val, 6)
t.end()
})
)
})
test('reduce becomes drain', function (t) {

@@ -18,0 +28,0 @@ pull(

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