New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

from

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

from - npm Package Compare versions

Comparing version 0.1.3 to 0.1.7

.travis.yml

8

index.js

@@ -15,6 +15,6 @@

if(Array.isArray(source)) {
source = source.slice()
var source_index = 0, source_len = source.length;
return from (function (i) {
if(source.length)
this.emit('data', source.shift())
if(source_index < source_len)
this.emit('data', source[source_index++])
else

@@ -41,3 +41,3 @@ this.emit('end')

if(!s.ended && !s.paused)
next()
process.nextTick(next);
}))

@@ -44,0 +44,0 @@ ;

{
"name": "from",
"version": "0.1.3",
"version": "0.1.7",
"description": "Easy way to make a Readable Stream",

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

@@ -45,2 +45,70 @@ var from = require('..')

exports['inc - async'] = function (test) {
var fs = from(function (i, next) {
this.emit('data', i)
if(i >= 99)
return this.emit('end')
next();
})
spec(fs).readable().validateOnExit()
read(fs, function (err, arr) {
test.equal(arr.length, 100)
test.done()
})
}
exports['large stream - from an array'] = function (test) {
var l = 100000
, expected = []
while(l--) expected.push(l * Math.random())
var fs = from(expected.slice())
spec(fs).readable().validateOnExit()
read(fs, function (err, arr) {
a.deepEqual(arr, expected)
test.done()
})
}
exports['large stream - callback return true'] = function (test) {
var fs = from(function (i, next) {
this.emit('data', i)
if(i >= 99999)
return this.emit('end')
return true;
})
spec(fs).readable().validateOnExit()
read(fs, function (err, arr) {
test.equal(arr.length, 100000)
test.done()
})
}
exports['large stream - callback call next()'] = function (test) {
var fs = from(function (i, next) {
this.emit('data', i)
if(i >= 99999)
return this.emit('end')
next();
})
spec(fs).readable().validateOnExit()
read(fs, function (err, arr) {
test.equal(arr.length, 100000)
test.done()
})
}
exports['simple'] = function (test) {

@@ -106,3 +174,4 @@

else
self.emit('end')
if(!self.ended)
self.emit('end')
n()

@@ -109,0 +178,0 @@ }, 3)

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