Socket
Socket
Sign inDemoInstall

through

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

through - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

.travis.yml

63

index.js
var Stream = require('stream')
// through

@@ -10,4 +11,2 @@ //

exports.from = from
//create a readable writable stream.

@@ -83,61 +82,1 @@

//create a readable stream.
function from (source) {
if(Array.isArray(source))
return from (function (i) {
if(source.length)
this.emit('data', source.shift())
else
this.emit('end')
return true
})
var s = new Stream(), i = 0, ended = false, started = false
s.readable = true
s.writable = false
s.paused = false
s.pause = function () {
started = true
s.paused = true
}
function next () {
var n = 0, r = false
if(ended) return
while(!ended && !s.paused && source.call(s, i, function () {
if(!n++ && !s.ended && !s.paused)
next()
}))
;
}
s.resume = function () {
started = true
s.paused = false
next()
}
s.on('end', function () {
ended = true
s.readable = false
process.nextTick(s.destroy)
})
s.destroy = function () {
ended = true
s.emit('close')
}
/*
by default, the stream will start emitting at nextTick
if you want, you can pause it, after pipeing.
you can also resume before next tick, and that will also
work.
*/
process.nextTick(function () {
if(!started) s.resume()
})
return s
}
//create a writable stream.
function to () {
}
{
"name": "through",
"version": "0.0.2",
"version": "0.0.3",
"description": "simplified stream contruction",

@@ -5,0 +5,0 @@ "main": "index.js",

Sorry, the diff of this file is not supported yet

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