Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

from2

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

from2 - npm Package Compare versions

Comparing version 2.0.3 to 2.1.0

9

index.js

@@ -14,3 +14,10 @@ var Readable = require('readable-stream').Readable

return function (_, cb) {
cb(null, list.length ? list.shift() : null)
var err = null
var item = list.length ? list.shift() : null
if (item instanceof Error) {
err = item
item = null
}
cb(err, item)
}

@@ -17,0 +24,0 @@ }

2

package.json
{
"name": "from2",
"description": "Convenience wrapper for ReadableStream, with an API lifted from \"from\" and \"through2\"",
"version": "2.0.3",
"version": "2.1.0",
"main": "index.js",

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

@@ -87,1 +87,38 @@ var test = require('tape')

})
test('arrays can emit errors', function (t) {
var input = ['a', 'b', new Error('ooops'), 'c']
var stream = from(input)
var output = []
stream.on('data', function (letter) {
output.push(letter.toString())
})
stream.on('error', function(e){
t.deepEqual(['a', 'b'], output)
t.equal('ooops', e.message)
t.end()
})
stream.on('end', function () {
t.fail('the stream should have errored')
})
})
test('obj arrays can emit errors', function (t) {
var input = [{foo:'a'}, {foo:'b'}, new Error('ooops'), {foo:'c'}]
var stream = from.obj(input)
var output = []
stream.on('data', function (letter) {
output.push(letter)
})
stream.on('error', function(e){
t.deepEqual([{foo:'a'}, {foo:'b'}], output)
t.equal('ooops', e.message)
t.end()
})
stream.on('end', function () {
t.fail('the stream should have errored')
})
})
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