@fluidframework/core-utils 2.43.0 → 2.50.0-345060

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/dist/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export { delay } from "./delay.js";
8
8
  export type { IComparer, IHeapNode } from "./heap.js";
9
9
  export { Heap, NumberComparer } from "./heap.js";
10
10
  export { Lazy, LazyPromise } from "./lazy.js";
11
+ export { DoublyLinkedList, type ListNode, type ListNodeRange, iterateListValuesWhile, walkList, } from "./list.js";
11
12
  export type { PromiseCacheExpiry, PromiseCacheOptions } from "./promiseCache.js";
12
13
  export { PromiseCache } from "./promiseCache.js";
13
14
  export { Deferred } from "./promises.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,MAAM,EACN,IAAI,EACJ,WAAW,EACX,qBAAqB,EACrB,iCAAiC,EACjC,kBAAkB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC9C,YAAY,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AA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CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@
4
4
  * Licensed under the MIT License.
5
5
  */
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.oob = exports.isPromiseLike = exports.isObject = exports.unreachableCase = exports.Timer = exports.setLongTimeout = exports.PromiseTimer = exports.shallowCloneObject = exports.Deferred = exports.PromiseCache = exports.LazyPromise = exports.Lazy = exports.NumberComparer = exports.Heap = exports.delay = exports.compareArrays = exports.onAssertionFailure = exports.nonProductionConditionalsIncluded = exports.configureDebugAsserts = exports.debugAssert = exports.fail = exports.assert = void 0;
7
+ exports.oob = exports.isPromiseLike = exports.isObject = exports.unreachableCase = exports.Timer = exports.setLongTimeout = exports.PromiseTimer = exports.shallowCloneObject = exports.Deferred = exports.PromiseCache = exports.walkList = exports.iterateListValuesWhile = exports.DoublyLinkedList = exports.LazyPromise = exports.Lazy = exports.NumberComparer = exports.Heap = exports.delay = exports.compareArrays = exports.onAssertionFailure = exports.nonProductionConditionalsIncluded = exports.configureDebugAsserts = exports.debugAssert = exports.fail = exports.assert = void 0;
8
8
  var assert_js_1 = require("./assert.js");
9
9
  Object.defineProperty(exports, "assert", { enumerable: true, get: function () { return assert_js_1.assert; } });
10
10
  Object.defineProperty(exports, "fail", { enumerable: true, get: function () { return assert_js_1.fail; } });
@@ -22,6 +22,10 @@ Object.defineProperty(exports, "NumberComparer", { enumerable: true, get: functi
22
22
  var lazy_js_1 = require("./lazy.js");
23
23
  Object.defineProperty(exports, "Lazy", { enumerable: true, get: function () { return lazy_js_1.Lazy; } });
24
24
  Object.defineProperty(exports, "LazyPromise", { enumerable: true, get: function () { return lazy_js_1.LazyPromise; } });
25
+ var list_js_1 = require("./list.js");
26
+ Object.defineProperty(exports, "DoublyLinkedList", { enumerable: true, get: function () { return list_js_1.DoublyLinkedList; } });
27
+ Object.defineProperty(exports, "iterateListValuesWhile", { enumerable: true, get: function () { return list_js_1.iterateListValuesWhile; } });
28
+ Object.defineProperty(exports, "walkList", { enumerable: true, get: function () { return list_js_1.walkList; } });
25
29
  var promiseCache_js_1 = require("./promiseCache.js");
26
30
  Object.defineProperty(exports, "PromiseCache", { enumerable: true, get: function () { return promiseCache_js_1.PromiseCache; } });
27
31
  var promises_js_1 = require("./promises.js");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAOqB;AANpB,mGAAA,MAAM,OAAA;AACN,iGAAA,IAAI,OAAA;AACJ,wGAAA,WAAW,OAAA;AACX,kHAAA,qBAAqB,OAAA;AACrB,8HAAA,iCAAiC,OAAA;AACjC,+GAAA,kBAAkB,OAAA;AAEnB,2CAA6C;AAApC,2GAAA,aAAa,OAAA;AACtB,uCAAmC;AAA1B,iGAAA,KAAK,OAAA;AAEd,qCAAiD;AAAxC,+FAAA,IAAI,OAAA;AAAE,yGAAA,cAAc,OAAA;AAC7B,qCAA8C;AAArC,+FAAA,IAAI,OAAA;AAAE,sGAAA,WAAW,OAAA;AAE1B,qDAAiD;AAAxC,+GAAA,YAAY,OAAA;AACrB,6CAAyC;AAAhC,uGAAA,QAAQ,OAAA;AACjB,qDAAuD;AAA9C,qHAAA,kBAAkB,OAAA;AAE3B,uCAAiE;AAAxD,wGAAA,YAAY,OAAA;AAAE,0GAAA,cAAc,OAAA;AAAE,iGAAA,KAAK,OAAA;AAC5C,mDAAmD;AAA1C,iHAAA,eAAe,OAAA;AACxB,mDAA2D;AAAlD,0GAAA,QAAQ,OAAA;AAAE,+GAAA,aAAa,OAAA;AAChC,mCAA+B;AAAtB,6FAAA,GAAG,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tassert,\n\tfail,\n\tdebugAssert,\n\tconfigureDebugAsserts,\n\tnonProductionConditionalsIncluded,\n\tonAssertionFailure,\n} from \"./assert.js\";\nexport { compareArrays } from \"./compare.js\";\nexport { delay } from \"./delay.js\";\nexport type { IComparer, IHeapNode } from \"./heap.js\";\nexport { Heap, NumberComparer } from \"./heap.js\";\nexport { Lazy, LazyPromise } from \"./lazy.js\";\nexport type { PromiseCacheExpiry, PromiseCacheOptions } from \"./promiseCache.js\";\nexport { PromiseCache } from \"./promiseCache.js\";\nexport { Deferred } from \"./promises.js\";\nexport { shallowCloneObject } from \"./shallowClone.js\";\nexport type { IPromiseTimer, IPromiseTimerResult, ITimer } from \"./timer.js\";\nexport { PromiseTimer, setLongTimeout, Timer } from \"./timer.js\";\nexport { unreachableCase } from \"./unreachable.js\";\nexport { isObject, isPromiseLike } from \"./typesGuards.js\";\nexport { oob } from \"./oob.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,yCAOqB;AANpB,mGAAA,MAAM,OAAA;AACN,iGAAA,IAAI,OAAA;AACJ,wGAAA,WAAW,OAAA;AACX,kHAAA,qBAAqB,OAAA;AACrB,8HAAA,iCAAiC,OAAA;AACjC,+GAAA,kBAAkB,OAAA;AAEnB,2CAA6C;AAApC,2GAAA,aAAa,OAAA;AACtB,uCAAmC;AAA1B,iGAAA,KAAK,OAAA;AAEd,qCAAiD;AAAxC,+FAAA,IAAI,OAAA;AAAE,yGAAA,cAAc,OAAA;AAC7B,qCAA8C;AAArC,+FAAA,IAAI,OAAA;AAAE,sGAAA,WAAW,OAAA;AAC1B,qCAMmB;AALlB,2GAAA,gBAAgB,OAAA;AAGhB,iHAAA,sBAAsB,OAAA;AACtB,mGAAA,QAAQ,OAAA;AAGT,qDAAiD;AAAxC,+GAAA,YAAY,OAAA;AACrB,6CAAyC;AAAhC,uGAAA,QAAQ,OAAA;AACjB,qDAAuD;AAA9C,qHAAA,kBAAkB,OAAA;AAE3B,uCAAiE;AAAxD,wGAAA,YAAY,OAAA;AAAE,0GAAA,cAAc,OAAA;AAAE,iGAAA,KAAK,OAAA;AAC5C,mDAAmD;AAA1C,iHAAA,eAAe,OAAA;AACxB,mDAA2D;AAAlD,0GAAA,QAAQ,OAAA;AAAE,+GAAA,aAAa,OAAA;AAChC,mCAA+B;AAAtB,6FAAA,GAAG,OAAA","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tassert,\n\tfail,\n\tdebugAssert,\n\tconfigureDebugAsserts,\n\tnonProductionConditionalsIncluded,\n\tonAssertionFailure,\n} from \"./assert.js\";\nexport { compareArrays } from \"./compare.js\";\nexport { delay } from \"./delay.js\";\nexport type { IComparer, IHeapNode } from \"./heap.js\";\nexport { Heap, NumberComparer } from \"./heap.js\";\nexport { Lazy, LazyPromise } from \"./lazy.js\";\nexport {\n\tDoublyLinkedList,\n\ttype ListNode,\n\ttype ListNodeRange,\n\titerateListValuesWhile,\n\twalkList,\n} from \"./list.js\";\nexport type { PromiseCacheExpiry, PromiseCacheOptions } from \"./promiseCache.js\";\nexport { PromiseCache } from \"./promiseCache.js\";\nexport { Deferred } from \"./promises.js\";\nexport { shallowCloneObject } from \"./shallowClone.js\";\nexport type { IPromiseTimer, IPromiseTimerResult, ITimer } from \"./timer.js\";\nexport { PromiseTimer, setLongTimeout, Timer } from \"./timer.js\";\nexport { unreachableCase } from \"./unreachable.js\";\nexport { isObject, isPromiseLike } from \"./typesGuards.js\";\nexport { oob } from \"./oob.js\";\n"]}
