New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

pull-switch

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pull-switch - npm Package Compare versions

Comparing version
2.0.0
to
3.0.1
+14
-5
index.js

@@ -1,2 +0,2 @@

'use strict';
var pull = require('pull-stream')

@@ -8,11 +8,10 @@ var pushable = require('pull-pushable')

return pull.drain(function (item) {
var sink = pull.drain(function (item) {
var key = select(item)
if(!streams[key]) {
streams[key] = pushable(function (err) {
delete streams[key]
if(--n) return
--n
})
streams[key].pipe(createStream(item))
pull(streams[key], createStream(key))
}

@@ -25,2 +24,12 @@ streams[key].push(item)

})
sink.add = function (key, subsink) {
streams[key] = pushable(function (err) {
delete streams[key]
--n
})
pull(streams[key], subsink)
}
return sink
}
{
"name": "pull-switch",
"description": "split a pull-stream into many streams",
"version": "2.0.0",
"version": "3.0.1",
"homepage": "https://github.com/dominictarr/pull-switch",

@@ -12,3 +12,3 @@ "repository": {

"pull-pushable": "~1.1.0",
"pull-stream": "~2.18.2"
"pull-stream": "~2.23.0"
},

@@ -15,0 +15,0 @@ "devDependencies": {},

+17
-11

@@ -7,17 +7,23 @@ # pull-switch

var pull = require('pull-stream')
var switch = require('pull-switch')
var pswitch = require('pull-switch')
pull.count(100)
.pipe(switch(function select (e) {
// return key for which stream this is directed to.
return e % 2 ? 'even' : 'odd'
}, function createStream(key) {
//return a stream that will be piped to...
return pull.drain(function (d) {
console.log(key+'>', d)
pull(
pull.count(100),
pswitch(function select (e) {
// return key for which stream this is directed to.
return e % 2 ? 'even' : 'odd'
}, function createStream(key) { // 'even' or 'odd'
//return a stream that will be piped to...
return pull.drain(function (d) {
console.log(key+'>', d)
})
})
})
)
```
has the same api as [pull-fork](https://github.com/dominictarr/pull-fork)
but reads the source at full power instead of trying to follow
backpressure closely. In somecases it's simpler to do this,
as waiting (for back-pressure to release) creates the possibility of
deadlocks.

@@ -24,0 +30,0 @@ ## License