Socket
Socket
Sign inDemoInstall

pull-pushable

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pull-pushable - npm Package Compare versions

Comparing version 2.0.1 to 2.1.0

19

index.js
module.exports = pullPushable
function pullPushable (onClose) {
function pullPushable (separated, onClose) {
if (typeof separated === 'function') {
onClose = separated
separated = false
}
// create a buffer for data

@@ -28,3 +33,3 @@ // that have been pushed

var ended
read.end = function (end) {
function end (end) {
ended = ended || end || true

@@ -35,3 +40,3 @@ // attempt to drain

read.push = function (data) {
function push (data) {
if (ended) return

@@ -50,2 +55,10 @@ // if sink already waiting,

// Return functions separated from source { push, end, source }
if (separated) {
return { push, end, source: read }
}
// Return normal
read.push = push
read.end = end
return read

@@ -52,0 +65,0 @@

2

package.json
{
"name": "pull-pushable",
"description": "pull-stream with a push interface",
"version": "2.0.1",
"version": "2.1.0",
"homepage": "https://github.com/dominictarr/pull-pushable",

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

@@ -47,4 +47,24 @@ # pull-pushable

When giving the stream away and you don't want the user to have the `push`/`end` functions,
you can pass a `separated` option. It returns `{ push, end, source }`.
```js
function createStream () {
var p = Pushable(true) // optionally pass `onDone` after it
somethingAsync((err, data) => {
if (err) return p.end(err)
p.push(data)
})
return p.source
}
var stream = createStream()
// stream.push === undefined
```
## License
MIT

@@ -29,1 +29,24 @@ var pull = require('pull-stream')

})
test('pushable with separated functions', function (t) {
t.plan(3)
var { push, end, source } = pushable(true)
t.is(typeof source, 'function', 'is a function')
t.is(source.length, 2, 'is a source stream')
pull(
source,
pull.collect(function (err, data) {
if (err) throw err
console.log(data)
t.same(data, [1, 2, 3], 'got expected output')
})
)
push(1)
push(2)
push(3)
end()
})
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