package/dist/list.d.ts ADDED
@@ -0,0 +1,163 @@
1
+ /*!
2
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
3
+ * Licensed under the MIT License.
4
+ */
5
+ /**
6
+ * Represents a node in a doubly linked list.
7
+ * @internal
8
+ */
9
+ export interface ListNode<T> {
10
+ /**
11
+ * The list this node belongs to, or undefined if not attached.
12
+ */
13
+ readonly list: DoublyLinkedList<T> | undefined;
14
+ /**
15
+ * The data value stored in this node.
16
+ */
17
+ readonly data: T;
18
+ /**
19
+ * The next node in the list, or undefined if this is the last node.
20
+ */
21
+ readonly next: ListNode<T> | undefined;
22
+ /**
23
+ * The previous node in the list, or undefined if this is the first node.
24
+ */
25
+ readonly prev: ListNode<T> | undefined;
26
+ /**
27
+ * Removes this node from its list.
28
+ * @returns The removed node, or undefined if not in a list.
29
+ */
30
+ remove(): ListNode<T> | undefined;
31
+ }
32
+ /**
33
+ * Represents a range of nodes in a doubly linked list.
34
+ * @internal
35
+ */
36
+ export interface ListNodeRange<T> {
37
+ /**
38
+ * The first node in the range.
39
+ */
40
+ first: ListNode<T>;
41
+ /**
42
+ * The last node in the range.
43
+ */
44
+ last: ListNode<T>;
45
+ }
46
+ /**
47
+ * A doubly linked list implementation with array-like methods and node access.
48
+ * @typeParam T - The type of data stored in the list nodes.
49
+ * @internal
50
+ */
51
+ export declare class DoublyLinkedList<T> implements Iterable<ListNode<T>>, // try to match array signature and semantics where possible
52
+ Pick<ListNode<T>[], "pop" | "shift" | "length" | "includes"> {
53
+ /**
54
+ * Creates a new doubly linked list optionally initialized with values.
55
+ * @param values - Optional iterable of values to populate the list.
56
+ */
57
+ constructor(values?: Iterable<T>);
58
+ /**
59
+ * Finds the first node matching the predicate.
60
+ * @param predicate - Function to test each node.
61
+ * @returns The first matching node, or undefined if none found.
62
+ */
63
+ find(predicate: (value: ListNode<T>, obj: DoublyLinkedList<T>) => boolean): ListNode<T> | undefined;
64
+ /**
65
+ * Returns an iterable that maps each node to a new value.
66
+ * @param callbackfn - Function to produce a new value for each node.
67
+ */
68
+ map<U>(callbackfn: (value: ListNode<T>) => U): Iterable<U>;
69
+ /**
70
+ * Inserts items after the specified node.
71
+ * @param preceding - The node to insert after.
72
+ * @param items - Items to insert.
73
+ * @returns The range of newly inserted nodes.
74
+ */
75
+ insertAfter(preceding: ListNode<T>, ...items: T[]): ListNodeRange<T>;
76
+ /**
77
+ * Removes and returns the last node in the list.
78
+ * @returns The removed node, or undefined if the list is empty.
79
+ */
80
+ pop(): ListNode<T> | undefined;
81
+ /**
82
+ * Appends items to the end of the list.
83
+ * @param items - Items to append.
84
+ * @returns The range of newly inserted nodes.
85
+ */
86
+ push(...items: T[]): ListNodeRange<T>;
87
+ /**
88
+ * Removes and returns the first node in the list.
89
+ * @returns The removed node, or undefined if the list is empty.
90
+ */
91
+ shift(): ListNode<T> | undefined;
92
+ /**
93
+ * Inserts items at the start of the list.
94
+ * @param items - Items to insert.
95
+ * @returns The range of newly inserted nodes.
96
+ */
97
+ unshift(...items: T[]): ListNodeRange<T>;
98
+ /**
99
+ * Removes nodes starting at `start` until `end` or `count` is reached.
100
+ * @param start - The node to start removing from.
101
+ * @param countOrEnd - The number of nodes to remove or the end node.
102
+ * @returns A new list containing the removed nodes.
103
+ */
104
+ splice(start: ListNode<T>, countOrEnd?: ListNode<T> | number): DoublyLinkedList<T>;
105
+ /**
106
+ * Checks if the node is in this list.
107
+ * @param node - The node to check.
108
+ * @returns True if the node is in the list.
109
+ */
110
+ includes(node: ListNode<T> | undefined): node is ListNode<T>;
111
+ private _includes;
112
+ private _remove;
113
+ /**
114
+ * Removes the specified node from the list.
115
+ * @param node - The node to remove.
116
+ * @returns The removed node, or undefined if not in the list.
117
+ */
118
+ remove(node: ListNode<T> | undefined): ListNode<T> | undefined;
119
+ [Symbol.iterator](): IterableIterator<ListNode<T>>;
120
+ private _len;
121
+ private readonly headNode;
122
+ /**
123
+ * The number of nodes in the list.
124
+ */
125
+ get length(): number;
126
+ /**
127
+ * Whether the list is empty.
128
+ */
129
+ get empty(): boolean;
130
+ /**
131
+ * The first node in the list, or undefined if empty.
132
+ */
133
+ get first(): ListNode<T> | undefined;
134
+ /**
135
+ * The last node in the list, or undefined if empty.
136
+ */
137
+ get last(): ListNode<T> | undefined;
138
+ }
139
+ /**
140
+ * Iterates over the nodes of a `DoublyLinkedList`, calling the provided visitor function for each node.
141
+ * Iteration starts at the specified node (or at the head/tail if not provided) and proceeds forward or backward.
142
+ * If the visitor returns `false`, iteration stops early.
143
+ *
144
+ * @typeParam T - The type of data stored in the list nodes.
145
+ * @param list - The list to walk.
146
+ * @param visitor - Function called for each node. If it returns `false`, iteration stops.
147
+ * @param start - Optional node to start iteration from. If not provided, starts at the first (or last if `forward` is false) node.
148
+ * @param forward - If `true` (default), iterates forward; if `false`, iterates backward.
149
+ * @returns `false` if iteration was stopped early by the visitor, otherwise `true`.
150
+ *
151
+ * @internal
152
+ */
153
+ export declare function walkList<T>(list: DoublyLinkedList<T>, visitor: (node: ListNode<T>) => boolean | void, start?: ListNode<T>, forward?: boolean): boolean;
154
+ /**
155
+ * Creates a lazily evaluated iterable which returns values while the predicate returns true,
156
+ * and stops iterating at the first value where the predicate is false.
157
+ * @param start - the node to start the iteration from
158
+ * @param includePredicate - determine if the current value be included in the iteration or stop if iteration
159
+ *
160
+ * @internal
161
+ */
162
+ export declare function iterateListValuesWhile<T>(start: ListNode<T> | undefined, includePredicate: (n: ListNode<T>) => boolean): Iterable<T>;
163
+ //# sourceMappingURL=list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../src/list.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;GAGG;AACH,MAAM,WAAW,QAAQ,CAAC,CAAC;IAC1B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IAC/C;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACjB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IACvC;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC;IACvC;;;OAGG;IACH,MAAM,IAAI,QAAQ,CAAC,CAAC,CAAC,GAAG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BT;AAED;;;;;;;GAOG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EACvC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,SAAS,EAC9B,gBAAgB,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,KAAK,OAAO,GAC3C,QAAQ,CAAC,CAAC,CAAC,CAkBb"}
package/dist/list.js ADDED
@@ -0,0 +1,332 @@
1
+ "use strict";
2
+ /*!
3
+ * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
4
+ * Licensed under the MIT License.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.iterateListValuesWhile = exports.walkList = exports.DoublyLinkedList = void 0;
8
+ class HeadNode {
9
+ constructor(list) {
10
+ this._next = this;
11
+ this._prev = this;
12
+ this.headNode = this;
13
+ if (list) {
14
+ this._list = list;
15
+ }
16
+ }
17
+ get next() {
18
+ return this._next === this.headNode ? undefined : this._next;
19
+ }
20
+ get prev() {
21
+ return this._prev === this.headNode ? undefined : this._prev;
22
+ }
23
+ get list() {
24
+ return this.headNode._list;
25
+ }
26
+ }
27
+ // The any is needed for use in the remove function, where the nodes are defined with a generic type.
28
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+ const DeadHead = new HeadNode(undefined);
30
+ class DataNode extends HeadNode {
31
+ constructor(headNode, data) {
32
+ super(undefined);
33
+ this.data = data;
34
+ this.headNode = headNode;
35
+ }
36
+ remove() {
37
+ return this.list?.remove(this);
38
+ }
39
+ }
40
+ function insertAfter(node, items) {
41
+ let previousNode = node;
42
+ const oldNext = previousNode._next;
43
+ let newRange;
44
+ for (const n of items) {
45
+ const newNode = new DataNode(node.headNode, n);
46
+ if (newRange === undefined) {
47
+ newRange = { first: newNode, last: newNode };
48
+ }
49
+ else {
50
+ newRange.last = newNode;
51
+ }
52
+ newNode._prev = previousNode;
53
+ previousNode._next = newNode;
54
+ previousNode = newNode;
55
+ }
56
+ oldNext._prev = previousNode;
57
+ previousNode._next = oldNext;
58
+ // explicitly prevent newRange from being undefined without casting,
59
+ // and without additional conditionals, as this is used in some perf critical areas.
60
+ // i could have just asserted, but that throws a non-user friendly error,
61
+ // so i went with a more user-friendly error, which describes the
62
+ // only condition that could lead to this being undefined in the current code.
63
+ if (newRange === undefined) {
64
+ throw new Error("items must not be empty");
65
+ }
66
+ return newRange;
67
+ }
68
+ /**
69
+ * A doubly linked list implementation with array-like methods and node access.
70
+ * @typeParam T - The type of data stored in the list nodes.
71
+ * @internal
72
+ */
73
+ class DoublyLinkedList {
74
+ /**
75
+ * Creates a new doubly linked list optionally initialized with values.
76
+ * @param values - Optional iterable of values to populate the list.
77
+ */
78
+ constructor(values) {
79
+ this._len = 0;
80
+ this.headNode = new HeadNode(this);
81
+ if (values !== undefined) {
82
+ this.push(...values);
83
+ }
84
+ }
85
+ /**
86
+ * Finds the first node matching the predicate.
87
+ * @param predicate - Function to test each node.
88
+ * @returns The first matching node, or undefined if none found.
89
+ */
90
+ find(predicate) {
91
+ let found;
92
+ walkList(this, (node) => {
93
+ if (predicate(node, this)) {
94
+ found = node;
95
+ return false;
96
+ }
97
+ });
98
+ return found;
99
+ }
100
+ /**
101
+ * Returns an iterable that maps each node to a new value.
102
+ * @param callbackfn - Function to produce a new value for each node.
103
+ */
104
+ map(callbackfn) {
105
+ let node = this.first;
106
+ const iterator = {
107
+ next() {
108
+ if (node === undefined) {
109
+ return { done: true, value: undefined };
110
+ }
111
+ const rtn = { value: callbackfn(node), done: false };
112
+ node = node.next;
113
+ return rtn;
114
+ },
115
+ [Symbol.iterator]() {
116
+ return this;
117
+ },
118
+ };
119
+ return iterator;
120
+ }
121
+ /**
122
+ * Inserts items after the specified node.
123
+ * @param preceding - The node to insert after.
124
+ * @param items - Items to insert.
125
+ * @returns The range of newly inserted nodes.
126
+ */
127
+ insertAfter(preceding, ...items) {
128
+ if (!this._includes(preceding)) {
129
+ throw new Error("preceding not in list");
130
+ }
131
+ this._len += items.length;
132
+ return insertAfter(preceding, items);
133
+ }
134
+ /**
135
+ * Removes and returns the last node in the list.
136
+ * @returns The removed node, or undefined if the list is empty.
137
+ */
138
+ pop() {
139
+ return this.remove(this.last);
140
+ }
141
+ /**
142
+ * Appends items to the end of the list.
143
+ * @param items - Items to append.
144
+ * @returns The range of newly inserted nodes.
145
+ */
146
+ push(...items) {
147
+ this._len += items.length;
148
+ const start = this.headNode._prev;
149
+ return insertAfter(start, items);
150
+ }
151
+ /**
152
+ * Removes and returns the first node in the list.
153
+ * @returns The removed node, or undefined if the list is empty.
154
+ */
155
+ shift() {
156
+ return this.remove(this.first);
157
+ }
158
+ /**
159
+ * Inserts items at the start of the list.
160
+ * @param items - Items to insert.
161
+ * @returns The range of newly inserted nodes.
162
+ */
163
+ unshift(...items) {
164
+ this._len += items.length;
165
+ return insertAfter(this.headNode, items);
166
+ }
167
+ /**
168
+ * Removes nodes starting at `start` until `end` or `count` is reached.
169
+ * @param start - The node to start removing from.
170
+ * @param countOrEnd - The number of nodes to remove or the end node.
171
+ * @returns A new list containing the removed nodes.
172
+ */
173
+ splice(start, countOrEnd) {
174
+ const newList = new DoublyLinkedList();
175
+ walkList(this, (node) => {
176
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
177
+ const removedNode = this._remove(node);
178
+ // whats special here is we preserve the node
179
+ // this allow looking up the old node in the new list
180
+ // when something preserves a reference
181
+ removedNode.headNode = newList.headNode;
182
+ removedNode._next = newList.headNode;
183
+ removedNode._prev = newList.headNode._prev;
184
+ newList.headNode._prev._next = removedNode;
185
+ newList.headNode._prev = removedNode;
186
+ newList._len++;
187
+ if (node === countOrEnd || newList.length === countOrEnd) {
188
+ return false;
189
+ }
190
+ }, start);
191
+ return newList;
192
+ }
193
+ /**
194
+ * Checks if the node is in this list.
195
+ * @param node - The node to check.
196
+ * @returns True if the node is in the list.
197
+ */
198
+ includes(node) {
199
+ return this._includes(node);
200
+ }
201
+ _includes(node) {
202
+ return node instanceof DataNode && node.headNode === this.headNode;
203
+ }
204
+ _remove(node) {
205
+ if (this._includes(node)) {
206
+ node._prev._next = node._next;
207
+ node._next._prev = node._prev;
208
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
209
+ node.headNode = node._next = node._prev = DeadHead;
210
+ this._len--;
211
+ return node;
212
+ }
213
+ return undefined;
214
+ }
215
+ /**
216
+ * Removes the specified node from the list.
217
+ * @param node - The node to remove.
218
+ * @returns The removed node, or undefined if not in the list.
219
+ */
220
+ remove(node) {
221
+ return this._remove(node);
222
+ }
223
+ [Symbol.iterator]() {
224
+ let value = this.first;
225
+ const iterator = {
226
+ next() {
227
+ if (value !== undefined) {
228
+ const rtn = { value, done: false };
229
+ value = value.next;
230
+ return rtn;
231
+ }
232
+ return { value: undefined, done: true };
233
+ },
234
+ [Symbol.iterator]() {
235
+ return this;
236
+ },
237
+ };
238
+ return iterator;
239
+ }
240
+ /**
241
+ * The number of nodes in the list.
242
+ */
243
+ get length() {
244
+ return this._len;
245
+ }
246
+ /**
247
+ * Whether the list is empty.
248
+ */
249
+ get empty() {
250
+ return this._len === 0;
251
+ }
252
+ /**
253
+ * The first node in the list, or undefined if empty.
254
+ */
255
+ get first() {
256
+ return this.headNode.next;
257
+ }
258
+ /**
259
+ * The last node in the list, or undefined if empty.
260
+ */
261
+ get last() {
262
+ return this.headNode.prev;
263
+ }
264
+ }
265
+ exports.DoublyLinkedList = DoublyLinkedList;
266
+ /**
267
+ * Iterates over the nodes of a `DoublyLinkedList`, calling the provided visitor function for each node.
268
+ * Iteration starts at the specified node (or at the head/tail if not provided) and proceeds forward or backward.
269
+ * If the visitor returns `false`, iteration stops early.
270
+ *
271
+ * @typeParam T - The type of data stored in the list nodes.
272
+ * @param list - The list to walk.
273
+ * @param visitor - Function called for each node. If it returns `false`, iteration stops.
274
+ * @param start - Optional node to start iteration from. If not provided, starts at the first (or last if `forward` is false) node.
275
+ * @param forward - If `true` (default), iterates forward; if `false`, iterates backward.
276
+ * @returns `false` if iteration was stopped early by the visitor, otherwise `true`.
277
+ *
278
+ * @internal
279
+ */
280
+ function walkList(list, visitor, start, forward = true) {
281
+ let current;
282
+ if (start) {
283
+ if (!list.includes(start)) {
284
+ throw new Error("start must be in the provided list");
285
+ }
286
+ current = start;
287
+ }
288
+ else {
289
+ current = forward ? list.first : list.last;
290
+ }
291
+ // cache the next node, incase the visitor mutates the list
292
+ // need this to support splice
293
+ let next = forward ? current?.next : current?.prev;
294
+ while (current !== undefined) {
295
+ if (visitor(current) === false) {
296
+ return false;
297
+ }
298
+ current = next;
299
+ next = forward ? next?.next : next?.prev;
300
+ }
301
+ return true;
302
+ }
303
+ exports.walkList = walkList;
304
+ /**
305
+ * Creates a lazily evaluated iterable which returns values while the predicate returns true,
306
+ * and stops iterating at the first value where the predicate is false.
307
+ * @param start - the node to start the iteration from
308
+ * @param includePredicate - determine if the current value be included in the iteration or stop if iteration
309
+ *
310
+ * @internal
311
+ */
312
+ function iterateListValuesWhile(start, includePredicate) {
313
+ let next = start;
314
+ const iterator = {
315
+ next: () => {
316
+ if (next !== undefined) {
317
+ const current = next;
318
+ next = current.next;
319
+ if (includePredicate(current) === true) {
320
+ return { value: current.data, done: false };
321
+ }
322
+ }
323
+ return { done: true, value: undefined };
324
+ },
325
+ [Symbol.iterator]() {
326
+ return this;
327
+ },
328
+ };
329
+ return iterator;
330
+ }
331
+ exports.iterateListValuesWhile = iterateListValuesWhile;
332
+ //# sourceMappingURL=list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"list.js","sourceRoot":"","sources":["../src/list.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA6CH,MAAM,QAAQ;IAKb,YAAmB,IAAqC;QAJjD,UAAK,GAA8B,IAAI,CAAC;QACxC,UAAK,GAA8B,IAAI,CAAC;QACxC,aAAQ,GAAgB,IAAI,CAAC;QAGnC,IAAI,IAAI,EAAE,CAAC;YACV,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QACnB,CAAC;IACF,CAAC;IACD,IAAW,IAAI;QACd,OAAO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AAI,CAAC;gBACpB,IAAI,gBAAgB,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;oBACxC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;gBAC7C,CAAC;YACF,CAAC;YACD,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;QACzC,CAAC;QACD,CAAC,MAAM,CAAC,QAAQ,CAAC;YAChB,OAAO,IAAI,CAAC;QACb,CAAC;KACD,CAAC;IACF,OAAO,QAAQ,CAAC;AACjB,CAAC;AArBD,wDAqBC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\n/**\n * Represents a node in a doubly linked list.\n * @internal\n */\nexport interface ListNode<T> {\n\t/**\n\t * The list this node belongs to, or undefined if not attached.\n\t */\n\treadonly list: DoublyLinkedList<T> | undefined;\n\t/**\n\t * The data value stored in this node.\n\t */\n\treadonly data: T;\n\t/**\n\t * The next node in the list, or undefined if this is the last node.\n\t */\n\treadonly next: ListNode<T> | undefined;\n\t/**\n\t * The previous node in the list, or undefined if this is the first node.\n\t */\n\treadonly prev: ListNode<T> | undefined;\n\t/**\n\t * Removes this node from its list.\n\t * @returns The removed node, or undefined if not in a list.\n\t */\n\tremove(): ListNode<T> | undefined;\n}\n\n/**\n * Represents a range of nodes in a doubly linked list.\n * @internal\n */\nexport interface ListNodeRange<T> {\n\t/**\n\t * The first node in the range.\n\t */\n\tfirst: ListNode<T>;\n\t/**\n\t * The last node in the range.\n\t */\n\tlast: ListNode<T>;\n}\n\nclass HeadNode<T> {\n\tpublic _next: HeadNode<T> | DataNode<T> = this;\n\tpublic _prev: HeadNode<T> | DataNode<T> = this;\n\tpublic headNode: HeadNode<T> = this;\n\tprivate readonly _list?: DoublyLinkedList<T>;\n\tpublic constructor(list: DoublyLinkedList<T> | undefined) {\n\t\tif (list) {\n\t\t\tthis._list = list;\n\t\t}\n\t}\n\tpublic get next(): DataNode<T> | undefined {\n\t\treturn this._next === this.headNode ? undefined : (this._next as DataNode<T>);\n\t}\n\tpublic get prev(): DataNode<T> | undefined {\n\t\treturn this._prev === this.headNode ? undefined : (this._prev as DataNode<T>);\n\t}\n\tpublic get list(): DoublyLinkedList<T> | undefined {\n\t\treturn this.headNode._list;\n\t}\n}\n\n// The any is needed for use in the remove function, where the nodes are defined with a generic type.\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst DeadHead = new HeadNode<any>(undefined);\n\nclass DataNode<T> extends HeadNode<T> implements ListNode<T> {\n\tpublic constructor(\n\t\theadNode: HeadNode<T>,\n\t\tpublic readonly data: T,\n\t) {\n\t\tsuper(undefined);\n\t\tthis.headNode = headNode;\n\t}\n\tpublic remove(): ListNode<T> | undefined {\n\t\treturn this.list?.remove(this);\n\t}\n}\n\nfunction insertAfter<T>(node: DataNode<T> | HeadNode<T>, items: T[]): ListNodeRange<T> {\n\tlet previousNode = node;\n\tconst oldNext = previousNode._next;\n\tlet newRange: ListNodeRange<T> | undefined;\n\tfor (const n of items) {\n\t\tconst newNode = new DataNode<T>(node.headNode, n);\n\t\tif (newRange === undefined) {\n\t\t\tnewRange = { first: newNode, last: newNode };\n\t\t} else {\n\t\t\tnewRange.last = newNode;\n\t\t}\n\t\tnewNode._prev = previousNode;\n\t\tpreviousNode._next = newNode;\n\t\tpreviousNode = newNode;\n\t}\n\toldNext._prev = previousNode;\n\tpreviousNode._next = oldNext;\n\t// explicitly prevent newRange from being undefined without casting,\n\t// and without additional conditionals, as this is used in some perf critical areas.\n\t// i could have just asserted, but that throws a non-user friendly error,\n\t// so i went with a more user-friendly error, which describes the\n\t// only condition that could lead to this being undefined in the current code.\n\tif (newRange === undefined) {\n\t\tthrow new Error(\"items must not be empty\");\n\t}\n\treturn newRange;\n}\n\n/**\n * A doubly linked list implementation with array-like methods and node access.\n * @typeParam T - The type of data stored in the list nodes.\n * @internal\n */\nexport class DoublyLinkedList<T>\n\timplements\n\t\tIterable<ListNode<T>>, // try to match array signature and semantics where possible\n\t\tPick<ListNode<T>[], \"pop\" | \"shift\" | \"length\" | \"includes\">\n{\n\t/**\n\t * Creates a new doubly linked list optionally initialized with values.\n\t * @param values - Optional iterable of values to populate the list.\n\t */\n\tpublic constructor(values?: Iterable<T>) {\n\t\tif (values !== undefined) {\n\t\t\tthis.push(...values);\n\t\t}\n\t}\n\t/**\n\t * Finds the first node matching the predicate.\n\t * @param predicate - Function to test each node.\n\t * @returns The first matching node, or undefined if none found.\n\t */\n\tpublic find(\n\t\tpredicate: (value: ListNode<T>, obj: DoublyLinkedList<T>) => boolean,\n\t): ListNode<T> | undefined {\n\t\tlet found: ListNode<T> | undefined;\n\t\twalkList(this, (node) => {\n\t\t\tif (predicate(node, this)) {\n\t\t\t\tfound = node;\n\t\t\t\treturn false;\n\t\t\t}\n\t\t});\n\t\treturn found;\n\t}\n\n\t/**\n\t * Returns an iterable that maps each node to a new value.\n\t * @param callbackfn - Function to produce a new value for each node.\n\t */\n\tpublic map<U>(callbackfn: (value: ListNode<T>) => U): Iterable<U> {\n\t\tlet node = this.first;\n\t\tconst iterator: IterableIterator<U> = {\n\t\t\tnext(): IteratorResult<U> {\n\t\t\t\tif (node === undefined) {\n\t\t\t\t\treturn { done: true, value: undefined };\n\t\t\t\t}\n\t\t\t\tconst rtn = { value: callbackfn(node), done: false };\n\t\t\t\tnode = node.next;\n\t\t\t\treturn rtn;\n\t\t\t},\n\t\t\t[Symbol.iterator]() {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\t/**\n\t * Inserts items after the specified node.\n\t * @param preceding - The node to insert after.\n\t * @param items - Items to insert.\n\t * @returns The range of newly inserted nodes.\n\t */\n\tpublic insertAfter(preceding: ListNode<T>, ...items: T[]): ListNodeRange<T> {\n\t\tif (!this._includes(preceding)) {\n\t\t\tthrow new Error(\"preceding not in list\");\n\t\t}\n\t\tthis._len += items.length;\n\t\treturn insertAfter(preceding, items);\n\t}\n\n\t/**\n\t * Removes and returns the last node in the list.\n\t * @returns The removed node, or undefined if the list is empty.\n\t */\n\tpublic pop(): ListNode<T> | undefined {\n\t\treturn this.remove(this.last);\n\t}\n\n\t/**\n\t * Appends items to the end of the list.\n\t * @param items - Items to append.\n\t * @returns The range of newly inserted nodes.\n\t */\n\tpublic push(...items: T[]): ListNodeRange<T> {\n\t\tthis._len += items.length;\n\t\tconst start = this.headNode._prev;\n\t\treturn insertAfter(start, items);\n\t}\n\n\t/**\n\t * Removes and returns the first node in the list.\n\t * @returns The removed node, or undefined if the list is empty.\n\t */\n\tpublic shift(): ListNode<T> | undefined {\n\t\treturn this.remove(this.first);\n\t}\n\n\t/**\n\t * Inserts items at the start of the list.\n\t * @param items - Items to insert.\n\t * @returns The range of newly inserted nodes.\n\t */\n\tpublic unshift(...items: T[]): ListNodeRange<T> {\n\t\tthis._len += items.length;\n\t\treturn insertAfter(this.headNode, items);\n\t}\n\n\t/**\n\t * Removes nodes starting at `start` until `end` or `count` is reached.\n\t * @param start - The node to start removing from.\n\t * @param countOrEnd - The number of nodes to remove or the end node.\n\t * @returns A new list containing the removed nodes.\n\t */\n\tpublic splice(start: ListNode<T>, countOrEnd?: ListNode<T> | number): DoublyLinkedList<T> {\n\t\tconst newList = new DoublyLinkedList<T>();\n\t\twalkList(\n\t\t\tthis,\n\t\t\t(node) => {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n\t\t\t\tconst removedNode = this._remove(node)!;\n\t\t\t\t// whats special here is we preserve the node\n\t\t\t\t// this allow looking up the old node in the new list\n\t\t\t\t// when something preserves a reference\n\t\t\t\tremovedNode.headNode = newList.headNode;\n\t\t\t\tremovedNode._next = newList.headNode;\n\t\t\t\tremovedNode._prev = newList.headNode._prev;\n\t\t\t\tnewList.headNode._prev._next = removedNode;\n\t\t\t\tnewList.headNode._prev = removedNode;\n\t\t\t\tnewList._len++;\n\t\t\t\tif (node === countOrEnd || newList.length === countOrEnd) {\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t},\n\t\t\tstart,\n\t\t);\n\t\treturn newList;\n\t}\n\n\t/**\n\t * Checks if the node is in this list.\n\t * @param node - The node to check.\n\t * @returns True if the node is in the list.\n\t */\n\tpublic includes(node: ListNode<T> | undefined): node is ListNode<T> {\n\t\treturn this._includes(node);\n\t}\n\n\tprivate _includes(node: ListNode<T> | undefined): node is DataNode<T> {\n\t\treturn node instanceof DataNode && node.headNode === this.headNode;\n\t}\n\n\tprivate _remove(node: ListNode<T> | undefined): DataNode<T> | undefined {\n\t\tif (this._includes(node)) {\n\t\t\tnode._prev._next = node._next;\n\t\t\tnode._next._prev = node._prev;\n\t\t\t// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n\t\t\tnode.headNode = node._next = node._prev = DeadHead;\n\t\t\tthis._len--;\n\t\t\treturn node;\n\t\t}\n\t\treturn undefined;\n\t}\n\n\t/**\n\t * Removes the specified node from the list.\n\t * @param node - The node to remove.\n\t * @returns The removed node, or undefined if not in the list.\n\t */\n\tpublic remove(node: ListNode<T> | undefined): ListNode<T> | undefined {\n\t\treturn this._remove(node);\n\t}\n\n\tpublic [Symbol.iterator](): IterableIterator<ListNode<T>> {\n\t\tlet value = this.first;\n\t\tconst iterator: IterableIterator<ListNode<T>> = {\n\t\t\tnext(): IteratorResult<ListNode<T>> {\n\t\t\t\tif (value !== undefined) {\n\t\t\t\t\tconst rtn = { value, done: false };\n\t\t\t\t\tvalue = value.next;\n\t\t\t\t\treturn rtn;\n\t\t\t\t}\n\t\t\t\treturn { value: undefined, done: true };\n\t\t\t},\n\t\t\t[Symbol.iterator]() {\n\t\t\t\treturn this;\n\t\t\t},\n\t\t};\n\t\treturn iterator;\n\t}\n\n\tprivate _len: number = 0;\n\tprivate readonly headNode: HeadNode<T> | DataNode<T> = new HeadNode(this);\n\n\t/**\n\t * The number of nodes in the list.\n\t */\n\tpublic get length(): number {\n\t\treturn this._len;\n\t}\n\n\t/**\n\t * Whether the list is empty.\n\t */\n\tpublic get empty(): boolean {\n\t\treturn this._len === 0;\n\t}\n\n\t/**\n\t * The first node in the list, or undefined if empty.\n\t */\n\tpublic get first(): ListNode<T> | undefined {\n\t\treturn this.headNode.next;\n\t}\n\n\t/**\n\t * The last node in the list, or undefined if empty.\n\t */\n\tpublic get last(): ListNode<T> | undefined {\n\t\treturn this.headNode.prev;\n\t}\n}\n\n/**\n * Iterates over the nodes of a `DoublyLinkedList`, calling the provided visitor function for each node.\n * Iteration starts at the specified node (or at the head/tail if not provided) and proceeds forward or backward.\n * If the visitor returns `false`, iteration stops early.\n *\n * @typeParam T - The type of data stored in the list nodes.\n * @param list - The list to walk.\n * @param visitor - Function called for each node. If it returns `false`, iteration stops.\n * @param start - Optional node to start iteration from. If not provided, starts at the first (or last if `forward` is false) node.\n * @param forward - If `true` (default), iterates forward; if `false`, iterates backward.\n * @returns `false` if iteration was stopped early by the visitor, otherwise `true`.\n *\n * @internal\n */\nexport function walkList<T>(\n\tlist: DoublyLinkedList<T>,\n\tvisitor: (node: ListNode<T>) => boolean | void,\n\tstart?: ListNode<T>,\n\tforward: boolean = true,\n): boolean {\n\tlet current: ListNode<T> | undefined;\n\tif (start) {\n\t\tif (!list.includes(start)) {\n\t\t\tthrow new Error(\"start must be in the provided list\");\n\t\t}\n\t\tcurrent = start;\n\t} else {\n\t\tcurrent = forward ? list.first : list.last;\n\t}\n\t// cache the next node, incase the visitor mutates the list\n\t// need this to support splice\n\tlet next = forward ? current?.next : current?.prev;\n\twhile (current !== undefined) {\n\t\tif (visitor(current) === false) {\n\t\t\treturn false;\n\t\t}\n\t\tcurrent = next;\n\t\tnext = forward ? next?.next : next?.prev;\n\t}\n\treturn true;\n}\n\n/**\n * Creates a lazily evaluated iterable which returns values while the predicate returns true,\n * and stops iterating at the first value where the predicate is false.\n * @param start - the node to start the iteration from\n * @param includePredicate - determine if the current value be included in the iteration or stop if iteration\n *\n * @internal\n */\nexport function iterateListValuesWhile<T>(\n\tstart: ListNode<T> | undefined,\n\tincludePredicate: (n: ListNode<T>) => boolean,\n): Iterable<T> {\n\tlet next: ListNode<T> | undefined = start;\n\tconst iterator: IterableIterator<T> = {\n\t\tnext: (): IteratorResult<T> => {\n\t\t\tif (next !== undefined) {\n\t\t\t\tconst current = next;\n\t\t\t\tnext = current.next;\n\t\t\t\tif (includePredicate(current) === true) {\n\t\t\t\t\treturn { value: current.data, done: false };\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn { done: true, value: undefined };\n\t\t},\n\t\t[Symbol.iterator]() {\n\t\t\treturn this;\n\t\t},\n\t};\n\treturn iterator;\n}\n"]}
package/lib/index.d.ts CHANGED
@@ -8,6 +8,7 @@ export { delay } from "./delay.js";
8
8
  export type { IComparer, IHeapNode } from "./heap.js";
