@pulumi/query
Advanced tools
Comparing version
@@ -16,6 +16,7 @@ "use strict"; | ||
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -48,5 +49,2 @@ }); | ||
class AsyncQueryableImpl extends base_1.IterableBase { | ||
constructor(source) { | ||
super(source); | ||
} | ||
// | ||
@@ -58,2 +56,5 @@ // Constructors. | ||
} | ||
constructor(source) { | ||
super(source); | ||
} | ||
// | ||
@@ -60,0 +61,0 @@ // Restriction operators. |
declare global { | ||
interface SymbolConstructor { | ||
export interface SymbolConstructor { | ||
readonly asyncIterator: symbol; | ||
@@ -4,0 +4,0 @@ } |
@@ -16,6 +16,7 @@ "use strict"; | ||
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -22,0 +23,0 @@ }); |
{ | ||
"name": "@pulumi/query", | ||
"version": "v0.3.0", | ||
"version": "v0.3.1-dev.1571080995+g0d25f52", | ||
"description": "An simple, relational SDK for querying TypeScript and JavaScript data structures", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -16,6 +16,7 @@ "use strict"; | ||
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) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -62,3 +63,3 @@ }); | ||
// | ||
it("produces an empty array for overlapping ranges", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces an empty array for overlapping ranges", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield __1.range(0, 0).toArray(); | ||
@@ -69,11 +70,11 @@ assert.deepEqual(xs, []); | ||
})); | ||
it("produces an array of one for boundary case", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces an array of one for boundary case", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield __1.range(0, 1).toArray(); | ||
assert.deepEqual(xs, [0]); | ||
})); | ||
it("can produce a range including negative numbers", () => __awaiter(this, void 0, void 0, function* () { | ||
it("can produce a range including negative numbers", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield __1.range(-3, 2).toArray(); | ||
assert.deepEqual(xs, [-3, -2, -1, 0, 1]); | ||
})); | ||
it("is lazily evaluated by take when range is infinite", () => __awaiter(this, void 0, void 0, function* () { | ||
it("is lazily evaluated by take when range is infinite", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield __1.range(0) | ||
@@ -84,3 +85,3 @@ .take(5) | ||
})); | ||
it("is lazily transformed and filtered when range is infinite", () => __awaiter(this, void 0, void 0, function* () { | ||
it("is lazily transformed and filtered when range is infinite", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield __1.range(0) | ||
@@ -97,3 +98,3 @@ .map(x => x + 2) | ||
})); | ||
it("is lazily flatMap'd when range is infinite", () => __awaiter(this, void 0, void 0, function* () { | ||
it("is lazily flatMap'd when range is infinite", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield __1.range(0) | ||
@@ -111,3 +112,3 @@ // If filter is bigger than the take window, we enumerate all numbers and hang | ||
describe("filter", () => { | ||
it("produces [] when all elements are filtered out", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces [] when all elements are filtered out", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3, 4]) | ||
@@ -118,3 +119,3 @@ .filter(x => x < 0) | ||
})); | ||
it("produces an non-empty array when some elements are filtered out", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces an non-empty array when some elements are filtered out", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3, 4]) | ||
@@ -129,3 +130,3 @@ .filter(x => x >= 3) | ||
describe("map", () => { | ||
it("x => x does identity transformation", () => __awaiter(this, void 0, void 0, function* () { | ||
it("x => x does identity transformation", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3, 4]) | ||
@@ -136,3 +137,3 @@ .map(x => x) | ||
})); | ||
it("x => x+1 adds one to every element", () => __awaiter(this, void 0, void 0, function* () { | ||
it("x => x+1 adds one to every element", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3, 4]) | ||
@@ -145,3 +146,3 @@ .map(x => x + 1) | ||
describe("flatMap", () => { | ||
it("produces [] when all elements are filtered out", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces [] when all elements are filtered out", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3, 4]) | ||
@@ -152,3 +153,3 @@ .flatMap(x => []) | ||
})); | ||
it("can add elements to an enumerable", () => __awaiter(this, void 0, void 0, function* () { | ||
it("can add elements to an enumerable", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3, 4]) | ||
@@ -163,3 +164,3 @@ .flatMap(x => [x, x]) | ||
describe("skip", () => { | ||
it("produces [] when all elements are skipped", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces [] when all elements are skipped", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3, 4]) | ||
@@ -194,3 +195,3 @@ .skip(4) | ||
})); | ||
it("produces non-empty array when not all elements are skipped", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces non-empty array when not all elements are skipped", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3, 4, 5]) | ||
@@ -205,3 +206,3 @@ .skip(4) | ||
})); | ||
it("throws exception when negative number is provided for n, part 1", () => __awaiter(this, void 0, void 0, function* () { | ||
it("throws exception when negative number is provided for n, part 1", () => __awaiter(void 0, void 0, void 0, function* () { | ||
try { | ||
@@ -217,3 +218,3 @@ asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3, 4, 5]) | ||
})); | ||
it("throws exception when negative number is provided for n, part 2", () => __awaiter(this, void 0, void 0, function* () { | ||
it("throws exception when negative number is provided for n, part 2", () => __awaiter(void 0, void 0, void 0, function* () { | ||
try { | ||
@@ -230,3 +231,3 @@ asyncQueryable_1.AsyncQueryableImpl.from([]) | ||
describe("skipWhile", () => { | ||
it("produces [] when all elements are skipped", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces [] when all elements are skipped", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3, 4]) | ||
@@ -245,3 +246,3 @@ .skipWhile(x => true) | ||
})); | ||
it("produces non-empty array when not all elements are skipped", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces non-empty array when not all elements are skipped", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3, 4]) | ||
@@ -256,3 +257,3 @@ .skipWhile(x => x < 2) | ||
})); | ||
it("does not invoke the predicate again after it returns false one time", () => __awaiter(this, void 0, void 0, function* () { | ||
it("does not invoke the predicate again after it returns false one time", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3, 4, 5]) | ||
@@ -265,3 +266,3 @@ .skipWhile(x => x < 2 || x > 3) | ||
describe("take", () => { | ||
it("produces [] when no elements are taken", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces [] when no elements are taken", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3, 4]) | ||
@@ -280,3 +281,3 @@ .take(0) | ||
})); | ||
it("produces non-empty array when some elements are taken", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces non-empty array when some elements are taken", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3, 4, 5]) | ||
@@ -295,3 +296,3 @@ .take(4) | ||
})); | ||
it("throws exception when negative number is provided for n, part 1", () => __awaiter(this, void 0, void 0, function* () { | ||
it("throws exception when negative number is provided for n, part 1", () => __awaiter(void 0, void 0, void 0, function* () { | ||
try { | ||
@@ -307,3 +308,3 @@ yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3, 4, 5]) | ||
})); | ||
it("throws exception when negative number is provided for n, part 2", () => __awaiter(this, void 0, void 0, function* () { | ||
it("throws exception when negative number is provided for n, part 2", () => __awaiter(void 0, void 0, void 0, function* () { | ||
try { | ||
@@ -321,3 +322,3 @@ yield asyncQueryable_1.AsyncQueryableImpl.from([]) | ||
describe("takeWhile", () => { | ||
it("produces [] when no elements are taken", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces [] when no elements are taken", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3, 4]) | ||
@@ -336,3 +337,3 @@ .takeWhile(x => false) | ||
})); | ||
it("produces non-empty array when some elements are taken", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces non-empty array when some elements are taken", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3, 4]) | ||
@@ -347,3 +348,3 @@ .takeWhile(x => x <= 2) | ||
})); | ||
it("does not invoke the predicate again after it returns false one time", () => __awaiter(this, void 0, void 0, function* () { | ||
it("does not invoke the predicate again after it returns false one time", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3, 4, 5]) | ||
@@ -358,3 +359,3 @@ .takeWhile(x => x <= 2 || x > 4) | ||
describe("join", () => { | ||
it("produces [] when no elements are taken", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces [] when no elements are taken", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([]) | ||
@@ -369,3 +370,3 @@ .join([1, 2, 3], x => x, x => x, (x, y) => [x, y]) | ||
})); | ||
it("joins non-empty sets", () => __awaiter(this, void 0, void 0, function* () { | ||
it("joins non-empty sets", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3, 4, 5]) | ||
@@ -376,3 +377,3 @@ .join([1, 2, 3], x => x, x => x, (x, y) => [x, y]) | ||
})); | ||
it("ignores joins when key selector produces undefined", () => __awaiter(this, void 0, void 0, function* () { | ||
it("ignores joins when key selector produces undefined", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3, 4, 5]) | ||
@@ -395,3 +396,3 @@ .join([1, 2, 3], x => (x === 2 ? undefined : x), x => x, (x, y) => [x, y]) | ||
})); | ||
it("joins multiple inner records to one outer record", () => __awaiter(this, void 0, void 0, function* () { | ||
it("joins multiple inner records to one outer record", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 2, 3, 4, 5]) | ||
@@ -418,3 +419,3 @@ .join([1, 2], x => x, x => x, (x, y) => [x, y]) | ||
// | ||
it("concats T[]", () => __awaiter(this, void 0, void 0, function* () { | ||
it("concats T[]", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2]) | ||
@@ -433,3 +434,3 @@ .concat([3, 4]) | ||
})); | ||
it("concats Promise<T[]>", () => __awaiter(this, void 0, void 0, function* () { | ||
it("concats Promise<T[]>", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from(Promise.resolve([1, 2])) | ||
@@ -460,3 +461,3 @@ .concat([3, 4]) | ||
})); | ||
it("concats iterators", () => __awaiter(this, void 0, void 0, function* () { | ||
it("concats iterators", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from((function* () { | ||
@@ -515,3 +516,3 @@ for (const x of [1, 2]) { | ||
describe("reverse", () => { | ||
it("produces [] for empty array", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces [] for empty array", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([]) | ||
@@ -532,3 +533,3 @@ .reverse() | ||
describe("orderBy", () => { | ||
it("correctly sorts number keys", () => __awaiter(this, void 0, void 0, function* () { | ||
it("correctly sorts number keys", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([]) | ||
@@ -543,3 +544,3 @@ .orderBy(x => x) | ||
})); | ||
it("lexically sorts string keys", () => __awaiter(this, void 0, void 0, function* () { | ||
it("lexically sorts string keys", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield asyncQueryable_1.AsyncQueryableImpl.from([2, 3, 1, 14]) | ||
@@ -569,3 +570,3 @@ .orderBy(x => x.toString()) | ||
describe("groupBy", () => { | ||
it("produces [] for empty array", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces [] for empty array", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([]) | ||
@@ -584,3 +585,3 @@ .groupBy(x => x) | ||
})); | ||
it("produces non-empty groups when array is not empty", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces non-empty groups when array is not empty", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1]) | ||
@@ -643,3 +644,3 @@ .groupBy(x => x) | ||
})); | ||
it("produces projected elements when result selector is used", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces projected elements when result selector is used", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const ys = yield asyncQueryable_1.AsyncQueryableImpl.from([ | ||
@@ -660,3 +661,3 @@ { foo: "bar", bar: 1 }, | ||
describe("distinct", () => { | ||
it("produces [] for empty array", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces [] for empty array", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield asyncQueryable_1.AsyncQueryableImpl.from([]) | ||
@@ -667,3 +668,3 @@ .distinct() | ||
})); | ||
it("produces non-empty set when array is not empty", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces non-empty set when array is not empty", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3]) | ||
@@ -680,3 +681,3 @@ .distinct() | ||
describe("union", () => { | ||
it("produces [] for empty array", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces [] for empty array", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield asyncQueryable_1.AsyncQueryableImpl.from([]) | ||
@@ -687,3 +688,3 @@ .union([]) | ||
})); | ||
it("produces non-empty set when array is not empty", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces non-empty set when array is not empty", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3]) | ||
@@ -712,3 +713,3 @@ .union([]) | ||
describe("intersect", () => { | ||
it("produces [] when there is no set intersection", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces [] when there is no set intersection", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([]) | ||
@@ -731,3 +732,3 @@ .intersect([]) | ||
})); | ||
it("produces non-empty set when intersection is not empty", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces non-empty set when intersection is not empty", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3]) | ||
@@ -752,3 +753,3 @@ .intersect([1]) | ||
describe("except", () => { | ||
it("produces [] when there is no set difference", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces [] when there is no set difference", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([]) | ||
@@ -771,3 +772,3 @@ .except([]) | ||
})); | ||
it("produces non-empty set when set difference is not empty", () => __awaiter(this, void 0, void 0, function* () { | ||
it("produces non-empty set when set difference is not empty", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3]) | ||
@@ -796,3 +797,3 @@ .except([1]) | ||
}); | ||
it("finds first element of sequence", () => __awaiter(this, void 0, void 0, function* () { | ||
it("finds first element of sequence", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3]).first(); | ||
@@ -809,3 +810,3 @@ assert.deepEqual(xs, 1); | ||
describe("firstOrDefault", () => { | ||
it("default value populated if enumerable is empty", () => __awaiter(this, void 0, void 0, function* () { | ||
it("default value populated if enumerable is empty", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([]).firstOrDefault(99); | ||
@@ -820,3 +821,3 @@ assert.deepEqual(xs, 99); | ||
})); | ||
it("default value if predicate specifies non-existent element", () => __awaiter(this, void 0, void 0, function* () { | ||
it("default value if predicate specifies non-existent element", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3]).firstOrDefault(99, x => x === 4); | ||
@@ -831,3 +832,3 @@ assert.deepEqual(xs, 99); | ||
})); | ||
it("finds first element of sequence", () => __awaiter(this, void 0, void 0, function* () { | ||
it("finds first element of sequence", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3]).firstOrDefault(99); | ||
@@ -850,3 +851,3 @@ assert.deepEqual(xs, 1); | ||
}); | ||
it("finds last element of sequence", () => __awaiter(this, void 0, void 0, function* () { | ||
it("finds last element of sequence", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3]).last(); | ||
@@ -863,3 +864,3 @@ assert.deepEqual(xs, 3); | ||
describe("lastOrDefault", () => { | ||
it("default value populated if enumerable is empty", () => __awaiter(this, void 0, void 0, function* () { | ||
it("default value populated if enumerable is empty", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([]).lastOrDefault(99); | ||
@@ -874,3 +875,3 @@ assert.deepEqual(xs, 99); | ||
})); | ||
it("default value if predicate specifies non-existent element", () => __awaiter(this, void 0, void 0, function* () { | ||
it("default value if predicate specifies non-existent element", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3]).firstOrDefault(99, x => x === 4); | ||
@@ -885,3 +886,3 @@ assert.deepEqual(xs, 99); | ||
})); | ||
it("finds first element of sequence", () => __awaiter(this, void 0, void 0, function* () { | ||
it("finds first element of sequence", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3]).lastOrDefault(99); | ||
@@ -910,3 +911,3 @@ assert.deepEqual(xs, 3); | ||
}); | ||
it("finds single element of sequence", () => __awaiter(this, void 0, void 0, function* () { | ||
it("finds single element of sequence", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3]).single(x => x === 2); | ||
@@ -931,3 +932,3 @@ assert.deepEqual(xs, 2); | ||
describe("singleOrDefault", () => { | ||
it("default value if enumerable is empty", () => __awaiter(this, void 0, void 0, function* () { | ||
it("default value if enumerable is empty", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([]).singleOrDefault(99); | ||
@@ -945,3 +946,3 @@ assert.deepEqual(xs, 99); | ||
}); | ||
it("default value if predicate specifies non-existent element", () => __awaiter(this, void 0, void 0, function* () { | ||
it("default value if predicate specifies non-existent element", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3]).singleOrDefault(99, x => x === 4); | ||
@@ -959,3 +960,3 @@ assert.deepEqual(xs, 99); | ||
}); | ||
it("finds single element of sequence", () => __awaiter(this, void 0, void 0, function* () { | ||
it("finds single element of sequence", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3]).singleOrDefault(99, x => x === 2); | ||
@@ -980,3 +981,3 @@ assert.deepEqual(xs, 2); | ||
describe("elementAt", () => { | ||
it("finds element at in-range index", () => __awaiter(this, void 0, void 0, function* () { | ||
it("finds element at in-range index", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3]).elementAt(1); | ||
@@ -1003,7 +1004,7 @@ assert.deepEqual(xs, 2); | ||
describe("elementAtOrDefault", () => { | ||
it("finds element at in-range index", () => __awaiter(this, void 0, void 0, function* () { | ||
it("finds element at in-range index", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3]).elementAtOrDefault(99, 1); | ||
assert.deepEqual(xs, 2); | ||
})); | ||
it("default value if index is out-of-range", () => __awaiter(this, void 0, void 0, function* () { | ||
it("default value if index is out-of-range", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3]).elementAtOrDefault(99, 3); | ||
@@ -1018,3 +1019,3 @@ assert.deepEqual(xs, 99); | ||
describe("defaultIfEmpty", () => { | ||
it("default value if empty", () => __awaiter(this, void 0, void 0, function* () { | ||
it("default value if empty", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield asyncQueryable_1.AsyncQueryableImpl.from([]) | ||
@@ -1025,3 +1026,3 @@ .defaultIfEmpty(99) | ||
})); | ||
it("identity if not empty", () => __awaiter(this, void 0, void 0, function* () { | ||
it("identity if not empty", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3]) | ||
@@ -1036,3 +1037,3 @@ .defaultIfEmpty(99) | ||
describe("any", () => { | ||
it("false if nothing satisfies predicate", () => __awaiter(this, void 0, void 0, function* () { | ||
it("false if nothing satisfies predicate", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let res = yield asyncQueryable_1.AsyncQueryableImpl.from([]).any(x => x > 3); | ||
@@ -1043,3 +1044,3 @@ assert.deepEqual(res, false); | ||
})); | ||
it("true if >= 1 thing satisfies predicate", () => __awaiter(this, void 0, void 0, function* () { | ||
it("true if >= 1 thing satisfies predicate", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let res = yield asyncQueryable_1.AsyncQueryableImpl.from([4]).any(x => x > 3); | ||
@@ -1054,3 +1055,3 @@ assert.deepEqual(res, true); | ||
describe("all", () => { | ||
it("empty sequence satisfies predicate", () => __awaiter(this, void 0, void 0, function* () { | ||
it("empty sequence satisfies predicate", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let res = yield asyncQueryable_1.AsyncQueryableImpl.from([]).all(x => x > 3); | ||
@@ -1065,3 +1066,3 @@ assert.deepEqual(res, true); | ||
})); | ||
it("returns false when not everything satisfies predicate", () => __awaiter(this, void 0, void 0, function* () { | ||
it("returns false when not everything satisfies predicate", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let res = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3]).all(x => x > 2); | ||
@@ -1076,3 +1077,3 @@ assert.deepEqual(res, false); | ||
})); | ||
it("returns false when not everything satisfies predicate", () => __awaiter(this, void 0, void 0, function* () { | ||
it("returns false when not everything satisfies predicate", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let res = yield asyncQueryable_1.AsyncQueryableImpl.from([2, 3]).all(x => x >= 2); | ||
@@ -1089,3 +1090,3 @@ assert.deepEqual(res, true); | ||
describe("contains", () => { | ||
it("returns true if sequence contains value", () => __awaiter(this, void 0, void 0, function* () { | ||
it("returns true if sequence contains value", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let res = yield asyncQueryable_1.AsyncQueryableImpl.from([]).contains(3); | ||
@@ -1096,3 +1097,3 @@ assert.deepEqual(res, false); | ||
})); | ||
it("returns true if sequence contains value", () => __awaiter(this, void 0, void 0, function* () { | ||
it("returns true if sequence contains value", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let res = yield asyncQueryable_1.AsyncQueryableImpl.from([3]).contains(3); | ||
@@ -1107,3 +1108,3 @@ assert.deepEqual(res, true); | ||
describe("count", () => { | ||
it("returns 0 for empty lists", () => __awaiter(this, void 0, void 0, function* () { | ||
it("returns 0 for empty lists", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let res = yield asyncQueryable_1.AsyncQueryableImpl.from([]).count(); | ||
@@ -1118,3 +1119,3 @@ assert.deepEqual(res, 0); | ||
})); | ||
it("returns > 1 count for non-empty lists", () => __awaiter(this, void 0, void 0, function* () { | ||
it("returns > 1 count for non-empty lists", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let res = yield asyncQueryable_1.AsyncQueryableImpl.from([1]).count(); | ||
@@ -1127,7 +1128,7 @@ assert.deepEqual(res, 1); | ||
describe("sum", () => { | ||
it("returns 0 for empty array", () => __awaiter(this, void 0, void 0, function* () { | ||
it("returns 0 for empty array", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const res = yield asyncQueryable_1.AsyncQueryableImpl.from([]).sum(); | ||
assert.deepEqual(res, 0); | ||
})); | ||
it("correctly calculates the sum of array of numbers", () => __awaiter(this, void 0, void 0, function* () { | ||
it("correctly calculates the sum of array of numbers", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const res = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3, 4, 5]).sum(); | ||
@@ -1139,3 +1140,3 @@ assert.deepEqual(res, 15); | ||
}); | ||
it("correctly calculates the sum using key func", () => __awaiter(this, void 0, void 0, function* () { | ||
it("correctly calculates the sum using key func", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const res = yield asyncQueryable_1.AsyncQueryableImpl.from([{ foo: 1 }, { foo: 2 }, { foo: 3 }]).sum(x => x.foo); | ||
@@ -1149,3 +1150,3 @@ assert.deepEqual(res, 6); | ||
}); | ||
it("correctly finds min for array of numbers", () => __awaiter(this, void 0, void 0, function* () { | ||
it("correctly finds min for array of numbers", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let res = yield asyncQueryable_1.AsyncQueryableImpl.from([1]).min(); | ||
@@ -1159,3 +1160,3 @@ assert.deepEqual(res, 1); | ||
}); | ||
it("correctly calculates the min using key func", () => __awaiter(this, void 0, void 0, function* () { | ||
it("correctly calculates the min using key func", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const res = yield asyncQueryable_1.AsyncQueryableImpl.from([{ foo: 1 }, { foo: 2 }, { foo: 3 }]).min(x => x.foo); | ||
@@ -1169,3 +1170,3 @@ assert.deepEqual(res, 1); | ||
}); | ||
it("correctly finds max for array of numbers", () => __awaiter(this, void 0, void 0, function* () { | ||
it("correctly finds max for array of numbers", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let res = yield asyncQueryable_1.AsyncQueryableImpl.from([1]).max(); | ||
@@ -1179,3 +1180,3 @@ assert.deepEqual(res, 1); | ||
}); | ||
it("correctly calculates the max using key func", () => __awaiter(this, void 0, void 0, function* () { | ||
it("correctly calculates the max using key func", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const res = yield asyncQueryable_1.AsyncQueryableImpl.from([{ foo: 1 }, { foo: 2 }, { foo: 3 }]).max(x => x.foo); | ||
@@ -1189,3 +1190,3 @@ assert.deepEqual(res, 3); | ||
}); | ||
it("correctly finds average for array of numbers", () => __awaiter(this, void 0, void 0, function* () { | ||
it("correctly finds average for array of numbers", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let res = yield asyncQueryable_1.AsyncQueryableImpl.from([1]).average(); | ||
@@ -1199,3 +1200,3 @@ assert.deepEqual(res, 1); | ||
}); | ||
it("correctly calculates the average using key func", () => __awaiter(this, void 0, void 0, function* () { | ||
it("correctly calculates the average using key func", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const res = yield asyncQueryable_1.AsyncQueryableImpl.from([{ foo: 1 }, { foo: 2 }, { foo: 3 }]).average(x => x.foo); | ||
@@ -1206,7 +1207,7 @@ assert.deepEqual(res, 2); | ||
describe("aggregate", () => { | ||
it("throws for empty lists", () => __awaiter(this, void 0, void 0, function* () { | ||
it("throws for empty lists", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const res = yield asyncQueryable_1.AsyncQueryableImpl.from([]).aggregate(0, acc => acc + 13); | ||
assert.deepEqual(res, 0); | ||
})); | ||
it("aggregates (+) over array of numbers", () => __awaiter(this, void 0, void 0, function* () { | ||
it("aggregates (+) over array of numbers", () => __awaiter(void 0, void 0, void 0, function* () { | ||
let res = yield asyncQueryable_1.AsyncQueryableImpl.from([1]).aggregate(0, (acc, i) => acc + i); | ||
@@ -1223,3 +1224,3 @@ assert.deepEqual(res, 1); | ||
describe("toArray", () => { | ||
it("returns empty array for empty enumerable", () => __awaiter(this, void 0, void 0, function* () { | ||
it("returns empty array for empty enumerable", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield asyncQueryable_1.AsyncQueryableImpl.from([]).toArray(); | ||
@@ -1232,3 +1233,3 @@ assert.deepEqual(xs, []); | ||
describe("pipe", () => { | ||
it("allows composition of multiple async iterators", () => __awaiter(this, void 0, void 0, function* () { | ||
it("allows composition of multiple async iterators", () => __awaiter(void 0, void 0, void 0, function* () { | ||
const xs = yield asyncQueryable_1.AsyncQueryableImpl.from([1, 2, 3, 4]) | ||
@@ -1235,0 +1236,0 @@ .pipe(function (source) { |
Sorry, the diff of this file is not supported yet
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
174611
0.27%3478
0.09%