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 1.1.1 to 1.1.2

8

index.js

@@ -23,3 +23,3 @@ var Stream = require('stream')

stream.readable = stream.writable = true
stream.paused = false
stream.paused = false
stream.write = function (data) {

@@ -47,3 +47,3 @@ write.call(this, data)

//must call destroy next tick, to make sure we're after any
//stream piped from here.
//stream piped from here.
//this is only a problem if end is not emitted synchronously.

@@ -68,6 +68,6 @@ //a nicer way to do this is to make sure this is the last listener for 'end'

stream.end = function (data) {
if(ended) return
if(ended) return
ended = true
if(arguments.length) stream.write(data)
if(!buffer.length) _end()
_end() // will emit or queue
}

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

{
"name": "through",
"version": "1.1.1",
"version": "1.1.2",
"description": "simplified stream contruction",

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

@@ -38,1 +38,35 @@ var through = require('..')

}
exports['buffering has data in queue, when ends'] = function (t) {
/*
* If stream ends while paused with data in the queue,
* stream should still emit end after all data is written
* on resume.
*/
var ts = through(function (data) {
this.queue(data)
}, function () {
this.queue(null)
})
var ended = false, actual = []
ts.on('data', actual.push.bind(actual))
ts.on('end', function () {
ended = true
})
ts.pause()
ts.write(1)
ts.write(2)
ts.write(3)
ts.end()
t.deepEqual(actual, [], 'no data written yet, still paused')
t.ok(!ended, 'end not emitted yet, still paused')
ts.resume()
t.deepEqual(actual, [1, 2, 3], 'resumed, all data should be delivered')
t.ok(ended, 'end should be emitted once all data was delivered')
t.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