9
9
  export { Heap, NumberComparer } from "./heap.js";
10
10
  export { Lazy, LazyPromise } from "./lazy.js";
11
+ export { DoublyLinkedList, type ListNode, type ListNodeRange, iterateListValuesWhile, walkList, } from "./list.js";
11
12
  export type { PromiseCacheExpiry, PromiseCacheOptions } from "./promiseCache.js";
12
13
  export { PromiseCache } from "./promiseCache.js";
13
14
  export { Deferred } from "./promises.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,MAAM,EACN,IAAI,EACJ,WAAW,EACX,qBAAqB,EACrB,iCAAiC,EACjC,kBAAkB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC9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ACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC"}
package/lib/index.js CHANGED
@@ -7,6 +7,7 @@ export { compareArrays } from "./compare.js";
7
7
  export { delay } from "./delay.js";
8
8
  export { Heap, NumberComparer } from "./heap.js";
9
9
  export { Lazy, LazyPromise } from "./lazy.js";
10
+ export { DoublyLinkedList, iterateListValuesWhile, walkList, } from "./list.js";
10
11
  export { PromiseCache } from "./promiseCache.js";
11
12
  export { Deferred } from "./promises.js";
12
13
  export { shallowCloneObject } from "./shallowClone.js";
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,MAAM,EACN,IAAI,EACJ,WAAW,EACX,qBAAqB,EACrB,iCAAiC,EACjC,kBAAkB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tassert,\n\tfail,\n\tdebugAssert,\n\tconfigureDebugAsserts,\n\tnonProductionConditionalsIncluded,\n\tonAssertionFailure,\n} from \"./assert.js\";\nexport { compareArrays } from \"./compare.js\";\nexport { delay } from \"./delay.js\";\nexport type { IComparer, IHeapNode } from \"./heap.js\";\nexport { Heap, NumberComparer } from \"./heap.js\";\nexport { Lazy, LazyPromise } from \"./lazy.js\";\nexport type { PromiseCacheExpiry, PromiseCacheOptions } from \"./promiseCache.js\";\nexport { PromiseCache } from \"./promiseCache.js\";\nexport { Deferred } from \"./promises.js\";\nexport { shallowCloneObject } from \"./shallowClone.js\";\nexport type { IPromiseTimer, IPromiseTimerResult, ITimer } from \"./timer.js\";\nexport { PromiseTimer, setLongTimeout, Timer } from \"./timer.js\";\nexport { unreachableCase } from \"./unreachable.js\";\nexport { isObject, isPromiseLike } from \"./typesGuards.js\";\nexport { oob } from \"./oob.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACN,MAAM,EACN,IAAI,EACJ,WAAW,EACX,qBAAqB,EACrB,iCAAiC,EACjC,kBAAkB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAEnC,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EACN,gBAAgB,EAGhB,sBAAsB,EACtB,QAAQ,GACR,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAEvD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC","sourcesContent":["/*!\n * Copyright (c) Microsoft Corporation and contributors. All rights reserved.\n * Licensed under the MIT License.\n */\n\nexport {\n\tassert,\n\tfail,\n\tdebugAssert,\n\tconfigureDebugAsserts,\n\tnonProductionConditionalsIncluded,\n\tonAssertionFailure,\n} from \"./assert.js\";\nexport { compareArrays } from \"./compare.js\";\nexport { delay } from \"./delay.js\";\nexport type { IComparer, IHeapNode } from \"./heap.js\";\nexport { Heap, NumberComparer } from \"./heap.js\";\nexport { Lazy, LazyPromise } from \"./lazy.js\";\nexport {\n\tDoublyLinkedList,\n\ttype ListNode,\n\ttype ListNodeRange,\n\titerateListValuesWhile,\n\twalkList,\n} from \"./list.js\";\nexport type { PromiseCacheExpiry, PromiseCacheOptions } from \"./promiseCache.js\";\nexport { PromiseCache } from \"./promiseCache.js\";\nexport { Deferred } from \"./promises.js\";\nexport { shallowCloneObject } from \"./shallowClone.js\";\nexport type { IPromiseTimer, IPromiseTimerResult, ITimer } from \"./timer.js\";\nexport { PromiseTimer, setLongTimeout, Timer } from \"./timer.js\";\nexport { unreachableCase } from \"./unreachable.js\";\nexport { isObject, isPromiseLike } from \"./typesGuards.js\";\nexport { oob } from \"./oob.js\";\n"]}