into-stream
Advanced tools
Comparing version 4.0.0 to 5.0.0
45
index.js
@@ -5,3 +5,3 @@ 'use strict'; | ||
module.exports = input => { | ||
const intoStream = input => { | ||
if (Array.isArray(input)) { | ||
@@ -33,5 +33,13 @@ input = input.slice(); | ||
return from(function reader(size, cb) { | ||
return from(function reader(size, callback) { | ||
if (promise) { | ||
promise.then(prepare).then(() => reader.call(this, size, cb), cb); | ||
(async () => { | ||
try { | ||
await prepare(await promise); | ||
reader.call(this, size, callback); | ||
} catch (error) { | ||
callback(error); | ||
} | ||
})(); | ||
return; | ||
@@ -41,4 +49,4 @@ } | ||
if (iterator) { | ||
const obj = iterator.next(); | ||
setImmediate(cb, null, obj.done ? null : obj.value); | ||
const object = iterator.next(); | ||
setImmediate(callback, null, object.done ? null : object.value); | ||
return; | ||
@@ -48,3 +56,3 @@ } | ||
if (input.length === 0) { | ||
setImmediate(cb, null, null); | ||
setImmediate(callback, null, null); | ||
return; | ||
@@ -56,7 +64,10 @@ } | ||
setImmediate(cb, null, chunk); | ||
setImmediate(callback, null, chunk); | ||
}); | ||
}; | ||
module.exports.obj = input => { | ||
module.exports = intoStream; | ||
module.exports.default = intoStream; | ||
module.exports.object = input => { | ||
if (Array.isArray(input)) { | ||
@@ -77,5 +88,13 @@ input = input.slice(); | ||
return from.obj(function reader(size, cb) { | ||
return from.obj(function reader(size, callback) { | ||
if (promise) { | ||
promise.then(prepare).then(() => reader.call(this, size, cb), cb); | ||
(async () => { | ||
try { | ||
await prepare(await promise); | ||
reader.call(this, size, callback); | ||
} catch (error) { | ||
callback(error); | ||
} | ||
})(); | ||
return; | ||
@@ -85,4 +104,4 @@ } | ||
if (iterator) { | ||
const obj = iterator.next(); | ||
setImmediate(cb, null, obj.done ? null : obj.value); | ||
const object = iterator.next(); | ||
setImmediate(callback, null, object.done ? null : object.value); | ||
return; | ||
@@ -93,4 +112,4 @@ } | ||
setImmediate(cb, null, null); | ||
setImmediate(callback, null, null); | ||
}); | ||
}; |
{ | ||
"name": "into-stream", | ||
"version": "4.0.0", | ||
"version": "5.0.0", | ||
"description": "Convert a string/promise/array/iterable/buffer/typedarray/arraybuffer/object into a stream", | ||
@@ -13,9 +13,10 @@ "license": "MIT", | ||
"engines": { | ||
"node": ">=6" | ||
"node": ">=8" | ||
}, | ||
"scripts": { | ||
"test": "xo && ava" | ||
"test": "xo && ava && tsd-check" | ||
}, | ||
"files": [ | ||
"index.js" | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
@@ -47,7 +48,8 @@ "keywords": [ | ||
"devDependencies": { | ||
"ava": "^0.25.0", | ||
"get-stream": "^4.1.0", | ||
"p-event": "^2.1.0", | ||
"xo": "^0.23.0" | ||
"ava": "^1.3.1", | ||
"get-stream": "^5.0.0", | ||
"p-event": "^3.0.0", | ||
"tsd-check": "^0.3.0", | ||
"xo": "^0.24.0" | ||
} | ||
} |
@@ -34,3 +34,3 @@ # into-stream [![Build Status](https://travis-ci.org/sindresorhus/into-stream.svg?branch=master)](https://travis-ci.org/sindresorhus/into-stream) | ||
### intoStream.obj(input) | ||
### intoStream.object(input) | ||
@@ -37,0 +37,0 @@ Type: `Object`, `Iterable<Object>` `Promise`<br> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6248
5
112
5