@async-generators/iterable
Advanced tools
Comparing version 0.2.0 to 0.3.0
@@ -1,1 +0,1 @@ | ||
export default function <T>(source: AsyncIterable<T> | Iterable<T>, errmsg?: string): AsyncIterable<T>; | ||
export default function iterable<T>(source: AsyncIterable<T> | Iterable<T> | (() => AsyncIterable<T> | Iterable<T>), errmsg?: string): AsyncIterable<T>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
function default_1(source, errmsg = "source parameter is not iterable") { | ||
function iterable(source, errmsg = "source parameter is not iterable") { | ||
if (source == undefined) { | ||
throw Error(errmsg); | ||
} | ||
const It = source[Symbol.asyncIterator] || source[Symbol.iterator]; | ||
if (typeof It !== "function") | ||
if (typeof It !== "function") { | ||
if (typeof source === "function") { | ||
return iterable(source(), errmsg); | ||
} | ||
throw Error(errmsg); | ||
} | ||
return { | ||
@@ -11,3 +18,3 @@ [Symbol.asyncIterator]() { return It.call(source); } | ||
} | ||
exports.default = default_1; | ||
exports.default = iterable; | ||
//# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
export default function <T>(source: AsyncIterable<T> | Iterable<T>, errmsg?: string): AsyncIterable<T>; | ||
export default function iterable<T>(source: AsyncIterable<T> | Iterable<T> | (() => AsyncIterable<T> | Iterable<T>), errmsg?: string): AsyncIterable<T>; |
@@ -1,5 +0,12 @@ | ||
export default function (source, errmsg = "source parameter is not iterable") { | ||
export default function iterable(source, errmsg = "source parameter is not iterable") { | ||
if (source == undefined) { | ||
throw Error(errmsg); | ||
} | ||
const It = source[Symbol.asyncIterator] || source[Symbol.iterator]; | ||
if (typeof It !== "function") | ||
if (typeof It !== "function") { | ||
if (typeof source === "function") { | ||
return iterable(source(), errmsg); | ||
} | ||
throw Error(errmsg); | ||
} | ||
return { | ||
@@ -6,0 +13,0 @@ [Symbol.asyncIterator]() { return It.call(source); } |
{ | ||
"name": "@async-generators/iterable", | ||
"description": "wrap async/sync Iterable as an asyncIterable", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Meirion Hughes", |
@@ -1,8 +0,18 @@ | ||
export default function <T>( | ||
source: AsyncIterable<T> | Iterable<T>, | ||
errmsg:string = "source parameter is not iterable" | ||
export default function iterable<T>( | ||
source: AsyncIterable<T> | Iterable<T> | (() => AsyncIterable<T> | Iterable<T>), | ||
errmsg: string = "source parameter is not iterable" | ||
): AsyncIterable<T> { | ||
if (source == undefined) { | ||
throw Error(errmsg); | ||
} | ||
const It = source[Symbol.asyncIterator] || source[Symbol.iterator]; | ||
if (typeof It !== "function") | ||
if (typeof It !== "function") { | ||
if (typeof source === "function") { | ||
return iterable(source(), errmsg); | ||
} | ||
throw Error(errmsg); | ||
} | ||
return { | ||
@@ -9,0 +19,0 @@ [Symbol.asyncIterator]() { return It.call(source); } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
8598
52