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

into-stream

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

into-stream - npm Package Compare versions

Comparing version 3.1.0 to 4.0.0

49

index.js

@@ -5,5 +5,5 @@ 'use strict';

module.exports = x => {
if (Array.isArray(x)) {
x = x.slice();
module.exports = input => {
if (Array.isArray(input)) {
input = input.slice();
}

@@ -14,10 +14,19 @@

prepare(x);
prepare(input);
function prepare(value) {
x = value;
promise = pIsPromise(x) ? x : null;
// we don't iterate on strings and buffers since slicing them is ~7x faster
const shouldIterate = !promise && x[Symbol.iterator] && typeof x !== 'string' && !Buffer.isBuffer(x);
iterator = shouldIterate ? x[Symbol.iterator]() : null;
input = value;
if (
input instanceof ArrayBuffer ||
(ArrayBuffer.isView(input) && !Buffer.isBuffer(input))
) {
input = Buffer.from(input);
}
promise = pIsPromise(input) ? input : null;
// We don't iterate on strings and buffers since slicing them is ~7x faster
const shouldIterate = !promise && input[Symbol.iterator] && typeof input !== 'string' && !Buffer.isBuffer(input);
iterator = shouldIterate ? input[Symbol.iterator]() : null;
}

@@ -37,3 +46,3 @@

if (x.length === 0) {
if (input.length === 0) {
setImmediate(cb, null, null);

@@ -43,4 +52,4 @@ return;

const chunk = x.slice(0, size);
x = x.slice(size);
const chunk = input.slice(0, size);
input = input.slice(size);

@@ -51,5 +60,5 @@ setImmediate(cb, null, chunk);

module.exports.obj = x => {
if (Array.isArray(x)) {
x = x.slice();
module.exports.obj = input => {
if (Array.isArray(input)) {
input = input.slice();
}

@@ -60,8 +69,8 @@

prepare(x);
prepare(input);
function prepare(value) {
x = value;
promise = pIsPromise(x) ? x : null;
iterator = !promise && x[Symbol.iterator] ? x[Symbol.iterator]() : null;
input = value;
promise = pIsPromise(input) ? input : null;
iterator = !promise && input[Symbol.iterator] ? input[Symbol.iterator]() : null;
}

@@ -81,3 +90,3 @@

this.push(x);
this.push(input);

@@ -84,0 +93,0 @@ setImmediate(cb, null, null);

{
"name": "into-stream",
"version": "3.1.0",
"description": "Convert a buffer/string/array/object/iterable/promise into a stream",
"license": "MIT",
"repository": "sindresorhus/into-stream",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"stream",
"buffer",
"string",
"object",
"array",
"iterable",
"promise",
"promises",
"from",
"into",
"to",
"transform",
"convert",
"readable",
"pull",
"gulpfriendly",
"value",
"str"
],
"dependencies": {
"from2": "^2.1.1",
"p-is-promise": "^1.1.0"
},
"devDependencies": {
"ava": "*",
"get-stream": "^3.0.0",
"xo": "*"
}
"name": "into-stream",
"version": "4.0.0",
"description": "Convert a string/promise/array/iterable/buffer/typedarray/arraybuffer/object into a stream",
"license": "MIT",
"repository": "sindresorhus/into-stream",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"stream",
"buffer",
"string",
"object",
"array",
"iterable",
"promise",
"promises",
"from",
"into",
"to",
"transform",
"convert",
"readable",
"pull",
"gulpfriendly",
"value",
"str"
],
"dependencies": {
"from2": "^2.1.1",
"p-is-promise": "^2.0.0"
},
"devDependencies": {
"ava": "^0.25.0",
"get-stream": "^4.1.0",
"p-event": "^2.1.0",
"xo": "^0.23.0"
}
}
# into-stream [![Build Status](https://travis-ci.org/sindresorhus/into-stream.svg?branch=master)](https://travis-ci.org/sindresorhus/into-stream)
> Convert a buffer/string/array/object/iterable/promise into a stream
> Convert a string/promise/array/iterable/buffer/typedarray/arraybuffer/object into a stream

@@ -11,3 +11,3 @@ Correctly chunks up the input and handles backpressure.

```
$ npm install --save into-stream
$ npm install into-stream
```

@@ -30,3 +30,3 @@

Type: `Buffer` `string` `Iterable<Buffer|string>` `Promise`<br>
Type: `Buffer` `TypedArray` `ArrayBuffer` `string` `Iterable<Buffer|string>` `Promise`<br>
Returns: [Readable stream](https://nodejs.org/api/stream.html#stream_class_stream_readable)

@@ -42,4 +42,9 @@

## Related
- [to-readable-stream](https://github.com/sindresorhus/to-readable-stream) - Simpler version of this module
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

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