linqx 0.2.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +143 -3
- package/dist/core/dictionary.d.ts +15 -0
- package/dist/core/dictionary.d.ts.map +1 -0
- package/dist/core/enumerable.d.ts +10 -0
- package/dist/core/enumerable.d.ts.map +1 -0
- package/dist/core/enumerator.d.ts +11 -0
- package/dist/core/enumerator.d.ts.map +1 -0
- package/dist/core/grouping.d.ts +12 -0
- package/dist/core/grouping.d.ts.map +1 -0
- package/dist/core/lookup.d.ts +13 -0
- package/dist/core/lookup.d.ts.map +1 -0
- package/dist/core/memoized-enumerable.d.ts +13 -0
- package/dist/core/memoized-enumerable.d.ts.map +1 -0
- package/dist/core/ordered-enumerable.d.ts +15 -0
- package/dist/core/ordered-enumerable.d.ts.map +1 -0
- package/dist/core/shared-enumerable.d.ts +11 -0
- package/dist/core/shared-enumerable.d.ts.map +1 -0
- package/dist/extensions.d.ts +19 -0
- package/dist/extensions.d.ts.map +1 -0
- package/dist/extensions.js +13 -0
- package/dist/factories/choice.d.ts +9 -0
- package/dist/factories/choice.d.ts.map +1 -0
- package/dist/factories/cycle.d.ts +9 -0
- package/dist/factories/cycle.d.ts.map +1 -0
- package/dist/factories/defer.d.ts +9 -0
- package/dist/factories/defer.d.ts.map +1 -0
- package/dist/factories/empty.d.ts +4 -0
- package/dist/factories/empty.d.ts.map +1 -0
- package/dist/factories/from.d.ts +47 -0
- package/dist/factories/from.d.ts.map +1 -0
- package/dist/factories/generate.d.ts +10 -0
- package/dist/factories/generate.d.ts.map +1 -0
- package/dist/factories/make.d.ts +9 -0
- package/dist/factories/make.d.ts.map +1 -0
- package/dist/factories/matches.d.ts +15 -0
- package/dist/factories/matches.d.ts.map +1 -0
- package/dist/factories/range-down.d.ts +11 -0
- package/dist/factories/range-down.d.ts.map +1 -0
- package/dist/factories/range-to.d.ts +13 -0
- package/dist/factories/range-to.d.ts.map +1 -0
- package/dist/factories/range.d.ts +11 -0
- package/dist/factories/range.d.ts.map +1 -0
- package/dist/factories/repeat-with-finalize.d.ts +10 -0
- package/dist/factories/repeat-with-finalize.d.ts.map +1 -0
- package/dist/factories/repeat.d.ts +10 -0
- package/dist/factories/repeat.d.ts.map +1 -0
- package/dist/factories/to-infinity.d.ts +10 -0
- package/dist/factories/to-infinity.d.ts.map +1 -0
- package/dist/factories/to-negative-infinity.d.ts +10 -0
- package/dist/factories/to-negative-infinity.d.ts.map +1 -0
- package/dist/factories/unfold.d.ts +10 -0
- package/dist/factories/unfold.d.ts.map +1 -0
- package/dist/index.d.ts +88 -3
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -4
- package/dist/internal/create-enumerable.d.ts +4 -0
- package/dist/internal/create-enumerable.d.ts.map +1 -0
- package/dist/internal/functions.d.ts +7 -0
- package/dist/internal/functions.d.ts.map +1 -0
- package/dist/internal/to-iterable.d.ts +3 -0
- package/dist/internal/to-iterable.d.ts.map +1 -0
- package/dist/operators/aggregate-by.d.ts +3 -0
- package/dist/operators/aggregate-by.d.ts.map +1 -0
- package/dist/operators/aggregate.d.ts +3 -0
- package/dist/operators/aggregate.d.ts.map +1 -0
- package/dist/operators/all.d.ts +3 -0
- package/dist/operators/all.d.ts.map +1 -0
- package/dist/operators/alternate.d.ts +3 -0
- package/dist/operators/alternate.d.ts.map +1 -0
- package/dist/operators/any.d.ts +3 -0
- package/dist/operators/any.d.ts.map +1 -0
- package/dist/operators/append.d.ts +3 -0
- package/dist/operators/append.d.ts.map +1 -0
- package/dist/operators/as-enumerable.d.ts +3 -0
- package/dist/operators/as-enumerable.d.ts.map +1 -0
- package/dist/operators/average.d.ts +3 -0
- package/dist/operators/average.d.ts.map +1 -0
- package/dist/operators/buffer.d.ts +3 -0
- package/dist/operators/buffer.d.ts.map +1 -0
- package/dist/operators/cast.d.ts +3 -0
- package/dist/operators/cast.d.ts.map +1 -0
- package/dist/operators/catch-error.d.ts +3 -0
- package/dist/operators/catch-error.d.ts.map +1 -0
- package/dist/operators/choose.d.ts +3 -0
- package/dist/operators/choose.d.ts.map +1 -0
- package/dist/operators/chunk.d.ts +3 -0
- package/dist/operators/chunk.d.ts.map +1 -0
- package/dist/operators/concat.d.ts +3 -0
- package/dist/operators/concat.d.ts.map +1 -0
- package/dist/operators/contains.d.ts +3 -0
- package/dist/operators/contains.d.ts.map +1 -0
- package/dist/operators/count-by.d.ts +3 -0
- package/dist/operators/count-by.d.ts.map +1 -0
- package/dist/operators/count.d.ts +3 -0
- package/dist/operators/count.d.ts.map +1 -0
- package/dist/operators/create-ordered-enumerable.d.ts +3 -0
- package/dist/operators/create-ordered-enumerable.d.ts.map +1 -0
- package/dist/operators/default-if-empty.d.ts +3 -0
- package/dist/operators/default-if-empty.d.ts.map +1 -0
- package/dist/operators/distinct-by.d.ts +3 -0
- package/dist/operators/distinct-by.d.ts.map +1 -0
- package/dist/operators/distinct-until-changed.d.ts +3 -0
- package/dist/operators/distinct-until-changed.d.ts.map +1 -0
- package/dist/operators/distinct.d.ts +3 -0
- package/dist/operators/distinct.d.ts.map +1 -0
- package/dist/operators/do-action.d.ts +4 -0
- package/dist/operators/do-action.d.ts.map +1 -0
- package/dist/operators/element-at-or-default.d.ts +3 -0
- package/dist/operators/element-at-or-default.d.ts.map +1 -0
- package/dist/operators/element-at.d.ts +3 -0
- package/dist/operators/element-at.d.ts.map +1 -0
- package/dist/operators/except-by.d.ts +3 -0
- package/dist/operators/except-by.d.ts.map +1 -0
- package/dist/operators/except.d.ts +3 -0
- package/dist/operators/except.d.ts.map +1 -0
- package/dist/operators/finally-action.d.ts +3 -0
- package/dist/operators/finally-action.d.ts.map +1 -0
- package/dist/operators/first-or-default.d.ts +3 -0
- package/dist/operators/first-or-default.d.ts.map +1 -0
- package/dist/operators/first.d.ts +3 -0
- package/dist/operators/first.d.ts.map +1 -0
- package/dist/operators/flatten.d.ts +3 -0
- package/dist/operators/flatten.d.ts.map +1 -0
- package/dist/operators/for-each.d.ts +4 -0
- package/dist/operators/for-each.d.ts.map +1 -0
- package/dist/operators/force.d.ts +3 -0
- package/dist/operators/force.d.ts.map +1 -0
- package/dist/operators/group-by.d.ts +3 -0
- package/dist/operators/group-by.d.ts.map +1 -0
- package/dist/operators/group-join.d.ts +3 -0
- package/dist/operators/group-join.d.ts.map +1 -0
- package/dist/operators/index-of.d.ts +3 -0
- package/dist/operators/index-of.d.ts.map +1 -0
- package/dist/operators/index.d.ts +3 -0
- package/dist/operators/index.d.ts.map +1 -0
- package/dist/operators/insert.d.ts +3 -0
- package/dist/operators/insert.d.ts.map +1 -0
- package/dist/operators/intersect-by.d.ts +3 -0
- package/dist/operators/intersect-by.d.ts.map +1 -0
- package/dist/operators/intersect.d.ts +3 -0
- package/dist/operators/intersect.d.ts.map +1 -0
- package/dist/operators/is-empty.d.ts +3 -0
- package/dist/operators/is-empty.d.ts.map +1 -0
- package/dist/operators/join-with.d.ts +3 -0
- package/dist/operators/join-with.d.ts.map +1 -0
- package/dist/operators/join.d.ts +3 -0
- package/dist/operators/join.d.ts.map +1 -0
- package/dist/operators/last-index-of.d.ts +3 -0
- package/dist/operators/last-index-of.d.ts.map +1 -0
- package/dist/operators/last-or-default.d.ts +3 -0
- package/dist/operators/last-or-default.d.ts.map +1 -0
- package/dist/operators/last.d.ts +3 -0
- package/dist/operators/last.d.ts.map +1 -0
- package/dist/operators/left-join.d.ts +3 -0
- package/dist/operators/left-join.d.ts.map +1 -0
- package/dist/operators/let-bind.d.ts +3 -0
- package/dist/operators/let-bind.d.ts.map +1 -0
- package/dist/operators/log.d.ts +3 -0
- package/dist/operators/log.d.ts.map +1 -0
- package/dist/operators/map.d.ts +3 -0
- package/dist/operators/map.d.ts.map +1 -0
- package/dist/operators/max-by.d.ts +3 -0
- package/dist/operators/max-by.d.ts.map +1 -0
- package/dist/operators/max.d.ts +3 -0
- package/dist/operators/max.d.ts.map +1 -0
- package/dist/operators/memoize.d.ts +3 -0
- package/dist/operators/memoize.d.ts.map +1 -0
- package/dist/operators/merge.d.ts +3 -0
- package/dist/operators/merge.d.ts.map +1 -0
- package/dist/operators/min-by.d.ts +3 -0
- package/dist/operators/min-by.d.ts.map +1 -0
- package/dist/operators/min.d.ts +3 -0
- package/dist/operators/min.d.ts.map +1 -0
- package/dist/operators/of-type.d.ts +3 -0
- package/dist/operators/of-type.d.ts.map +1 -0
- package/dist/operators/operators.d.ts +209 -0
- package/dist/operators/operators.d.ts.map +1 -0
- package/dist/operators/order-by-descending.d.ts +3 -0
- package/dist/operators/order-by-descending.d.ts.map +1 -0
- package/dist/operators/order-by.d.ts +3 -0
- package/dist/operators/order-by.d.ts.map +1 -0
- package/dist/operators/page.d.ts +3 -0
- package/dist/operators/page.d.ts.map +1 -0
- package/dist/operators/pairwise.d.ts +3 -0
- package/dist/operators/pairwise.d.ts.map +1 -0
- package/dist/operators/partition-by.d.ts +3 -0
- package/dist/operators/partition-by.d.ts.map +1 -0
- package/dist/operators/position.d.ts +3 -0
- package/dist/operators/position.d.ts.map +1 -0
- package/dist/operators/prepend.d.ts +3 -0
- package/dist/operators/prepend.d.ts.map +1 -0
- package/dist/operators/reverse.d.ts +3 -0
- package/dist/operators/reverse.d.ts.map +1 -0
- package/dist/operators/right-join.d.ts +3 -0
- package/dist/operators/right-join.d.ts.map +1 -0
- package/dist/operators/scan.d.ts +3 -0
- package/dist/operators/scan.d.ts.map +1 -0
- package/dist/operators/select-many.d.ts +3 -0
- package/dist/operators/select-many.d.ts.map +1 -0
- package/dist/operators/select.d.ts +3 -0
- package/dist/operators/select.d.ts.map +1 -0
- package/dist/operators/sequence-equal.d.ts +3 -0
- package/dist/operators/sequence-equal.d.ts.map +1 -0
- package/dist/operators/share.d.ts +3 -0
- package/dist/operators/share.d.ts.map +1 -0
- package/dist/operators/shuffle.d.ts +3 -0
- package/dist/operators/shuffle.d.ts.map +1 -0
- package/dist/operators/single-or-default.d.ts +3 -0
- package/dist/operators/single-or-default.d.ts.map +1 -0
- package/dist/operators/single.d.ts +3 -0
- package/dist/operators/single.d.ts.map +1 -0
- package/dist/operators/skip-last.d.ts +3 -0
- package/dist/operators/skip-last.d.ts.map +1 -0
- package/dist/operators/skip-while.d.ts +3 -0
- package/dist/operators/skip-while.d.ts.map +1 -0
- package/dist/operators/skip.d.ts +3 -0
- package/dist/operators/skip.d.ts.map +1 -0
- package/dist/operators/sum.d.ts +3 -0
- package/dist/operators/sum.d.ts.map +1 -0
- package/dist/operators/take-except-last.d.ts +3 -0
- package/dist/operators/take-except-last.d.ts.map +1 -0
- package/dist/operators/take-from-last.d.ts +3 -0
- package/dist/operators/take-from-last.d.ts.map +1 -0
- package/dist/operators/take-last.d.ts +3 -0
- package/dist/operators/take-last.d.ts.map +1 -0
- package/dist/operators/take-while.d.ts +3 -0
- package/dist/operators/take-while.d.ts.map +1 -0
- package/dist/operators/take.d.ts +3 -0
- package/dist/operators/take.d.ts.map +1 -0
- package/dist/operators/then-by-descending.d.ts +3 -0
- package/dist/operators/then-by-descending.d.ts.map +1 -0
- package/dist/operators/then-by.d.ts +3 -0
- package/dist/operators/then-by.d.ts.map +1 -0
- package/dist/operators/to-array.d.ts +3 -0
- package/dist/operators/to-array.d.ts.map +1 -0
- package/dist/operators/to-dictionary.d.ts +3 -0
- package/dist/operators/to-dictionary.d.ts.map +1 -0
- package/dist/operators/to-joined-string.d.ts +3 -0
- package/dist/operators/to-joined-string.d.ts.map +1 -0
- package/dist/operators/to-json-string.d.ts +3 -0
- package/dist/operators/to-json-string.d.ts.map +1 -0
- package/dist/operators/to-lookup.d.ts +3 -0
- package/dist/operators/to-lookup.d.ts.map +1 -0
- package/dist/operators/to-map.d.ts +3 -0
- package/dist/operators/to-map.d.ts.map +1 -0
- package/dist/operators/to-object.d.ts +3 -0
- package/dist/operators/to-object.d.ts.map +1 -0
- package/dist/operators/to-set.d.ts +3 -0
- package/dist/operators/to-set.d.ts.map +1 -0
- package/dist/operators/trace.d.ts +3 -0
- package/dist/operators/trace.d.ts.map +1 -0
- package/dist/operators/traverse-breadth-first.d.ts +3 -0
- package/dist/operators/traverse-breadth-first.d.ts.map +1 -0
- package/dist/operators/traverse-depth-first.d.ts +3 -0
- package/dist/operators/traverse-depth-first.d.ts.map +1 -0
- package/dist/operators/union-by.d.ts +3 -0
- package/dist/operators/union-by.d.ts.map +1 -0
- package/dist/operators/union.d.ts +3 -0
- package/dist/operators/union.d.ts.map +1 -0
- package/dist/operators/weighted-sample.d.ts +3 -0
- package/dist/operators/weighted-sample.d.ts.map +1 -0
- package/dist/operators/where-if.d.ts +3 -0
- package/dist/operators/where-if.d.ts.map +1 -0
- package/dist/operators/where.d.ts +3 -0
- package/dist/operators/where.d.ts.map +1 -0
- package/dist/operators/with-neighbors.d.ts +3 -0
- package/dist/operators/with-neighbors.d.ts.map +1 -0
- package/dist/operators/zip.d.ts +3 -0
- package/dist/operators/zip.d.ts.map +1 -0
- package/dist/src-D_Mk3oMP.js +1597 -0
- package/dist/types.d.ts +1155 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +57 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +21 -11
- package/dist/linq.d.ts +0 -256
- package/dist/linq.js +0 -3085
- package/dist/linqx.d.ts +0 -36
- package/dist/linqx.js +0 -153
package/dist/linqx.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
declare module './linq.js' {
|
|
2
|
-
type IEnumerable<T> = Enumerable.IEnumerable<T>;
|
|
3
|
-
namespace Enumerable {
|
|
4
|
-
interface IPageInfo {
|
|
5
|
-
pageNumber: number;
|
|
6
|
-
pageSize: number;
|
|
7
|
-
}
|
|
8
|
-
interface IndexedItem<T> {
|
|
9
|
-
index: number;
|
|
10
|
-
item: T;
|
|
11
|
-
}
|
|
12
|
-
interface PositionedItem<T> extends IndexedItem<T> {
|
|
13
|
-
isFirst: boolean;
|
|
14
|
-
isLast: boolean;
|
|
15
|
-
}
|
|
16
|
-
interface ItemWithNeighbors<T> {
|
|
17
|
-
prev: T | null;
|
|
18
|
-
item: T;
|
|
19
|
-
next: T | null;
|
|
20
|
-
}
|
|
21
|
-
const prototype: any;
|
|
22
|
-
interface IEnumerable<T> {
|
|
23
|
-
whereIf(flag: boolean | string | undefined | null, filter: (t: T) => boolean): IEnumerable<T>;
|
|
24
|
-
page(pageNumber: number, pageSize: number): IEnumerable<T>;
|
|
25
|
-
page(info: IPageInfo): IEnumerable<T>;
|
|
26
|
-
joinWith(separator: string): string;
|
|
27
|
-
joinWith<T>(this: IEnumerable<T>, separator: (t: T) => T): IEnumerable<T>;
|
|
28
|
-
toMap<K, V>(keySelector: (element: T) => K, valueSelector: (element: T) => V): Map<K, V>;
|
|
29
|
-
chunk(size: number): IEnumerable<T[]>;
|
|
30
|
-
index(): IEnumerable<IndexedItem<T>>;
|
|
31
|
-
position(): IEnumerable<PositionedItem<T>>;
|
|
32
|
-
withNeighbors(): IEnumerable<ItemWithNeighbors<T>>;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
export {};
|
package/dist/linqx.js
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { Enumerable } from "./linq.js";
|
|
2
|
-
Enumerable.prototype.whereIf = function (flag, filter) {
|
|
3
|
-
return flag ? this.where(filter) : this;
|
|
4
|
-
};
|
|
5
|
-
function page(...args) {
|
|
6
|
-
let number = 0;
|
|
7
|
-
let size = 0;
|
|
8
|
-
if (args.length === 1) {
|
|
9
|
-
const info = args[0];
|
|
10
|
-
number = info.pageNumber;
|
|
11
|
-
size = info.pageSize;
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
number = args[0];
|
|
15
|
-
size = args[1];
|
|
16
|
-
}
|
|
17
|
-
return this.skip((number - 1) * size).take(size);
|
|
18
|
-
}
|
|
19
|
-
Enumerable.prototype.page = page;
|
|
20
|
-
Enumerable.prototype.map = function (selector) {
|
|
21
|
-
return this.select(selector).toArray();
|
|
22
|
-
};
|
|
23
|
-
function joinWith(separator) {
|
|
24
|
-
if (typeof separator === 'string') {
|
|
25
|
-
return this.toArray().join(separator);
|
|
26
|
-
}
|
|
27
|
-
return Enumerable.from(joinWithIterator(this, separator));
|
|
28
|
-
function* joinWithIterator(enumerable, sep) {
|
|
29
|
-
for (const { index, item, isFirst, isLast } of enumerable.position()) {
|
|
30
|
-
yield item;
|
|
31
|
-
if (!isLast) {
|
|
32
|
-
yield sep(item);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
Enumerable.prototype.joinWith = joinWith;
|
|
38
|
-
Enumerable.prototype.toMap = function (keySelector, valueSelector) {
|
|
39
|
-
const map = new Map();
|
|
40
|
-
for (const m of this) {
|
|
41
|
-
const k = keySelector(m);
|
|
42
|
-
const v = valueSelector(m);
|
|
43
|
-
map.set(k, v);
|
|
44
|
-
}
|
|
45
|
-
return map;
|
|
46
|
-
};
|
|
47
|
-
function* chunkIterator(enumerable, size) {
|
|
48
|
-
const e = enumerable.getEnumerator();
|
|
49
|
-
// Before allocating anything, make sure there's at least one element.
|
|
50
|
-
if (e.moveNext()) {
|
|
51
|
-
// Now that we know we have at least one item, allocate an initial storage array. This is not
|
|
52
|
-
// the array we'll yield. It starts out small in order to avoid significantly overallocating
|
|
53
|
-
// when the source has many fewer elements than the chunk size.
|
|
54
|
-
let arraySize = Math.min(size, 4);
|
|
55
|
-
let i;
|
|
56
|
-
do {
|
|
57
|
-
const array = new Array(arraySize);
|
|
58
|
-
// Store the first item.
|
|
59
|
-
array[0] = e.current();
|
|
60
|
-
i = 1;
|
|
61
|
-
if (size != array.length) {
|
|
62
|
-
// This is the first chunk. As we fill the array, grow it as needed.
|
|
63
|
-
for (; i < size && e.moveNext(); i++) {
|
|
64
|
-
if (i >= array.length) {
|
|
65
|
-
arraySize = Math.min(size, 2 * array.length);
|
|
66
|
-
resize(array, arraySize);
|
|
67
|
-
}
|
|
68
|
-
array[i] = e.current();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
// For all but the first chunk, the array will already be correctly sized.
|
|
73
|
-
// We can just store into it until either it's full or MoveNext returns false.
|
|
74
|
-
const local = array; // avoid bounds checks by using cached local (`array` is lifted to iterator object as a field)
|
|
75
|
-
for (; i < local.length && e.moveNext(); i++) {
|
|
76
|
-
local[i] = e.current();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (i != array.length) {
|
|
80
|
-
resize(array, i);
|
|
81
|
-
}
|
|
82
|
-
yield array;
|
|
83
|
-
} while (i >= size && e.moveNext());
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
Enumerable.prototype.chunk = function (size) {
|
|
87
|
-
if (size < 1)
|
|
88
|
-
throw new Error('size cannot be less than 1');
|
|
89
|
-
const e = chunkIterator(this, size);
|
|
90
|
-
return Enumerable.from(e);
|
|
91
|
-
};
|
|
92
|
-
function* positionIterator(enumerable) {
|
|
93
|
-
const e = enumerable.getEnumerator();
|
|
94
|
-
if (!e.moveNext()) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
let i = 0;
|
|
98
|
-
let current = e.current();
|
|
99
|
-
while (e.moveNext()) {
|
|
100
|
-
yield {
|
|
101
|
-
index: i,
|
|
102
|
-
item: current,
|
|
103
|
-
isFirst: i === 0,
|
|
104
|
-
isLast: false
|
|
105
|
-
};
|
|
106
|
-
current = e.current();
|
|
107
|
-
++i;
|
|
108
|
-
}
|
|
109
|
-
yield {
|
|
110
|
-
index: i,
|
|
111
|
-
item: current,
|
|
112
|
-
isFirst: i === 0,
|
|
113
|
-
isLast: true
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
Enumerable.prototype.position = function () {
|
|
117
|
-
const e = positionIterator(this);
|
|
118
|
-
return Enumerable.from(e);
|
|
119
|
-
};
|
|
120
|
-
Enumerable.prototype.index = function () {
|
|
121
|
-
const e = positionIterator(this);
|
|
122
|
-
return this.select((m, i) => ({ index: i, item: m }));
|
|
123
|
-
};
|
|
124
|
-
function* withNeighborsIterator(enumerable) {
|
|
125
|
-
const e = enumerable.getEnumerator();
|
|
126
|
-
if (!e.moveNext()) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
let previous = null;
|
|
130
|
-
let current = e.current();
|
|
131
|
-
while (e.moveNext()) {
|
|
132
|
-
const next = e.current();
|
|
133
|
-
yield { prev: previous, item: current, next: next };
|
|
134
|
-
previous = current;
|
|
135
|
-
current = next;
|
|
136
|
-
}
|
|
137
|
-
yield { prev: previous, item: current, next: null };
|
|
138
|
-
}
|
|
139
|
-
Enumerable.prototype.withNeighbors = function () {
|
|
140
|
-
const e = withNeighborsIterator(this);
|
|
141
|
-
return Enumerable.from(e);
|
|
142
|
-
};
|
|
143
|
-
function resize(array, newSize) {
|
|
144
|
-
const oldSize = array.length;
|
|
145
|
-
if (newSize > oldSize) {
|
|
146
|
-
array.length = newSize;
|
|
147
|
-
array.fill(undefined, oldSize, newSize);
|
|
148
|
-
}
|
|
149
|
-
else if (newSize < oldSize) {
|
|
150
|
-
array.length = newSize;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
;
|