@mark1russell7/collections 0.7.0 → 0.7.2
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 +24 -4
- package/build/core/layers.js.map +1 -1
- package/build/dag/index.d.ts +9 -4
- package/build/dag/index.d.ts.map +1 -1
- package/build/dag/index.js +5 -3
- package/build/dag/index.js.map +1 -1
- package/build/index.d.ts +8 -8
- package/build/index.d.ts.map +1 -1
- package/build/index.js +26 -6
- package/build/index.js.map +1 -1
- package/build/layers.d.ts +3 -1
- package/build/layers.d.ts.map +1 -1
- package/package.json +2 -1
- package/src/behaviors/readonly.ts +24 -0
- package/src/core/layers.ts +3 -1
- package/src/dag/executor.ts +5 -3
- package/src/dag/types.ts +4 -1
- package/src/fx/iter.ts +6 -5
- package/src/interfaces/list.ts +4 -4
package/build/layers.d.ts
CHANGED
|
@@ -24,7 +24,9 @@ type InnerOf<L> = L extends ((next: infer I) => any) ? I : never;
|
|
|
24
24
|
type OuterOf<L> = L extends ((next: any) => infer O) ? O : never;
|
|
25
25
|
/**
|
|
26
26
|
* This type checks each neighbor pair of a list of layers. The result of the inner neighbor must
|
|
27
|
-
* fit the input of the outer neighbor.
|
|
27
|
+
* fit the input of the outer neighbor. A bad pair makes the compiler refuse the call. The compiler
|
|
28
|
+
* marks the first argument, not the bad pair. Its message shows the type that the first bad pair
|
|
29
|
+
* needs. At the place of the inner neighbor, it needs a layer that gives the input of the outer one.
|
|
28
30
|
*
|
|
29
31
|
* The type is tail recursive, so the compiler accepts a chain of 100 layers.
|
|
30
32
|
*/
|
package/build/layers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layers.d.ts","names":[],"sources":["../src/core/layers.ts"],"mappings":";;;;;;;;;;;;;;;;;;;KAoBY,MAAM,aAAa,QAAQ,UAAU,MAAM,UAAU;;KAGrD,QAAQ,KAAK,YAAW,YAAY,aAAY;;KAGhD,QAAQ,KAAK,YAAW,oBAAoB,KAAI
|
|
1
|
+
{"version":3,"file":"layers.d.ts","names":[],"sources":["../src/core/layers.ts"],"mappings":";;;;;;;;;;;;;;;;;;;KAoBY,MAAM,aAAa,QAAQ,UAAU,MAAM,UAAU;;KAGrD,QAAQ,KAAK,YAAW,YAAY,aAAY;;KAGhD,QAAQ,KAAK,YAAW,oBAAoB,KAAI;;;;;;;;;KAUhD,MAAM,8BAA8B,iDAC9C,0BAA0B,SAAS,YAAY,MAC1C,QAAQ,aAAa,QAAQ,MAC5B,gBAAgB,MAAM,iBAAiB,MAAM,mBAChC,MAAM,GAAG,WAAW,QAAQ,QAAQ,kBACtC,SAAS;;;;;;KAOhB,SAAS,gCACnB,yBACK,GAAG,MAAM,MAAM,IAChB,0BAA0B,uBACxB,wCAAwC,SACrC,MAAM,QAAQ,UAAU,QAAQ,iBAEnC,0BAA0B,QACvB,MAAM,QAAQ,OAAO,QAAQ;;KAI5B,OAAO,8BAA8B,iBAC/C,0BAA0B,gBAAgB,QAAQ,OAAO,MAAM,MAAM,QAAQ,UAAU;;;;;KAM7E,QAAQ,gCAClB,wCAAwC,SACnC,MAAM,QAAQ,UAAU,OAAO,KAAK,QAAQ,QAC7C,SAAS;;;;;;;;;;;;;iBAcC,cAAc,mBAAmB,YAAY,QAAQ,IAAI,MAAM,KAAK,SAAS"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/package",
|
|
3
3
|
"name": "@mark1russell7/collections",
|
|
4
|
-
"version": "0.7.
|
|
4
|
+
"version": "0.7.2",
|
|
5
5
|
"description": "Collections with no dependencies: lists, maps, queues, a summary tree, channels, lazy operations and dependency graphs.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"collections",
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
"@mark1russell7/rigor-bench": "^0.2.5",
|
|
72
72
|
"@mark1russell7/rigor-generators": "^0.1.5",
|
|
73
73
|
"@mark1russell7/rigor-statistics": "^0.1.8",
|
|
74
|
+
"@mark1russell7/rigor-testkit": "^0.1.0",
|
|
74
75
|
"@types/node": "^26.6.5",
|
|
75
76
|
"esbuild": "^0.28.2",
|
|
76
77
|
"fast-check": "^4.10.2",
|
|
@@ -84,6 +84,30 @@ const MUTATING_METHODS = new Set([
|
|
|
84
84
|
"compute",
|
|
85
85
|
"merge",
|
|
86
86
|
"putAll",
|
|
87
|
+
|
|
88
|
+
// Queue changes that give undefined on an empty queue (C27: a readonly view removed an element)
|
|
89
|
+
"pollOrUndefined",
|
|
90
|
+
|
|
91
|
+
// The internal changes of the structures of this package. TypeScript marks them private, but a call at run
|
|
92
|
+
// time reaches them. `readonly.test.ts` puts each method of each structure in the reads or in this list.
|
|
93
|
+
"ensureCapacity",
|
|
94
|
+
"trimToSize",
|
|
95
|
+
"grow",
|
|
96
|
+
"resize",
|
|
97
|
+
"removeAtOffset",
|
|
98
|
+
"unlinkNode",
|
|
99
|
+
"heapify",
|
|
100
|
+
"bubbleUp",
|
|
101
|
+
"bubbleDown",
|
|
102
|
+
"addToEnd",
|
|
103
|
+
"moveToEnd",
|
|
104
|
+
"removeFromBucket",
|
|
105
|
+
"removeFromList",
|
|
106
|
+
"deleteNode",
|
|
107
|
+
"fixAfterInsertion",
|
|
108
|
+
"fixAfterDeletion",
|
|
109
|
+
"rotateLeft",
|
|
110
|
+
"rotateRight",
|
|
87
111
|
]);
|
|
88
112
|
|
|
89
113
|
/** Methods that return a view of the collection: the view is readonly too. */
|
package/src/core/layers.ts
CHANGED
|
@@ -28,7 +28,9 @@ export type OuterOf<L> = L extends (next: any) => infer O ? O : never;
|
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
30
|
* This type checks each neighbor pair of a list of layers. The result of the inner neighbor must
|
|
31
|
-
* fit the input of the outer neighbor.
|
|
31
|
+
* fit the input of the outer neighbor. A bad pair makes the compiler refuse the call. The compiler
|
|
32
|
+
* marks the first argument, not the bad pair. Its message shows the type that the first bad pair
|
|
33
|
+
* needs. At the place of the inner neighbor, it needs a layer that gives the input of the outer one.
|
|
32
34
|
*
|
|
33
35
|
* The type is tail recursive, so the compiler accepts a chain of 100 layers.
|
|
34
36
|
*/
|
package/src/dag/executor.ts
CHANGED
|
@@ -71,9 +71,11 @@ function notify<T>(name: string, listener: ((arg: T) => void) | undefined, arg:
|
|
|
71
71
|
* With `skipDependents` (the default), a node whose dependency failed or was skipped does not start. Its result has
|
|
72
72
|
* `skipped: true` and an error that names those dependencies. A dependency outside the DAG does not count.
|
|
73
73
|
*
|
|
74
|
-
* `failFast` operates
|
|
75
|
-
*
|
|
76
|
-
* starts.
|
|
74
|
+
* `failFast` operates on levels. When a node of a level fails, each node of that level continues to its end.
|
|
75
|
+
* This includes the nodes that did not start before the failure, when `concurrency` is less than the
|
|
76
|
+
* size of the level. No later level starts. The run does not cancel a node.
|
|
77
|
+
*
|
|
78
|
+
* A node that did not start (`skipped: true`) calls neither `onNodeStart` nor `onNodeComplete`.
|
|
77
79
|
*/
|
|
78
80
|
export async function executeDAG<TNode extends DAGNode>(
|
|
79
81
|
dag: DependencyDAG<TNode>,
|
package/src/dag/types.ts
CHANGED
|
@@ -39,7 +39,10 @@ export interface DependencyDAG<TNode extends DAGNode = DAGNode> {
|
|
|
39
39
|
export interface DAGExecutionOptions<TNode extends DAGNode = DAGNode> {
|
|
40
40
|
/** Max parallel operations per level (default: 4) */
|
|
41
41
|
concurrency?: number;
|
|
42
|
-
/**
|
|
42
|
+
/**
|
|
43
|
+
* When this value is true, no level starts after a level with a failure. The default is true.
|
|
44
|
+
* Each node of the level with the failure runs, also a node that did not start before the failure.
|
|
45
|
+
*/
|
|
43
46
|
failFast?: boolean;
|
|
44
47
|
/**
|
|
45
48
|
* When this value is true, a node whose dependency failed or was skipped does not start. Its result has `skipped: true`.
|
package/src/fx/iter.ts
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
* @example
|
|
8
8
|
* const result = pipe(
|
|
9
9
|
* [1, 2, 3, 4, 5],
|
|
10
|
-
* map(x => x * 2),
|
|
11
|
-
* filter(x => x > 5),
|
|
12
|
-
* take(2),
|
|
10
|
+
* (it) => map(it, x => x * 2),
|
|
11
|
+
* (it) => filter(it, x => x > 5),
|
|
12
|
+
* (it) => take(it, 2),
|
|
13
13
|
* toArray
|
|
14
14
|
* ) // [6, 8]
|
|
15
15
|
*/
|
|
@@ -76,13 +76,14 @@ export function* flatten<T>(iterable: Iterable<Iterable<T>>): Generator<T> {
|
|
|
76
76
|
// ============================================================================
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
|
-
* This function takes the first n elements.
|
|
79
|
+
* This function takes the first n elements. It reads no element after the n-th one, and it reads nothing when n is 0.
|
|
80
80
|
*/
|
|
81
81
|
export function* take<T>(iterable: Iterable<T>, n: number): Generator<T> {
|
|
82
|
+
if (n <= 0) return;
|
|
82
83
|
let count = 0;
|
|
83
84
|
for (const value of iterable) {
|
|
84
|
-
if (count++ >= n) break;
|
|
85
85
|
yield value;
|
|
86
|
+
if (++count >= n) return;
|
|
86
87
|
}
|
|
87
88
|
}
|
|
88
89
|
|
package/src/interfaces/list.ts
CHANGED
|
@@ -43,10 +43,9 @@ export interface ReadonlyList<T> extends ReadonlyCollection<T> {
|
|
|
43
43
|
lastIndexOf(element: T, fromIndex?: number): number;
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
|
-
* This method gives a
|
|
47
|
-
* and toIndex (exclusive).
|
|
46
|
+
* This method gives a new list with the elements from fromIndex (inclusive) to toIndex (exclusive).
|
|
48
47
|
*
|
|
49
|
-
*
|
|
48
|
+
* The new list is a copy, not a view. A change to one list does not change the other list.
|
|
50
49
|
*
|
|
51
50
|
* @param fromIndex Start index (inclusive)
|
|
52
51
|
* @param toIndex End index (exclusive)
|
|
@@ -135,7 +134,8 @@ export interface List<T> extends ReadonlyList<T>, Collection<T> {
|
|
|
135
134
|
reverse(): void;
|
|
136
135
|
|
|
137
136
|
/**
|
|
138
|
-
* This method gives a mutable
|
|
137
|
+
* This method gives a new mutable list with the elements from fromIndex (inclusive) to toIndex (exclusive).
|
|
138
|
+
* The new list is a copy, not a view.
|
|
139
139
|
*
|
|
140
140
|
* @param fromIndex Start index (inclusive)
|
|
141
141
|
* @param toIndex End index (exclusive)
|