@pulumi/query
Advanced tools
Comparing version
import { IterableBase } from "./base"; | ||
import { AsyncIterableIterator, AsyncQueryable, AsyncQueryableGrouping, AsyncQuerySource, Operator, OrderKey } from "./interfaces"; | ||
import { AsyncQueryable, AsyncQueryableGrouping, AsyncQuerySource, Operator, OrderKey } from "./interfaces"; | ||
export declare class AsyncQueryableImpl<TSource> extends IterableBase<TSource> implements AsyncQueryable<TSource> { | ||
static from<TSource>(source: AsyncQuerySource<TSource>): AsyncQueryableImpl<TSource>; | ||
protected constructor(source: AsyncIterableIterator<TSource>); | ||
protected constructor(source: AsyncQuerySource<TSource>); | ||
filter(f: (t: TSource, i: number) => boolean): AsyncQueryable<TSource>; | ||
flatMap<TInner, TResult = TInner>(selector: (t: TSource, index: number) => AsyncQuerySource<TInner>, resultSelector?: (t: TSource, ti: TInner) => TResult | Promise<TResult>): AsyncQueryable<TResult>; | ||
flatMap<TInner, TResult = TInner>(selector: (t: TSource, index: number) => AsyncQuerySource<TInner> | Promise<AsyncQuerySource<TInner>>, resultSelector?: (t: TSource, ti: TInner) => TResult | Promise<TResult>): AsyncQueryable<TResult>; | ||
map<TResult>(f: (t: TSource, i: number) => TResult | Promise<TResult>): AsyncQueryable<TResult>; | ||
@@ -14,3 +14,3 @@ skip(n: number): AsyncQueryable<TSource>; | ||
join<TInner, TKey, TResult>(inner: AsyncQuerySource<TInner>, outerKeySelector: (to: TSource) => TKey | Promise<TKey>, innerKeySelector: (ti: TInner) => TKey | Promise<TKey>, resultSelector: (to: TSource, ti: TInner) => TResult | Promise<TResult>): AsyncQueryable<TResult>; | ||
groupJoin<TInner, TKey, TResult>(inner: AsyncQuerySource<TInner>, outerKeySelector: (to: TSource) => TKey | Promise<TKey>, innerKeySelector: (ti: TInner) => TKey | Promise<TKey>, resultSelector: (to: TSource, ti: AsyncQuerySource<TInner>) => TResult | Promise<TResult>): AsyncQueryable<TResult>; | ||
groupJoin<TInner, TKey, TResult>(inner: AsyncQuerySource<TInner>, outerKeySelector: (to: TSource) => TKey | Promise<TKey>, innerKeySelector: (ti: TInner) => TKey | Promise<TKey>, resultSelector: (to: TSource, ti: AsyncQueryable<TInner>) => TResult | Promise<TResult>): AsyncQueryable<TResult>; | ||
concat(iter: AsyncQuerySource<TSource>): AsyncQueryable<TSource>; | ||
@@ -64,3 +64,3 @@ reverse(): AsyncQueryable<TSource>; | ||
readonly key: TKey; | ||
constructor(key: TKey, group: AsyncIterableIterator<TSource>); | ||
constructor(key: TKey, group: AsyncIterable<TSource>); | ||
} |
@@ -24,3 +24,2 @@ "use strict"; | ||
}; | ||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } | ||
var __asyncValues = (this && this.__asyncValues) || function (o) { | ||
@@ -33,2 +32,3 @@ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); | ||
}; | ||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } | ||
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { | ||
@@ -54,3 +54,3 @@ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); | ||
static from(source) { | ||
return new AsyncQueryableImpl(sources_1.from(source)); | ||
return new AsyncQueryableImpl(source); | ||
} | ||
@@ -124,7 +124,7 @@ constructor(source) { | ||
var e_1, _a; | ||
const groups = yield __await(operators_1.groupBy(keySelector, elementSelector)(source)); | ||
const groups = operators_1.groupBy(keySelector, elementSelector)(source); | ||
try { | ||
for (var groups_1 = __asyncValues(groups), groups_1_1; groups_1_1 = yield __await(groups_1.next()), !groups_1_1.done;) { | ||
const group = groups_1_1.value; | ||
yield yield __await(new GroupingImpl(group.key, sources_1.from(group))); | ||
yield yield __await(new GroupingImpl(group.key, group)); | ||
} | ||
@@ -203,3 +203,5 @@ } | ||
count(predicate) { | ||
return operators_1.count(predicate)(this); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return operators_1.count(predicate)(this); | ||
}); | ||
} | ||
@@ -254,6 +256,6 @@ sum(selector) { | ||
pipe(...ops) { | ||
return new AsyncQueryableImpl((function (source) { | ||
const src = function (source) { | ||
return __asyncGenerator(this, arguments, function* () { | ||
var e_3, _a; | ||
let newSource = source; | ||
let newSource = sources_1.from(source); | ||
for (const op of ops) { | ||
@@ -276,3 +278,4 @@ newSource = op(newSource); | ||
}); | ||
})(this)); | ||
}; | ||
return new AsyncQueryableImpl(sources_1.from(() => src(this.source))); | ||
} | ||
@@ -279,0 +282,0 @@ } |
@@ -1,11 +0,10 @@ | ||
import { AsyncIterableIterator, GroupedAsyncIterableIterator } from "./interfaces"; | ||
export declare abstract class IterableBase<T> implements AsyncIterableIterator<T> { | ||
private readonly core; | ||
constructor(core: AsyncIterableIterator<T>); | ||
[Symbol.asyncIterator](): AsyncIterableIterator<T>; | ||
next(value?: any): Promise<IteratorResult<T>>; | ||
import { AsyncQuerySource, GroupedAsyncIterable } from "./interfaces"; | ||
export declare abstract class IterableBase<T> implements AsyncIterable<T> { | ||
protected readonly source: AsyncQuerySource<T>; | ||
constructor(source: AsyncQuerySource<T>); | ||
[Symbol.asyncIterator](): AsyncIterator<T, any, undefined>; | ||
} | ||
export declare class GroupedAsyncIterableIteratorImpl<TKey, TSource> extends IterableBase<TSource> implements GroupedAsyncIterableIterator<TKey, TSource> { | ||
export declare class GroupedAsyncIterableImpl<TKey, TSource> extends IterableBase<TSource> implements GroupedAsyncIterable<TKey, TSource> { | ||
readonly key: TKey; | ||
constructor(key: TKey, core: AsyncIterableIterator<TSource>); | ||
constructor(key: TKey, core: AsyncIterable<TSource>); | ||
} |
14
base.js
@@ -16,15 +16,13 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const sources_1 = require("./sources"); | ||
class IterableBase { | ||
constructor(core) { | ||
this.core = core; | ||
constructor(source) { | ||
this.source = source; | ||
} | ||
[Symbol.asyncIterator]() { | ||
return this; | ||
return sources_1.from(this.source)[Symbol.asyncIterator](); | ||
} | ||
next(value) { | ||
return this.core.next(value); | ||
} | ||
} | ||
exports.IterableBase = IterableBase; | ||
class GroupedAsyncIterableIteratorImpl extends IterableBase { | ||
class GroupedAsyncIterableImpl extends IterableBase { | ||
constructor(key, core) { | ||
@@ -35,2 +33,2 @@ super(core); | ||
} | ||
exports.GroupedAsyncIterableIteratorImpl = GroupedAsyncIterableIteratorImpl; | ||
exports.GroupedAsyncIterableImpl = GroupedAsyncIterableImpl; |
@@ -1,2 +0,2 @@ | ||
import { AsyncIterableIterator, AsyncQueryable, AsyncQuerySource } from "./interfaces"; | ||
import { AsyncQueryable, AsyncQuerySource } from "./interfaces"; | ||
export { AsyncQueryable, AsyncQueryableGrouping, OrderKey } from "./interfaces"; | ||
@@ -24,3 +24,3 @@ /** | ||
*/ | ||
export declare function empty<TResult>(): AsyncIterableIterator<TResult>; | ||
export declare function empty<TResult>(): AsyncQueryable<TResult>; | ||
/** | ||
@@ -27,0 +27,0 @@ * Generates a (potentially infinite) sequence by repeating a single value. |
@@ -19,7 +19,7 @@ declare global { | ||
export declare function isIterable<T>(o: any): o is Iterable<T>; | ||
export declare type Operator<TSource, TResult> = (source: AsyncIterableIterator<TSource>) => AsyncIterableIterator<TResult>; | ||
export declare type Evaluator<TSource, TResult> = (source: AsyncIterableIterator<TSource>) => Promise<TResult>; | ||
export declare type AsyncQuerySource<TSource> = Iterable<TSource> | AsyncIterable<TSource> | Promise<Iterable<TSource>> | Promise<AsyncIterable<TSource>>; | ||
export declare type Operator<TSource, TResult> = (source: AsyncIterable<TSource>) => AsyncIterable<TResult>; | ||
export declare type Evaluator<TSource, TResult> = (source: AsyncIterable<TSource>) => Promise<TResult>; | ||
export declare type AsyncQuerySource<TSource> = Iterable<TSource> | AsyncIterable<TSource> | (() => Iterable<TSource> | AsyncIterable<TSource>); | ||
export declare type OrderKey = string | number; | ||
export interface AsyncQueryable<TSource> extends AsyncIterableIterator<TSource> { | ||
export interface AsyncQueryable<TSource> extends AsyncIterable<TSource> { | ||
/** | ||
@@ -50,3 +50,3 @@ * Filters out all elements in a sequence for which `predicate` does not return true. | ||
*/ | ||
flatMap<TInner, TResult = TInner>(transform: (t: TSource, index: number) => AsyncQuerySource<TInner>, // TODO: Make this iterable. | ||
flatMap<TInner, TResult = TInner>(transform: (t: TSource, index: number) => AsyncQuerySource<TInner> | Promise<AsyncQuerySource<TInner>>, // TODO: Make this iterable. | ||
resultTransform?: (t: TSource, ti: TInner) => TResult | Promise<TResult>): AsyncQueryable<TResult>; | ||
@@ -92,3 +92,3 @@ /** | ||
join<TInner, TKey, TResult>(inner: AsyncQuerySource<TInner>, outerKeySelector: (to: TSource) => TKey | Promise<TKey>, innerKeySelector: (ti: TInner) => TKey | Promise<TKey>, resultSelector: (to: TSource, ti: TInner) => TResult | Promise<TResult>): AsyncQueryable<TResult>; | ||
groupJoin<TInner, TKey, TResult>(inner: AsyncQuerySource<TInner>, outerKeySelector: (to: TSource) => TKey | Promise<TKey>, innerKeySelector: (ti: TInner) => TKey | Promise<TKey>, resultSelector: (to: TSource, ti: AsyncQuerySource<TInner>) => TResult | Promise<TResult>): AsyncQueryable<TResult>; | ||
groupJoin<TInner, TKey, TResult>(inner: AsyncQuerySource<TInner>, outerKeySelector: (to: TSource) => TKey | Promise<TKey>, innerKeySelector: (ti: TInner) => TKey | Promise<TKey>, resultSelector: (to: TSource, ti: AsyncQueryable<TInner>) => TResult | Promise<TResult>): AsyncQueryable<TResult>; | ||
/** | ||
@@ -312,6 +312,7 @@ * Concatenates two sequences. | ||
} | ||
export interface GroupedAsyncIterableIterator<TKey, TSource> extends AsyncIterableIterator<TSource> { | ||
export interface GroupedAsyncIterable<TKey, TSource> extends AsyncIterable<TSource> { | ||
key: TKey; | ||
} | ||
export interface AsyncQueryableGrouping<TKey, TSource> extends GroupedAsyncIterableIterator<TKey, TSource>, AsyncQueryable<TSource> { | ||
export interface AsyncQueryableGrouping<TKey, TSource> extends AsyncQueryable<TSource> { | ||
key: TKey; | ||
} |
@@ -18,8 +18,8 @@ "use strict"; | ||
function isAsyncIterable(o) { | ||
return typeof o[Symbol.asyncIterator] === "function"; | ||
return o !== undefined && typeof o[Symbol.asyncIterator] === "function"; | ||
} | ||
exports.isAsyncIterable = isAsyncIterable; | ||
function isIterable(o) { | ||
return typeof o[Symbol.iterator] === "function"; | ||
return o !== undefined && typeof o[Symbol.iterator] === "function"; | ||
} | ||
exports.isIterable = isIterable; |
@@ -1,4 +0,4 @@ | ||
import { AsyncIterable, AsyncIterableIterator, AsyncQuerySource, Evaluator, GroupedAsyncIterableIterator, Operator, OrderKey } from "./interfaces"; | ||
import { AsyncIterable, AsyncQueryable, AsyncQuerySource, Evaluator, GroupedAsyncIterable, Operator, OrderKey } from "./interfaces"; | ||
export declare function filter<TSource>(f: (t: TSource, i: number) => boolean | Promise<boolean>): Operator<TSource, TSource>; | ||
export declare function flatMap<TSource, TInner, TResult = TInner>(selector: (t: TSource, index: number) => AsyncQuerySource<TInner>, resultSelector?: (t: TSource, ti: TInner) => TResult | Promise<TResult>): Operator<TSource, TResult>; | ||
export declare function flatMap<TSource, TInner, TResult = TInner>(selector: (t: TSource, index: number) => AsyncQuerySource<TInner> | Promise<AsyncQuerySource<TInner>>, resultSelector?: (t: TSource, ti: TInner) => TResult | Promise<TResult>): Operator<TSource, TResult>; | ||
export declare function map<TSource, TResult>(f: (t: TSource, i: number) => TResult | Promise<TResult>): Operator<TSource, TResult>; | ||
@@ -9,4 +9,4 @@ export declare function skip<TSource>(n: number): Operator<TSource, TSource>; | ||
export declare function takeWhile<TSource>(predicate: (t: TSource, i: number) => boolean | Promise<boolean>): Operator<TSource, TSource>; | ||
export declare function join<TOuter, TInner, TKey, TResult>(inner: AsyncIterableIterator<TInner>, outerKeySelector: (to: TOuter) => TKey | Promise<TKey>, innerKeySelector: (ti: TInner) => TKey | Promise<TKey>, resultSelector: (to: TOuter, ti: TInner) => TResult | Promise<TResult>): Operator<TOuter, TResult>; | ||
export declare function groupJoin<TOuter, TInner, TKey, TResult>(inner: AsyncIterableIterator<TInner>, outerKeySelector: (to: TOuter) => TKey | Promise<TKey>, innerKeySelector: (ti: TInner) => TKey | Promise<TKey>, resultSelector: (to: TOuter, ti: AsyncQuerySource<TInner>) => TResult | Promise<TResult>): Operator<TOuter, TResult>; | ||
export declare function join<TOuter, TInner, TKey, TResult>(inner: AsyncIterable<TInner>, outerKeySelector: (to: TOuter) => TKey | Promise<TKey>, innerKeySelector: (ti: TInner) => TKey | Promise<TKey>, resultSelector: (to: TOuter, ti: TInner) => TResult | Promise<TResult>): Operator<TOuter, TResult>; | ||
export declare function groupJoin<TOuter, TInner, TKey, TResult>(inner: AsyncIterable<TInner>, outerKeySelector: (to: TOuter) => TKey | Promise<TKey>, innerKeySelector: (ti: TInner) => TKey | Promise<TKey>, resultSelector: (to: TOuter, ti: AsyncQueryable<TInner>) => TResult | Promise<TResult>): Operator<TOuter, TResult>; | ||
export declare function concat<TSource>(iter: AsyncIterable<TSource>): Operator<TSource, TSource>; | ||
@@ -16,7 +16,7 @@ export declare function orderBy<TSource>(keySelector: (t: TSource) => OrderKey | Promise<OrderKey>): Operator<TSource, TSource>; | ||
export declare function reverse<TSource>(): Operator<TSource, TSource>; | ||
export declare function groupBy<TSource, TKey, TResult = TSource>(keySelector: (t: TSource) => TKey | Promise<TKey>, elementSelector?: (t: TSource) => TResult | Promise<TResult>): (source: AsyncIterableIterator<TSource>) => AsyncIterableIterator<GroupedAsyncIterableIterator<TKey, TResult>>; | ||
export declare function groupBy<TSource, TKey, TResult = TSource>(keySelector: (t: TSource) => TKey | Promise<TKey>, elementSelector?: (t: TSource) => TResult | Promise<TResult>): (source: AsyncIterable<TSource>) => AsyncIterable<GroupedAsyncIterable<TKey, TResult>>; | ||
export declare function distinct<TSource>(): Operator<TSource, TSource>; | ||
export declare function union<TSource>(second: AsyncIterableIterator<TSource>): Operator<TSource, TSource>; | ||
export declare function intersect<TSource>(second: AsyncIterableIterator<TSource>): Operator<TSource, TSource>; | ||
export declare function except<TSource>(second: AsyncIterableIterator<TSource>): Operator<TSource, TSource>; | ||
export declare function union<TSource>(second: AsyncIterable<TSource>): Operator<TSource, TSource>; | ||
export declare function intersect<TSource>(second: AsyncIterable<TSource>): Operator<TSource, TSource>; | ||
export declare function except<TSource>(second: AsyncIterable<TSource>): Operator<TSource, TSource>; | ||
export declare function toArray<TSource>(): Evaluator<TSource, TSource[]>; | ||
@@ -47,2 +47,2 @@ export declare function toMap<TKey, TSource, TResult = TSource>(keySelector: (t: TSource) => TKey | Promise<TKey>, elementSelector?: (t: TSource) => TResult | Promise<TResult>): Evaluator<TSource, Map<TKey, TResult>>; | ||
export declare function aggregate<TSource, TAccumulate>(seed: TAccumulate, func: (acc: TAccumulate, t: TSource) => TAccumulate | Promise<TAccumulate>): Evaluator<TSource, TAccumulate>; | ||
export declare function zip<TSource1, TSource2, TResult = [TSource1, TSource2]>(source1: AsyncIterableIterator<TSource1>, source2: AsyncIterableIterator<TSource2>, resultSelector?: (t1: TSource1, t2: TSource2) => TResult | Promise<TResult>): AsyncIterableIterator<TResult>; | ||
export declare function zip<TSource1, TSource2, TResult = [TSource1, TSource2]>(source1: AsyncIterable<TSource1>, source2: AsyncIterable<TSource2>, resultSelector?: (t1: TSource1, t2: TSource2) => TResult | Promise<TResult>): AsyncIterable<TResult>; |
340
operators.js
@@ -45,2 +45,3 @@ "use strict"; | ||
const util_1 = require("util"); | ||
const asyncQueryable_1 = require("./asyncQueryable"); | ||
const base_1 = require("./base"); | ||
@@ -52,3 +53,3 @@ const sources_1 = require("./sources"); | ||
function filter(f) { | ||
return function (source) { | ||
return (source) => sources_1.from(function () { | ||
return __asyncGenerator(this, arguments, function* () { | ||
@@ -72,3 +73,3 @@ var e_1, _a; | ||
}); | ||
}; | ||
}); | ||
} | ||
@@ -80,3 +81,3 @@ exports.filter = filter; | ||
function flatMap(selector, resultSelector = (t, ti) => ti) { | ||
return function (source) { | ||
return source => sources_1.from(function () { | ||
return __asyncGenerator(this, arguments, function* () { | ||
@@ -89,3 +90,3 @@ var e_2, _a, e_3, _b; | ||
try { | ||
for (var _e = __asyncValues(sources_1.from(us)), _f; _f = yield __await(_e.next()), !_f.done;) { | ||
for (var _e = __asyncValues(sources_1.from(yield __await(us))), _f; _f = yield __await(_e.next()), !_f.done;) { | ||
const u = _f.value; | ||
@@ -112,7 +113,7 @@ yield yield __await(yield __await(resultSelector(t, u))); | ||
}); | ||
}; | ||
}); | ||
} | ||
exports.flatMap = flatMap; | ||
function map(f) { | ||
return function (source) { | ||
return source => sources_1.from(function () { | ||
return __asyncGenerator(this, arguments, function* () { | ||
@@ -134,3 +135,3 @@ var e_4, _a; | ||
}); | ||
}; | ||
}); | ||
} | ||
@@ -145,3 +146,3 @@ exports.map = map; | ||
} | ||
return function (source) { | ||
return source => sources_1.from(function () { | ||
return __asyncGenerator(this, arguments, function* () { | ||
@@ -165,7 +166,7 @@ var e_5, _a; | ||
}); | ||
}; | ||
}); | ||
} | ||
exports.skip = skip; | ||
function skipWhile(predicate) { | ||
return function (source) { | ||
return source => sources_1.from(function () { | ||
return __asyncGenerator(this, arguments, function* () { | ||
@@ -194,3 +195,3 @@ var e_6, _a; | ||
}); | ||
}; | ||
}); | ||
} | ||
@@ -202,3 +203,3 @@ exports.skipWhile = skipWhile; | ||
} | ||
return function (source) { | ||
return source => sources_1.from(function () { | ||
return __asyncGenerator(this, arguments, function* () { | ||
@@ -223,7 +224,7 @@ var e_7, _a; | ||
}); | ||
}; | ||
}); | ||
} | ||
exports.take = take; | ||
function takeWhile(predicate) { | ||
return function (source) { | ||
return source => sources_1.from(function () { | ||
return __asyncGenerator(this, arguments, function* () { | ||
@@ -248,3 +249,3 @@ var e_8, _a; | ||
}); | ||
}; | ||
}); | ||
} | ||
@@ -302,3 +303,3 @@ exports.takeWhile = takeWhile; | ||
function join(inner, outerKeySelector, innerKeySelector, resultSelector) { | ||
return function (outer) { | ||
return outer => sources_1.from(function () { | ||
return __asyncGenerator(this, arguments, function* () { | ||
@@ -322,16 +323,65 @@ var e_11, _a; | ||
}); | ||
}; | ||
}); | ||
} | ||
exports.join = join; | ||
function groupJoinHelper(outer, inner, outerKeySelector, innerKeySelector) { | ||
return __asyncGenerator(this, arguments, function* groupJoinHelper_1() { | ||
var e_12, _a, e_13, _b; | ||
const inners = new Map(); | ||
try { | ||
for (var inner_2 = __asyncValues(inner), inner_2_1; inner_2_1 = yield __await(inner_2.next()), !inner_2_1.done;) { | ||
const t = inner_2_1.value; | ||
const key = yield __await(innerKeySelector(t)); | ||
const val = inners.get(key); | ||
if (inners.has(key)) { | ||
val.push(t); | ||
} | ||
else { | ||
inners.set(key, [t]); | ||
} | ||
} | ||
} | ||
catch (e_12_1) { e_12 = { error: e_12_1 }; } | ||
finally { | ||
try { | ||
if (inner_2_1 && !inner_2_1.done && (_a = inner_2.return)) yield __await(_a.call(inner_2)); | ||
} | ||
finally { if (e_12) throw e_12.error; } | ||
} | ||
try { | ||
for (var outer_2 = __asyncValues(outer), outer_2_1; outer_2_1 = yield __await(outer_2.next()), !outer_2_1.done;) { | ||
const t = outer_2_1.value; | ||
const key = yield __await(outerKeySelector(t)); | ||
if (key === undefined) { | ||
continue; | ||
} | ||
else if (inners.has(key)) { | ||
const innerValues = inners.get(key); | ||
yield yield __await([t, innerValues]); | ||
} | ||
else { | ||
yield yield __await([t, []]); | ||
} | ||
} | ||
} | ||
catch (e_13_1) { e_13 = { error: e_13_1 }; } | ||
finally { | ||
try { | ||
if (outer_2_1 && !outer_2_1.done && (_b = outer_2.return)) yield __await(_b.call(outer_2)); | ||
} | ||
finally { if (e_13) throw e_13.error; } | ||
} | ||
}); | ||
} | ||
function groupJoin(inner, outerKeySelector, innerKeySelector, resultSelector) { | ||
return function (outer) { | ||
return outer => sources_1.from(function () { | ||
return __asyncGenerator(this, arguments, function* () { | ||
var e_12, _a; | ||
var e_14, _a; | ||
try { | ||
for (var _b = __asyncValues(joinHelper(outer, inner, outerKeySelector, innerKeySelector)), _c; _c = yield __await(_b.next()), !_c.done;) { | ||
for (var _b = __asyncValues(groupJoinHelper(outer, inner, outerKeySelector, innerKeySelector)), _c; _c = yield __await(_b.next()), !_c.done;) { | ||
const [o, inners] = _c.value; | ||
yield yield __await(yield __await(resultSelector(o, sources_1.from(inners)))); | ||
yield yield __await(yield __await(resultSelector(o, asyncQueryable_1.AsyncQueryableImpl.from(inners)))); | ||
} | ||
} | ||
catch (e_12_1) { e_12 = { error: e_12_1 }; } | ||
catch (e_14_1) { e_14 = { error: e_14_1 }; } | ||
finally { | ||
@@ -341,6 +391,6 @@ try { | ||
} | ||
finally { if (e_12) throw e_12.error; } | ||
finally { if (e_14) throw e_14.error; } | ||
} | ||
}); | ||
}; | ||
}); | ||
} | ||
@@ -352,5 +402,5 @@ exports.groupJoin = groupJoin; | ||
function concat(iter) { | ||
return function (source) { | ||
return source => sources_1.from(function () { | ||
return __asyncGenerator(this, arguments, function* () { | ||
var e_13, _a, e_14, _b; | ||
var e_15, _a, e_16, _b; | ||
try { | ||
@@ -362,3 +412,3 @@ for (var source_1 = __asyncValues(source), source_1_1; source_1_1 = yield __await(source_1.next()), !source_1_1.done;) { | ||
} | ||
catch (e_13_1) { e_13 = { error: e_13_1 }; } | ||
catch (e_15_1) { e_15 = { error: e_15_1 }; } | ||
finally { | ||
@@ -368,3 +418,3 @@ try { | ||
} | ||
finally { if (e_13) throw e_13.error; } | ||
finally { if (e_15) throw e_15.error; } | ||
} | ||
@@ -377,3 +427,3 @@ try { | ||
} | ||
catch (e_14_1) { e_14 = { error: e_14_1 }; } | ||
catch (e_16_1) { e_16 = { error: e_16_1 }; } | ||
finally { | ||
@@ -383,6 +433,6 @@ try { | ||
} | ||
finally { if (e_14) throw e_14.error; } | ||
finally { if (e_16) throw e_16.error; } | ||
} | ||
}); | ||
}; | ||
}); | ||
} | ||
@@ -394,3 +444,3 @@ exports.concat = concat; | ||
function orderBy(keySelector) { | ||
return function (source) { | ||
return source => sources_1.from(function () { | ||
return __asyncGenerator(this, arguments, function* () { | ||
@@ -439,15 +489,15 @@ // | ||
}); | ||
}; | ||
}); | ||
} | ||
exports.orderBy = orderBy; | ||
function orderByDescending(keySelector) { | ||
return function (source) { | ||
return source => sources_1.from(function () { | ||
return reverse()(orderBy(keySelector)(source)); | ||
}; | ||
}); | ||
} | ||
exports.orderByDescending = orderByDescending; | ||
function reverse() { | ||
return function (source) { | ||
return source => sources_1.from(function () { | ||
return __asyncGenerator(this, arguments, function* () { | ||
var e_15, _a; | ||
var e_17, _a; | ||
const ts = []; | ||
@@ -460,3 +510,3 @@ try { | ||
} | ||
catch (e_15_1) { e_15 = { error: e_15_1 }; } | ||
catch (e_17_1) { e_17 = { error: e_17_1 }; } | ||
finally { | ||
@@ -466,3 +516,3 @@ try { | ||
} | ||
finally { if (e_15) throw e_15.error; } | ||
finally { if (e_17) throw e_17.error; } | ||
} | ||
@@ -473,3 +523,3 @@ for (const t of ts.reverse()) { | ||
}); | ||
}; | ||
}); | ||
} | ||
@@ -481,5 +531,5 @@ exports.reverse = reverse; | ||
function groupBy(keySelector, elementSelector) { | ||
return function (source) { | ||
return source => sources_1.from(function () { | ||
return __asyncGenerator(this, arguments, function* () { | ||
var e_16, _a; | ||
var e_18, _a; | ||
if (elementSelector === undefined) { | ||
@@ -503,3 +553,3 @@ elementSelector = t => t; | ||
} | ||
catch (e_16_1) { e_16 = { error: e_16_1 }; } | ||
catch (e_18_1) { e_18 = { error: e_18_1 }; } | ||
finally { | ||
@@ -509,9 +559,9 @@ try { | ||
} | ||
finally { if (e_16) throw e_16.error; } | ||
finally { if (e_18) throw e_18.error; } | ||
} | ||
for (const [key, group] of groups) { | ||
yield yield __await(new base_1.GroupedAsyncIterableIteratorImpl(key, sources_1.from(group))); | ||
yield yield __await(new base_1.GroupedAsyncIterableImpl(key, sources_1.from(() => group))); | ||
} | ||
}); | ||
}; | ||
}); | ||
} | ||
@@ -523,5 +573,5 @@ exports.groupBy = groupBy; | ||
function distinct() { | ||
return function (source) { | ||
return source => sources_1.from(function () { | ||
return __asyncGenerator(this, arguments, function* () { | ||
var e_17, _a; | ||
var e_19, _a; | ||
const dist = new Set(); | ||
@@ -537,3 +587,3 @@ try { | ||
} | ||
catch (e_17_1) { e_17 = { error: e_17_1 }; } | ||
catch (e_19_1) { e_19 = { error: e_19_1 }; } | ||
finally { | ||
@@ -543,12 +593,12 @@ try { | ||
} | ||
finally { if (e_17) throw e_17.error; } | ||
finally { if (e_19) throw e_19.error; } | ||
} | ||
}); | ||
}; | ||
}); | ||
} | ||
exports.distinct = distinct; | ||
function union(second) { | ||
return function (source) { | ||
return source => sources_1.from(function () { | ||
return __asyncGenerator(this, arguments, function* () { | ||
var e_18, _a, e_19, _b; | ||
var e_20, _a, e_21, _b; | ||
const dist = new Set(); | ||
@@ -564,3 +614,3 @@ try { | ||
} | ||
catch (e_18_1) { e_18 = { error: e_18_1 }; } | ||
catch (e_20_1) { e_20 = { error: e_20_1 }; } | ||
finally { | ||
@@ -570,3 +620,3 @@ try { | ||
} | ||
finally { if (e_18) throw e_18.error; } | ||
finally { if (e_20) throw e_20.error; } | ||
} | ||
@@ -582,3 +632,3 @@ try { | ||
} | ||
catch (e_19_1) { e_19 = { error: e_19_1 }; } | ||
catch (e_21_1) { e_21 = { error: e_21_1 }; } | ||
finally { | ||
@@ -588,12 +638,12 @@ try { | ||
} | ||
finally { if (e_19) throw e_19.error; } | ||
finally { if (e_21) throw e_21.error; } | ||
} | ||
}); | ||
}; | ||
}); | ||
} | ||
exports.union = union; | ||
function intersect(second) { | ||
return function (source) { | ||
return source => sources_1.from(function () { | ||
return __asyncGenerator(this, arguments, function* () { | ||
var e_20, _a, e_21, _b; | ||
var e_22, _a, e_23, _b; | ||
const dist = new Set(); | ||
@@ -606,3 +656,3 @@ try { | ||
} | ||
catch (e_20_1) { e_20 = { error: e_20_1 }; } | ||
catch (e_22_1) { e_22 = { error: e_22_1 }; } | ||
finally { | ||
@@ -612,3 +662,3 @@ try { | ||
} | ||
finally { if (e_20) throw e_20.error; } | ||
finally { if (e_22) throw e_22.error; } | ||
} | ||
@@ -625,3 +675,3 @@ const emitted = new Set(); | ||
} | ||
catch (e_21_1) { e_21 = { error: e_21_1 }; } | ||
catch (e_23_1) { e_23 = { error: e_23_1 }; } | ||
finally { | ||
@@ -631,12 +681,12 @@ try { | ||
} | ||
finally { if (e_21) throw e_21.error; } | ||
finally { if (e_23) throw e_23.error; } | ||
} | ||
}); | ||
}; | ||
}); | ||
} | ||
exports.intersect = intersect; | ||
function except(second) { | ||
return function (source) { | ||
return source => sources_1.from(function () { | ||
return __asyncGenerator(this, arguments, function* () { | ||
var e_22, _a, e_23, _b; | ||
var e_24, _a, e_25, _b; | ||
const dist = new Set(); | ||
@@ -649,3 +699,3 @@ try { | ||
} | ||
catch (e_22_1) { e_22 = { error: e_22_1 }; } | ||
catch (e_24_1) { e_24 = { error: e_24_1 }; } | ||
finally { | ||
@@ -655,3 +705,3 @@ try { | ||
} | ||
finally { if (e_22) throw e_22.error; } | ||
finally { if (e_24) throw e_24.error; } | ||
} | ||
@@ -669,3 +719,3 @@ try { | ||
} | ||
catch (e_23_1) { e_23 = { error: e_23_1 }; } | ||
catch (e_25_1) { e_25 = { error: e_25_1 }; } | ||
finally { | ||
@@ -675,3 +725,3 @@ try { | ||
} | ||
finally { if (e_23) throw e_23.error; } | ||
finally { if (e_25) throw e_25.error; } | ||
} | ||
@@ -682,3 +732,3 @@ for (const t of dist) { | ||
}); | ||
}; | ||
}); | ||
} | ||
@@ -692,3 +742,3 @@ exports.except = except; | ||
var source_8, source_8_1; | ||
var e_24, _a; | ||
var e_26, _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -702,3 +752,3 @@ const ret = []; | ||
} | ||
catch (e_24_1) { e_24 = { error: e_24_1 }; } | ||
catch (e_26_1) { e_26 = { error: e_26_1 }; } | ||
finally { | ||
@@ -708,3 +758,3 @@ try { | ||
} | ||
finally { if (e_24) throw e_24.error; } | ||
finally { if (e_26) throw e_26.error; } | ||
} | ||
@@ -719,3 +769,3 @@ return ret; | ||
var source_9, source_9_1; | ||
var e_25, _a; | ||
var e_27, _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -737,3 +787,3 @@ if (elementSelector === undefined) { | ||
} | ||
catch (e_25_1) { e_25 = { error: e_25_1 }; } | ||
catch (e_27_1) { e_27 = { error: e_27_1 }; } | ||
finally { | ||
@@ -743,3 +793,3 @@ try { | ||
} | ||
finally { if (e_25) throw e_25.error; } | ||
finally { if (e_27) throw e_27.error; } | ||
} | ||
@@ -752,5 +802,5 @@ return ret; | ||
function ofType(typeGuard) { | ||
return function (source) { | ||
return source => sources_1.from(function () { | ||
return __asyncGenerator(this, arguments, function* () { | ||
var e_26, _a; | ||
var e_28, _a; | ||
try { | ||
@@ -764,3 +814,3 @@ for (var source_10 = __asyncValues(source), source_10_1; source_10_1 = yield __await(source_10.next()), !source_10_1.done;) { | ||
} | ||
catch (e_26_1) { e_26 = { error: e_26_1 }; } | ||
catch (e_28_1) { e_28 = { error: e_28_1 }; } | ||
finally { | ||
@@ -770,6 +820,6 @@ try { | ||
} | ||
finally { if (e_26) throw e_26.error; } | ||
finally { if (e_28) throw e_28.error; } | ||
} | ||
}); | ||
}; | ||
}); | ||
} | ||
@@ -783,3 +833,3 @@ exports.ofType = ofType; | ||
var source_11, source_11_1; | ||
var e_27, _a; | ||
var e_29, _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -797,3 +847,3 @@ if (predicate === undefined) { | ||
} | ||
catch (e_27_1) { e_27 = { error: e_27_1 }; } | ||
catch (e_29_1) { e_29 = { error: e_29_1 }; } | ||
finally { | ||
@@ -803,3 +853,3 @@ try { | ||
} | ||
finally { if (e_27) throw e_27.error; } | ||
finally { if (e_29) throw e_29.error; } | ||
} | ||
@@ -814,3 +864,3 @@ return Promise.reject("first could not find any elements that match predicate"); | ||
var source_12, source_12_1; | ||
var e_28, _a; | ||
var e_30, _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -828,3 +878,3 @@ if (predicate === undefined) { | ||
} | ||
catch (e_28_1) { e_28 = { error: e_28_1 }; } | ||
catch (e_30_1) { e_30 = { error: e_30_1 }; } | ||
finally { | ||
@@ -834,3 +884,3 @@ try { | ||
} | ||
finally { if (e_28) throw e_28.error; } | ||
finally { if (e_30) throw e_30.error; } | ||
} | ||
@@ -845,3 +895,3 @@ return defaultValue; | ||
var source_13, source_13_1; | ||
var e_29, _a; | ||
var e_31, _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -860,3 +910,3 @@ if (predicate === undefined) { | ||
} | ||
catch (e_29_1) { e_29 = { error: e_29_1 }; } | ||
catch (e_31_1) { e_31 = { error: e_31_1 }; } | ||
finally { | ||
@@ -866,3 +916,3 @@ try { | ||
} | ||
finally { if (e_29) throw e_29.error; } | ||
finally { if (e_31) throw e_31.error; } | ||
} | ||
@@ -882,3 +932,3 @@ if (curr === undefined) { | ||
var source_14, source_14_1; | ||
var e_30, _a; | ||
var e_32, _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -897,3 +947,3 @@ if (predicate === undefined) { | ||
} | ||
catch (e_30_1) { e_30 = { error: e_30_1 }; } | ||
catch (e_32_1) { e_32 = { error: e_32_1 }; } | ||
finally { | ||
@@ -903,3 +953,3 @@ try { | ||
} | ||
finally { if (e_30) throw e_30.error; } | ||
finally { if (e_32) throw e_32.error; } | ||
} | ||
@@ -956,3 +1006,3 @@ if (curr === undefined) { | ||
return function (source) { | ||
var e_31, _a; | ||
var e_33, _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -969,3 +1019,3 @@ try { | ||
} | ||
catch (e_31_1) { e_31 = { error: e_31_1 }; } | ||
catch (e_33_1) { e_33 = { error: e_33_1 }; } | ||
finally { | ||
@@ -975,3 +1025,3 @@ try { | ||
} | ||
finally { if (e_31) throw e_31.error; } | ||
finally { if (e_33) throw e_33.error; } | ||
} | ||
@@ -985,3 +1035,3 @@ throw Error(`elementAt tried to find item at index ${index}, but sequence had fewer elements`); | ||
return function (source) { | ||
var e_32, _a; | ||
var e_34, _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -998,3 +1048,3 @@ try { | ||
} | ||
catch (e_32_1) { e_32 = { error: e_32_1 }; } | ||
catch (e_34_1) { e_34 = { error: e_34_1 }; } | ||
finally { | ||
@@ -1004,3 +1054,3 @@ try { | ||
} | ||
finally { if (e_32) throw e_32.error; } | ||
finally { if (e_34) throw e_34.error; } | ||
} | ||
@@ -1013,5 +1063,5 @@ return defaultValue; | ||
function defaultIfEmpty(defaultValue) { | ||
return function (source) { | ||
return source => sources_1.from(function () { | ||
return __asyncGenerator(this, arguments, function* () { | ||
var e_33, _a; | ||
var e_35, _a; | ||
let sequenceEmpty = true; | ||
@@ -1025,3 +1075,3 @@ try { | ||
} | ||
catch (e_33_1) { e_33 = { error: e_33_1 }; } | ||
catch (e_35_1) { e_35 = { error: e_35_1 }; } | ||
finally { | ||
@@ -1031,3 +1081,3 @@ try { | ||
} | ||
finally { if (e_33) throw e_33.error; } | ||
finally { if (e_35) throw e_35.error; } | ||
} | ||
@@ -1038,3 +1088,3 @@ if (sequenceEmpty) { | ||
}); | ||
}; | ||
}); | ||
} | ||
@@ -1048,3 +1098,3 @@ exports.defaultIfEmpty = defaultIfEmpty; | ||
var source_16, source_16_1; | ||
var e_34, _a; | ||
var e_36, _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -1062,3 +1112,3 @@ if (predicate === undefined) { | ||
} | ||
catch (e_34_1) { e_34 = { error: e_34_1 }; } | ||
catch (e_36_1) { e_36 = { error: e_36_1 }; } | ||
finally { | ||
@@ -1068,3 +1118,3 @@ try { | ||
} | ||
finally { if (e_34) throw e_34.error; } | ||
finally { if (e_36) throw e_36.error; } | ||
} | ||
@@ -1079,3 +1129,3 @@ return false; | ||
var source_17, source_17_1; | ||
var e_35, _a; | ||
var e_37, _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -1090,3 +1140,3 @@ try { | ||
} | ||
catch (e_35_1) { e_35 = { error: e_35_1 }; } | ||
catch (e_37_1) { e_37 = { error: e_37_1 }; } | ||
finally { | ||
@@ -1096,3 +1146,3 @@ try { | ||
} | ||
finally { if (e_35) throw e_35.error; } | ||
finally { if (e_37) throw e_37.error; } | ||
} | ||
@@ -1107,3 +1157,3 @@ return true; | ||
var source_18, source_18_1; | ||
var e_36, _a; | ||
var e_38, _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -1119,3 +1169,3 @@ const dist = new Set([value]); | ||
} | ||
catch (e_36_1) { e_36 = { error: e_36_1 }; } | ||
catch (e_38_1) { e_38 = { error: e_38_1 }; } | ||
finally { | ||
@@ -1125,3 +1175,3 @@ try { | ||
} | ||
finally { if (e_36) throw e_36.error; } | ||
finally { if (e_38) throw e_38.error; } | ||
} | ||
@@ -1139,3 +1189,3 @@ return false; | ||
var source_19, source_19_1; | ||
var e_37, _a; | ||
var e_39, _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -1154,3 +1204,3 @@ if (predicate === undefined) { | ||
} | ||
catch (e_37_1) { e_37 = { error: e_37_1 }; } | ||
catch (e_39_1) { e_39 = { error: e_39_1 }; } | ||
finally { | ||
@@ -1160,3 +1210,3 @@ try { | ||
} | ||
finally { if (e_37) throw e_37.error; } | ||
finally { if (e_39) throw e_39.error; } | ||
} | ||
@@ -1171,3 +1221,3 @@ return n; | ||
var source_20, source_20_1; | ||
var e_38, _a; | ||
var e_40, _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -1189,3 +1239,3 @@ // If selector is undefined, the source should emit `number`. | ||
} | ||
catch (e_38_1) { e_38 = { error: e_38_1 }; } | ||
catch (e_40_1) { e_40 = { error: e_40_1 }; } | ||
finally { | ||
@@ -1195,3 +1245,3 @@ try { | ||
} | ||
finally { if (e_38) throw e_38.error; } | ||
finally { if (e_40) throw e_40.error; } | ||
} | ||
@@ -1206,3 +1256,3 @@ return total; | ||
var source_21, source_21_1; | ||
var e_39, _a; | ||
var e_41, _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -1229,3 +1279,3 @@ // If selector is undefined, the source should emit `number`. | ||
} | ||
catch (e_39_1) { e_39 = { error: e_39_1 }; } | ||
catch (e_41_1) { e_41 = { error: e_41_1 }; } | ||
finally { | ||
@@ -1235,3 +1285,3 @@ try { | ||
} | ||
finally { if (e_39) throw e_39.error; } | ||
finally { if (e_41) throw e_41.error; } | ||
} | ||
@@ -1249,3 +1299,3 @@ if (minimum === undefined) { | ||
var source_22, source_22_1; | ||
var e_40, _a; | ||
var e_42, _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -1272,3 +1322,3 @@ // If selector is undefined, the source should emit `number`. | ||
} | ||
catch (e_40_1) { e_40 = { error: e_40_1 }; } | ||
catch (e_42_1) { e_42 = { error: e_42_1 }; } | ||
finally { | ||
@@ -1278,3 +1328,3 @@ try { | ||
} | ||
finally { if (e_40) throw e_40.error; } | ||
finally { if (e_42) throw e_42.error; } | ||
} | ||
@@ -1292,3 +1342,3 @@ if (maximum === undefined) { | ||
var source_23, source_23_1; | ||
var e_41, _a; | ||
var e_43, _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -1312,3 +1362,3 @@ // If selector is undefined, the source should emit `number`. | ||
} | ||
catch (e_41_1) { e_41 = { error: e_41_1 }; } | ||
catch (e_43_1) { e_43 = { error: e_43_1 }; } | ||
finally { | ||
@@ -1318,3 +1368,3 @@ try { | ||
} | ||
finally { if (e_41) throw e_41.error; } | ||
finally { if (e_43) throw e_43.error; } | ||
} | ||
@@ -1332,3 +1382,3 @@ if (cnt === 0) { | ||
var source_24, source_24_1; | ||
var e_42, _a; | ||
var e_44, _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -1342,3 +1392,3 @@ let acc = seed; | ||
} | ||
catch (e_42_1) { e_42 = { error: e_42_1 }; } | ||
catch (e_44_1) { e_44 = { error: e_44_1 }; } | ||
finally { | ||
@@ -1348,3 +1398,3 @@ try { | ||
} | ||
finally { if (e_42) throw e_42.error; } | ||
finally { if (e_44) throw e_44.error; } | ||
} | ||
@@ -1360,15 +1410,19 @@ return acc; | ||
function zip(source1, source2, resultSelector = (t1, t2) => [t1, t2]) { | ||
return __asyncGenerator(this, arguments, function* zip_1() { | ||
while (true) { | ||
const result1 = yield __await(source1.next()); | ||
const result2 = yield __await(source2.next()); | ||
if (result1.done || result2.done) { | ||
return yield __await(void 0); | ||
return sources_1.from(function () { | ||
return __asyncGenerator(this, arguments, function* () { | ||
const iterator1 = source1[Symbol.asyncIterator](); | ||
const iterator2 = source2[Symbol.asyncIterator](); | ||
while (true) { | ||
const result1 = yield __await(iterator1.next()); | ||
const result2 = yield __await(iterator2.next()); | ||
if (result1.done || result2.done) { | ||
return yield __await(void 0); | ||
} | ||
else { | ||
yield yield __await(yield __await(resultSelector(result1.value, result2.value))); | ||
} | ||
} | ||
else { | ||
yield yield __await(yield __await(resultSelector(result1.value, result2.value))); | ||
} | ||
} | ||
}); | ||
}); | ||
} | ||
exports.zip = zip; |
{ | ||
"name": "@pulumi/query", | ||
"version": "v0.3.1-dev.1571080995+g0d25f52", | ||
"version": "v0.3.1-dev.1571689690+g5952b72", | ||
"description": "An simple, relational SDK for querying TypeScript and JavaScript data structures", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -1,3 +0,3 @@ | ||
import { AsyncIterableIterator, AsyncQuerySource } from "./interfaces"; | ||
export declare function range(start: number, end?: number): AsyncIterableIterator<number>; | ||
export declare function from<TSource>(source: AsyncQuerySource<TSource>): AsyncIterableIterator<TSource>; | ||
import { AsyncQuerySource } from "./interfaces"; | ||
export declare function range(start: number, end?: number): AsyncIterable<number>; | ||
export declare function from<TSource>(source: AsyncQuerySource<TSource>): AsyncIterable<TSource>; |
@@ -15,2 +15,11 @@ "use strict"; | ||
// limitations under the License. | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } | ||
@@ -37,12 +46,33 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { | ||
const interfaces_1 = require("./interfaces"); | ||
const util_1 = require("./util"); | ||
function wrapAsyncIterable(makeIterable) { | ||
return { | ||
[Symbol.asyncIterator]() { | ||
const iterable = makeIterable(); | ||
if (interfaces_1.isIterable(iterable)) { | ||
const iterator = iterable[Symbol.iterator](); | ||
return { | ||
next() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return iterator.next(); | ||
}); | ||
}, | ||
}; | ||
} | ||
else { | ||
return iterable[Symbol.asyncIterator](); | ||
} | ||
}, | ||
}; | ||
} | ||
function range(start, end) { | ||
return __asyncGenerator(this, arguments, function* range_1() { | ||
let i = start; | ||
while (true) { | ||
if (end !== undefined && i >= end) { | ||
return yield __await(void 0); | ||
return wrapAsyncIterable(function () { | ||
return __asyncGenerator(this, arguments, function* () { | ||
let i = start; | ||
while (true) { | ||
if (end !== undefined && i >= end) { | ||
return yield __await(void 0); | ||
} | ||
yield yield __await(i++); | ||
} | ||
yield yield __await(i++); | ||
} | ||
}); | ||
}); | ||
@@ -52,33 +82,30 @@ } | ||
function from(source) { | ||
return __asyncGenerator(this, arguments, function* from_1() { | ||
var e_1, _a; | ||
let iter; | ||
if (util_1.isIterable(source) || interfaces_1.isAsyncIterable(source)) { | ||
iter = source; | ||
} | ||
else { | ||
iter = yield __await(source); | ||
} | ||
if (util_1.isIterable(iter)) { | ||
for (const t of iter) { | ||
yield yield __await(t); | ||
} | ||
} | ||
else { | ||
try { | ||
for (var iter_1 = __asyncValues(iter), iter_1_1; iter_1_1 = yield __await(iter_1.next()), !iter_1_1.done;) { | ||
const t = iter_1_1.value; | ||
yield yield __await(t); | ||
return source instanceof Function | ||
? wrapAsyncIterable(source) | ||
: wrapAsyncIterable(function () { | ||
return __asyncGenerator(this, arguments, function* () { | ||
var e_1, _a; | ||
if (interfaces_1.isIterable(source)) { | ||
for (const t of source) { | ||
yield yield __await(t); | ||
} | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (iter_1_1 && !iter_1_1.done && (_a = iter_1.return)) yield __await(_a.call(iter_1)); | ||
else { | ||
try { | ||
for (var source_1 = __asyncValues(source), source_1_1; source_1_1 = yield __await(source_1.next()), !source_1_1.done;) { | ||
const t = source_1_1.value; | ||
yield yield __await(t); | ||
} | ||
} | ||
catch (e_1_1) { e_1 = { error: e_1_1 }; } | ||
finally { | ||
try { | ||
if (source_1_1 && !source_1_1.done && (_a = source_1.return)) yield __await(_a.call(source_1)); | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
} | ||
finally { if (e_1) throw e_1.error; } | ||
} | ||
} | ||
}); | ||
}); | ||
}); | ||
} | ||
exports.from = from; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
192398
10.19%3675
5.66%18
-10%