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 1.2.0 to 1.3.0

13

index.js

@@ -11,7 +11,16 @@ var Readable = require('readable-stream').Readable

function toFunction(list) {
list = list.slice()
return function (_, cb) {
cb(null, list.length ? list.shift() : null)
}
}
function from2(opts, read) {
if (typeof opts === 'function') {
if (typeof opts !== 'object' || Array.isArray(opts)) {
read = opts
opts = {}
}
if (Array.isArray(read)) read = toFunction(read)

@@ -70,3 +79,3 @@ var rs = new Proto(opts)

function obj(opts, read) {
if (typeof opts === 'function') {
if (typeof opts === 'function' || Array.isArray(opts)) {
read = opts

@@ -73,0 +82,0 @@ opts = {}

2

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

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

# from2 [![Flattr this!](https://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=hughskennedy&url=http://github.com/hughsk/from2&title=from2&description=hughsk/from2%20on%20GitHub&language=en_GB&tags=flattr,github,javascript&category=software)[![experimental](http://hughsk.github.io/stability-badges/dist/experimental.svg)](http://github.com/hughsk/stability-badges) #
`from2` is a high-level module for creating readable streams that properly handle backpressure.
Convience wrapper for

@@ -4,0 +6,0 @@ [readable-stream](http://github.com/isaacs/readable-stream)'s `ReadableStream`

@@ -60,2 +60,28 @@ var test = require('tape')

stream.destroy()
})
})
test('arrays', function (t) {
var input = ['a', 'b', 'c']
var stream = from(input)
var output = []
stream.on('data', function (letter) {
output.push(letter.toString())
})
stream.on('end', function () {
t.deepEqual(input, output)
t.end()
})
})
test('obj arrays', function (t) {
var input = [{foo:'a'}, {foo:'b'}, {foo:'c'}]
var stream = from.obj(input)
var output = []
stream.on('data', function (letter) {
output.push(letter)
})
stream.on('end', function () {
t.deepEqual(input, output)
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