@bodil/monkey-business 0.1.4 → 0.2.1

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
@@ -1,7 +1,13 @@
1
1
  import { Option } from "@bodil/opt";
2
2
  import { type OrderFn } from "@bodil/core/order";
3
3
  import type { Present } from "@bodil/core/types";
4
+ import "es-iterator-helpers/Iterator.concat/auto";
5
+ import "es-iterator-helpers/Iterator.zip/auto";
6
+ import "es-iterator-helpers/Iterator.zipKeyed/auto";
4
7
  declare global {
8
+ /**
9
+ * Added methods on the {@link Object} global object.
10
+ */
5
11
  interface ObjectConstructor {
6
12
  /**
7
13
  * Checked key lookup. Returns {@link None} if a key isn't present.
@@ -15,9 +21,9 @@ declare global {
15
21
  */
16
22
  mapEntries<A, B>(obj: Record<string, A>, fn: (entry: [key: string, value: A]) => [string, B]): Record<string, B>;
17
23
  }
18
- interface ErrorConstructor {
19
- isError(value: unknown): value is Error;
20
- }
24
+ /**
25
+ * Added methods on {@link Map}s.
26
+ */
21
27
  interface Map<K, V> {
22
28
  /**
23
29
  * If `key` exists in the map, return the value associated with it.
@@ -26,6 +32,9 @@ declare global {
26
32
  */
27
33
  getOrSet(key: K, defaultValue: () => V): V;
28
34
  }
35
+ /**
36
+ * Added methods on {@link Array}s.
37
+ */
29
38
  interface Array<T> {
30
39
  /**
31
40
  * Insert `value` at `index` in the array.
@@ -80,6 +89,9 @@ declare global {
80
89
  */
81
90
  get(index: number): Option<T>;
82
91
  }
92
+ /**
93
+ * Added methods on the {@link Iterator} global object.
94
+ */
83
95
  interface IteratorConstructor {
84
96
  /**
85
97
  * Construct an empty iterator.
@@ -87,22 +99,29 @@ declare global {
87
99
  empty<T>(): IteratorObject<T>;
88
100
  /**
89
101
  * Sequence multiple iterators into a single one.
90
- * {@see https://github.com/tc39/proposal-iterator-sequencing}
102
+ * @see https://github.com/tc39/proposal-iterator-sequencing
91
103
  */
92
104
  concat<T>(...inputs: Array<Iterable<T>>): IteratorObject<T>;
105
+ /**
106
+ * @see https://github.com/tc39/proposal-joint-iteration
107
+ */
108
+ zip<T>(inputs: Iterable<Iterable<T>>): IteratorObject<Array<T>>;
109
+ /**
110
+ * @see https://github.com/tc39/proposal-joint-iteration
111
+ */
112
+ zipKeyed<T>(inputs: Record<string, Iterable<T>>): IteratorObject<Record<string, T>>;
93
113
  }
94
114
  interface IteratorObject<T, TReturn, TNext> {
95
115
  /**
96
116
  * Get the next value from the iterator, wrapped in an {@link Option}
97
117
  * type. If the iterator has no more values, return {@link None}.
98
- *
99
- * This is the nicely utility typed version of {@link Iterator#next}.
100
118
  */
101
119
  takeOne(): Option<T>;
102
120
  /**
103
121
  * Take items from the iterator only until the first time `predicate` returns false.
104
122
  */
105
123
  takeWhile<S extends T>(predicate: (value: T, index: number) => value is S): IteratorObject<S, undefined>;
124
+ /** @ignore */
106
125
  takeWhile(predicate: (value: T, index: number) => boolean): IteratorObject<T, undefined>;
107
126
  /**
108
127
  * Ignore all items matching `predicate` until the first item that
package/dist/index.js CHANGED
@@ -3,252 +3,193 @@
3
3
  import { None, Option, Some } from "@bodil/opt";
4
4
  import { bisectHigh, bisectLow } from "@bodil/core/order";
5
5
  import { assert } from "@bodil/core/assert";
6
+ import defineProperties from "define-properties";
7
+ import shimUnscopables from "es-shim-unscopables";
8
+ import "es-iterator-helpers/Iterator.concat/auto";
9
+ import "es-iterator-helpers/Iterator.zip/auto";
10
+ import "es-iterator-helpers/Iterator.zipKeyed/auto";
6
11
  // Object
7
- Object.get = function get(obj, key) {
8
- return Object.hasOwn(obj, key) ? Some(obj[key]) : None;
9
- };
10
- Object.mapEntries = function mapEntries(obj, fn) {
11
- return Object.fromEntries(Object.entries(obj).map(fn));
12
- };
13
- // Error
14
- Error.isError ??= function isError(value) {
15
- if (!value || (typeof value !== "object" && typeof value !== "function")) {
16
- return false;
17
- }
18
- if (value instanceof Error || value instanceof DOMException) {
19
- return true;
20
- }
21
- try {
22
- const clone = structuredClone(value);
23
- return clone instanceof Error || clone instanceof DOMException;
24
- }
25
- catch (e) {
26
- return false;
27
- }
28
- };
12
+ defineProperties(Object, {
13
+ get(obj, key) {
14
+ return Object.hasOwn(obj, key) ? Some(obj[key]) : None;
15
+ },
16
+ mapEntries(obj, fn) {
17
+ return Object.fromEntries(Object.entries(obj).map(fn));
18
+ },
19
+ });
29
20
  // Map
30
- Map.prototype.getOrSet = function getOrSet(key, defaultValue) {
31
- const result = this.get(key);
32
- if (result !== undefined) {
33
- return result;
34
- }
35
- const newValue = defaultValue();
36
- this.set(key, newValue);
37
- return newValue;
38
- };
21
+ defineProperties(Map.prototype, {
22
+ getOrSet(key, defaultValue) {
23
+ const result = this.get(key);
24
+ if (result !== undefined) {
25
+ return result;
26
+ }
27
+ const newValue = defaultValue();
28
+ this.set(key, newValue);
29
+ return newValue;
30
+ },
31
+ });
39
32
  // Array
40
- Object.defineProperties(Array.prototype, {
41
- remove: {
42
- enumerable: false,
43
- get() {
44
- return function remove(value) {
45
- return this.removeIndex(this.indexOf(value));
46
- };
47
- },
48
- },
49
- removeFn: {
50
- enumerable: false,
51
- get() {
52
- return function removeFn(predicate) {
53
- return this.removeIndex(this.findIndex(predicate));
54
- };
55
- },
56
- },
57
- removeIndex: {
58
- enumerable: false,
59
- get() {
60
- return function removeIndex(index) {
61
- if (!Number.isInteger(index)) {
62
- throw new TypeError(`Array.removeIndex(): index ${index} is not an integer`);
63
- }
64
- if (index < 0 || index >= this.length) {
65
- return None;
66
- }
67
- const removed = this.splice(index, 1).pop();
68
- return Option.from(removed);
69
- };
70
- },
71
- },
72
- insert: {
73
- enumerable: false,
74
- get() {
75
- return function insert(value, index) {
76
- if (!Number.isInteger(index)) {
77
- throw new TypeError(`Array.insert(): index ${index} is not an integer`);
78
- }
79
- if (index > this.length || index < 0) {
80
- throw new RangeError(`Array.insert: index ${index} out of bounds`);
81
- }
82
- this.splice(index, 0, value);
83
- return this;
84
- };
85
- },
86
- },
87
- insertOrdered: {
88
- enumerable: false,
89
- get() {
90
- return function insertOrdered(value, cmp, duplicates = "high") {
91
- return this.insert(value, (duplicates === "low" ? bisectLow : bisectHigh)(cmp, this, value));
92
- };
93
- },
94
- },
95
- present: {
96
- enumerable: false,
97
- get() {
98
- return function present() {
99
- return this.filter((value) => value !== undefined);
100
- };
101
- },
102
- },
103
- nonNullable: {
104
- enumerable: false,
105
- get() {
106
- return function nonNullable() {
107
- return this.filter((value) => value !== undefined);
108
- };
109
- },
110
- },
111
- get: {
112
- enumerable: false,
113
- get() {
114
- return function get(index) {
115
- return Object.get(this, index);
116
- };
117
- },
33
+ defineProperties(Array.prototype, {
34
+ remove(value) {
35
+ return this.removeIndex(this.indexOf(value));
36
+ },
37
+ removeFn(predicate) {
38
+ return this.removeIndex(this.findIndex(predicate));
39
+ },
40
+ removeIndex(index) {
41
+ if (!Number.isInteger(index)) {
42
+ throw new TypeError(`Array.removeIndex(): index ${index} is not an integer`);
43
+ }
44
+ if (index < 0 || index >= this.length) {
45
+ return None;
46
+ }
47
+ const removed = this.splice(index, 1).pop();
48
+ return Option.from(removed);
49
+ },
50
+ insert(value, index) {
51
+ if (!Number.isInteger(index)) {
52
+ throw new TypeError(`Array.insert(): index ${index} is not an integer`);
53
+ }
54
+ if (index > this.length || index < 0) {
55
+ throw new RangeError(`Array.insert: index ${index} out of bounds`);
56
+ }
57
+ this.splice(index, 0, value);
58
+ return this;
59
+ },
60
+ insertOrdered(value, cmp, duplicates = "high") {
61
+ return this.insert(value, (duplicates === "low" ? bisectLow : bisectHigh)(cmp, this, value));
62
+ },
63
+ present() {
64
+ return this.filter((value) => value !== undefined);
65
+ },
66
+ nonNullable() {
67
+ return this.filter((value) => value !== undefined);
68
+ },
69
+ get(index) {
70
+ return Object.get(this, index);
118
71
  },
119
72
  });
73
+ shimUnscopables("remove");
74
+ shimUnscopables("removeFn");
75
+ shimUnscopables("removeIndex");
76
+ shimUnscopables("insert");
77
+ shimUnscopables("insertOrdered");
78
+ shimUnscopables("present");
79
+ shimUnscopables("nonNullable");
80
+ shimUnscopables("get");
120
81
  // Iterator
121
- Iterator.empty = function empty() {
122
- return Iterator.from([]);
123
- };
124
- Iterator.concat = function concat(...inputs) {
125
- if (inputs.length === 0) {
126
- return Iterator.empty();
127
- }
128
- let iter = inputs[0][Symbol.iterator]();
129
- let index = 0;
130
- let done = false;
131
- return Iterator.from({
132
- next() {
133
- if (!done) {
134
- let result = iter.next();
135
- while (result.done === true && index < inputs.length - 1) {
136
- iter = inputs[++index][Symbol.iterator]();
137
- result = iter.next();
138
- }
139
- if (result.done !== true) {
140
- return result;
82
+ defineProperties(Iterator, {
83
+ empty() {
84
+ return Iterator.from([]);
85
+ },
86
+ });
87
+ defineProperties(Iterator.prototype, {
88
+ takeOne() {
89
+ const result = this.next();
90
+ return result.done === true ? None : Some(result.value);
91
+ },
92
+ takeWhile(predicate) {
93
+ const iter = this;
94
+ let index = 0;
95
+ let done = false;
96
+ return Iterator.from({
97
+ next() {
98
+ if (!done) {
99
+ const result = iter.next();
100
+ if (result.done === true) {
101
+ return result;
102
+ }
103
+ if (predicate(result.value, index++)) {
104
+ return result;
105
+ }
141
106
  }
142
- }
143
- done = true;
144
- return { done: true, value: undefined };
145
- },
146
- });
147
- };
148
- Iterator.prototype.takeOne = function takeOne() {
149
- const result = this.next();
150
- return result.done === true ? None : Some(result.value);
151
- };
152
- Iterator.prototype.takeWhile = function takeWhile(predicate) {
153
- const iter = this;
154
- let index = 0;
155
- let done = false;
156
- return Iterator.from({
157
- next() {
158
- if (!done) {
159
- const result = iter.next();
160
- if (result.done === true) {
161
- return result;
107
+ done = true;
108
+ return { done: true, value: undefined };
109
+ },
110
+ });
111
+ },
112
+ skipWhile(predicate) {
113
+ const iter = this;
114
+ let index = 0;
115
+ let skipped = false;
116
+ return Iterator.from({
117
+ next() {
118
+ if (skipped) {
119
+ return iter.next();
162
120
  }
163
- if (predicate(result.value, index++)) {
164
- return result;
121
+ while (true) {
122
+ const result = iter.next();
123
+ if (result.done === true) {
124
+ return result;
125
+ }
126
+ if (!predicate(result.value, index++)) {
127
+ skipped = true;
128
+ return result;
129
+ }
165
130
  }
131
+ },
132
+ });
133
+ },
134
+ findMap(mapFn) {
135
+ let index = 0;
136
+ while (true) {
137
+ const result = this.next();
138
+ if (result.done === true) {
139
+ return undefined;
166
140
  }
167
- done = true;
168
- return { done: true, value: undefined };
169
- },
170
- });
171
- };
172
- Iterator.prototype.skipWhile = function skipWhile(predicate) {
173
- const iter = this;
174
- let index = 0;
175
- let skipped = false;
176
- return Iterator.from({
177
- next() {
178
- if (skipped) {
179
- return iter.next();
141
+ const mapped = mapFn(result.value, index++);
142
+ if (mapped !== undefined) {
143
+ return mapped;
180
144
  }
181
- while (true) {
182
- const result = iter.next();
183
- if (result.done === true) {
184
- return result;
145
+ }
146
+ },
147
+ partition(size) {
148
+ const iter = this;
149
+ let done = false;
150
+ return Iterator.from({
151
+ next() {
152
+ if (done) {
153
+ return { done: true, value: undefined };
185
154
  }
186
- if (!predicate(result.value, index++)) {
187
- skipped = true;
188
- return result;
155
+ const part = [];
156
+ while (true) {
157
+ const result = iter.next();
158
+ if (result.done === true) {
159
+ done = true;
160
+ return part.length > 0
161
+ ? { done: false, value: part }
162
+ : { done: true, value: undefined };
163
+ }
164
+ part.push(result.value);
165
+ if (part.length === size) {
166
+ return { done: false, value: part };
167
+ }
189
168
  }
190
- }
191
- },
192
- });
193
- };
194
- Iterator.prototype.findMap = function findMap(mapFn) {
195
- let index = 0;
196
- while (true) {
197
- const result = this.next();
198
- if (result.done === true) {
199
- return undefined;
169
+ },
170
+ });
171
+ },
172
+ frontBiasedPartition(size) {
173
+ const input = this.toArray();
174
+ let inputPos = 0;
175
+ const firstLength = input.length % size;
176
+ const output = [];
177
+ if (firstLength > 0) {
178
+ output.push(input.slice(0, firstLength));
179
+ inputPos = firstLength;
200
180
  }
201
- const mapped = mapFn(result.value, index++);
202
- if (mapped !== undefined) {
203
- return mapped;
181
+ while (inputPos < input.length) {
182
+ output.push(input.slice(inputPos, inputPos + size));
183
+ inputPos += size;
204
184
  }
205
- }
206
- };
207
- Iterator.prototype.partition = function partition(size) {
208
- const iter = this;
209
- let done = false;
210
- return Iterator.from({
211
- next() {
212
- if (done) {
213
- return { done: true, value: undefined };
214
- }
215
- const part = [];
216
- while (true) {
217
- const result = iter.next();
218
- if (result.done === true) {
219
- done = true;
220
- return part.length > 0
221
- ? { done: false, value: part }
222
- : { done: true, value: undefined };
223
- }
224
- part.push(result.value);
225
- if (part.length === size) {
226
- return { done: false, value: part };
227
- }
228
- }
229
- },
230
- });
231
- };
232
- Iterator.prototype.frontBiasedPartition = function frontBiasedPartition(size) {
233
- const input = this.toArray();
234
- let inputPos = 0;
235
- const firstLength = input.length % size;
236
- const output = [];
237
- if (firstLength > 0) {
238
- output.push(input.slice(0, firstLength));
239
- inputPos = firstLength;
240
- }
241
- while (inputPos < input.length) {
242
- output.push(input.slice(inputPos, inputPos + size));
243
- inputPos += size;
244
- }
245
- assert(inputPos === input.length);
246
- return output;
247
- };
248
- Iterator.prototype.present = function present() {
249
- return Iterator.from(this.filter((item) => item !== undefined));
250
- };
251
- Iterator.prototype.nonNullable = function nonNullable() {
252
- return Iterator.from(this.filter((item) => item !== undefined && item !== null));
253
- };
185
+ assert(inputPos === input.length);
186
+ return output;
187
+ },
188
+ present() {
189
+ return Iterator.from(this.filter((item) => item !== undefined));
190
+ },
191
+ nonNullable() {
192
+ return Iterator.from(this.filter((item) => item !== undefined && item !== null));
193
+ },
194
+ });
254
195
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,sCAAsC;AAEtC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAgB,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAExE,OAAO,E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AAE,CAAC;YAClB,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC;YACzC,QAAQ,GAAG,WAAW,CAAC;QAC3B,CAAC;QACD,OAAO,QAAQ,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC;YAC7B,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC;YACpD,QAAQ,IAAI,IAAI,CAAC;QACrB,CAAC;QACD,MAAM,CAAC,QAAQ,KAAK,KAAK,CAAC,MAAM,CAAC,CAAC;QAClC,OAAO,MAAM,CAAC;IAClB,CAAC;IAED,OAAO;QACH,OAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAsB,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC;IACxF,CAAC;IAED,WAAW;QACP,OAAO,QAAQ,CAAC,IAAI,CAChB,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAA0B,EAAE,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,CAAC,CACrF,CAAC;IACN,CAAC;CACJ,CAAC,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { test, expect, expectTypeOf } from "vitest";
2
- import { Order } from "@bodil/core";
2
+ import { order as Order } from "@bodil/core";
3
3
  import ".";
4
4
  import "@bodil/opt-vitest";
5
5
  const Iterator = globalThis.Iterator;
@@ -1 +1 @@
1
- {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEpD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,OAAO,GAAG,CAAC;AAEX,OAAO,mBAAmB,CAAC;AAE3B,MAAM,QAAQ,GAAG,U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C,CAAC;AAEH,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE;IACvB,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC;IAClC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC;IAChC,MAAM,IAAI,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACjC,MAAM,MAAM,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;AACxC,CAAC,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@bodil/monkey-business",
3
- "version": "0.1.4",
3
+ "version": "0.2.1",
4
4
  "description": "Let's give JS core types a polish",
5
+ "homepage": "https://codeberg.org/bodil/monkey-business",
5
6
  "repository": {
6
7
  "type": "git",
7
- "url": "git+https://github.com/bodil/monkey-business.git"
8
+ "url": "ssh://git@codeberg.org/bodil/monkey-business.git"
8
9
  },
9
10
  "license": "EUPL-1.2+",
10
11
  "module": "dist/index.js",
@@ -25,26 +26,35 @@
25
26
  "access": "public"
26
27
  },
27
28
  "dependencies": {
28
- "@bodil/core": "^0.1.2",
29
- "@bodil/opt": "^0.2.6"
29
+ "@bodil/core": "^0.3.0",
30
+ "@bodil/opt": "^0.4.1",
31
+ "@types/define-properties": "^1.1.5",
32
+ "define-properties": "^1.2.1",
33
+ "es-iterator-helpers": "^1.2.1",
34
+ "es-shim-unscopables": "^1.1.0"
30
35
  },
31
36
  "devDependencies": {
32
- "@bodil/opt-vitest": "^1.0.0",
37
+ "@bodil/opt-vitest": "^1.1.0",
33
38
  "@eslint/eslintrc": "^3.3.1",
34
- "@eslint/js": "^9.24.0",
35
- "@typescript-eslint/eslint-plugin": "^8.29.1",
36
- "@typescript-eslint/parser": "^8.29.1",
37
- "eslint": "^9.24.0",
38
- "eslint-config-prettier": "^10.1.1",
39
- "eslint-plugin-jsdoc": "^50.6.9",
40
- "globals": "^15.15.0",
41
- "typescript": "^5.8.3",
42
- "vitest": "^3.1.1"
39
+ "@eslint/js": "^9.33.0",
40
+ "@typescript-eslint/eslint-plugin": "^8.39.1",
41
+ "@typescript-eslint/parser": "^8.39.1",
42
+ "eslint": "^9.33.0",
43
+ "eslint-config-prettier": "^10.1.8",
44
+ "eslint-plugin-jsdoc": "^54.0.0",
45
+ "globals": "^16.3.0",
46
+ "typedoc": "^0.28.10",
47
+ "typedoc-plugin-extras": "^4.0.1",
48
+ "typedoc-plugin-mdn-links": "^5.0.8",
49
+ "typescript": "^5.9.2",
50
+ "vitest": "^3.2.4"
43
51
  },
44
52
  "scripts": {
45
53
  "build": "tsc",
46
54
  "test": "vitest --run",
47
55
  "lint": "eslint src",
56
+ "doc": "typedoc",
57
+ "doc:readthedocs": "typedoc --out $READTHEDOCS_OUTPUT/html",
48
58
  "prepublish": "tsc"
49
59
  }
50
60
  }
package/src/index.test.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { test, expect, expectTypeOf } from "vitest";
2
2
  import type { Option } from "@bodil/opt";
3
- import { Order } from "@bodil/core";
3
+ import { order as Order } from "@bodil/core";
4
4
 
5
5
  import ".";
6
6
 
package/src/index.ts CHANGED
@@ -5,8 +5,17 @@ import { None, Option, Some } from "@bodil/opt";
5
5
  import { type OrderFn, bisectHigh, bisectLow } from "@bodil/core/order";
6
6
  import type { Present } from "@bodil/core/types";
7
7
  import { assert } from "@bodil/core/assert";
8
+ import defineProperties from "define-properties";
9
+ import shimUnscopables from "es-shim-unscopables";
10
+
11
+ import "es-iterator-helpers/Iterator.concat/auto";
12
+ import "es-iterator-helpers/Iterator.zip/auto";
13
+ import "es-iterator-helpers/Iterator.zipKeyed/auto";
8
14
 
9
15
  declare global {
16
+ /**
17
+ * Added methods on the {@link Object} global object.
18
+ */
10
19
  interface ObjectConstructor {
11
20
  /**
12
21
  * Checked key lookup. Returns {@link None} if a key isn't present.
@@ -25,10 +34,9 @@ declare global {
25
34
  ): Record<string, B>;
26
35
  }
27
36
 
28
- interface ErrorConstructor {
29
- isError(value: unknown): value is Error;
30
- }
31
-
37
+ /**
38
+ * Added methods on {@link Map}s.
39
+ */
32
40
  interface Map<K, V> {
33
41
  /**
34
42
  * If `key` exists in the map, return the value associated with it.
@@ -38,6 +46,9 @@ declare global {
38
46
  getOrSet(key: K, defaultValue: () => V): V;
39
47
  }
40
48
 
49
+ /**
50
+ * Added methods on {@link Array}s.
51
+ */
41
52
  interface Array<T> {
42
53
  /**
43
54
  * Insert `value` at `index` in the array.
@@ -100,6 +111,9 @@ declare global {
100
111
  get(index: number): Option<T>;
101
112
  }
102
113
 
114
+ /**
115
+ * Added methods on the {@link Iterator} global object.
116
+ */
103
117
  interface IteratorConstructor {
104
118
  /**
105
119
  * Construct an empty iterator.
@@ -107,9 +121,17 @@ declare global {
107
121
  empty<T>(): IteratorObject<T>;
108
122
  /**
109
123
  * Sequence multiple iterators into a single one.
110
- * {@see https://github.com/tc39/proposal-iterator-sequencing}
124
+ * @see https://github.com/tc39/proposal-iterator-sequencing
111
125
  */
112
126
  concat<T>(...inputs: Array<Iterable<T>>): IteratorObject<T>;
127
+ /**
128
+ * @see https://github.com/tc39/proposal-joint-iteration
129
+ */
130
+ zip<T>(inputs: Iterable<Iterable<T>>): IteratorObject<Array<T>>;
131
+ /**
132
+ * @see https://github.com/tc39/proposal-joint-iteration
133
+ */
134
+ zipKeyed<T>(inputs: Record<string, Iterable<T>>): IteratorObject<Record<string, T>>;
113
135
  }
114
136
 
115
137
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
@@ -117,8 +139,6 @@ declare global {
117
139
  /**
118
140
  * Get the next value from the iterator, wrapped in an {@link Option}
119
141
  * type. If the iterator has no more values, return {@link None}.
120
- *
121
- * This is the nicely utility typed version of {@link Iterator#next}.
122
142
  */
123
143
  takeOne(): Option<T>;
124
144
  /**
@@ -127,6 +147,7 @@ declare global {
127
147
  takeWhile<S extends T>(
128
148
  predicate: (value: T, index: number) => value is S
129
149
  ): IteratorObject<S, undefined>;
150
+ /** @ignore */
130
151
  takeWhile(predicate: (value: T, index: number) => boolean): IteratorObject<T, undefined>;
131
152
  /**
132
153
  * Ignore all items matching `predicate` until the first item that
@@ -164,308 +185,237 @@ declare global {
164
185
 
165
186
  // Object
166
187
 
167
- Object.get = function get<O extends object, K extends keyof O>(obj: O, key: K): Option<O[K]> {
168
- return Object.hasOwn(obj, key) ? Some(obj[key]) : None;
169
- };
170
-
171
- Object.mapEntries = function mapEntries<A, B>(
172
- obj: Record<string, A>,
173
- fn: (entry: [key: string, value: A]) => [string, B]
174
- ): Record<string, B> {
175
- return Object.fromEntries(Object.entries(obj).map(fn));
176
- };
177
-
178
- // Error
179
-
180
- Error.isError ??= function isError(value: unknown): value is Error {
181
- if (!value || (typeof value !== "object" && typeof value !== "function")) {
182
- return false;
183
- }
184
-
185
- if (value instanceof Error || value instanceof DOMException) {
186
- return true;
187
- }
188
+ defineProperties(Object, {
189
+ get<O extends object, K extends keyof O>(obj: O, key: K): Option<O[K]> {
190
+ return Object.hasOwn(obj, key) ? Some(obj[key]) : None;
191
+ },
188
192
 
189
- try {
190
- const clone = structuredClone(value);
191
- return clone instanceof Error || clone instanceof DOMException;
192
- } catch (e) {
193
- return false;
194
- }
195
- };
193
+ mapEntries<A, B>(
194
+ obj: Record<string, A>,
195
+ fn: (entry: [key: string, value: A]) => [string, B]
196
+ ): Record<string, B> {
197
+ return Object.fromEntries(Object.entries(obj).map(fn));
198
+ },
199
+ });
196
200
 
197
201
  // Map
198
202
 
199
- Map.prototype.getOrSet = function getOrSet<K, V>(
200
- this: Map<K, NonNullable<V>>,
201
- key: K,
202
- defaultValue: () => NonNullable<V>
203
- ): V {
204
- const result = this.get(key);
205
- if (result !== undefined) {
206
- return result;
207
- }
208
- const newValue = defaultValue();
209
- this.set(key, newValue);
210
- return newValue;
211
- };
203
+ defineProperties(Map.prototype, {
204
+ getOrSet<K, V>(this: Map<K, NonNullable<V>>, key: K, defaultValue: () => NonNullable<V>): V {
205
+ const result = this.get(key);
206
+ if (result !== undefined) {
207
+ return result;
208
+ }
209
+ const newValue = defaultValue();
210
+ this.set(key, newValue);
211
+ return newValue;
212
+ },
213
+ });
212
214
 
213
215
  // Array
214
216
 
215
- Object.defineProperties(Array.prototype, {
216
- remove: {
217
- enumerable: false,
218
- get() {
219
- return function remove<T>(this: Array<T>, value: T): Option<T> {
220
- return this.removeIndex(this.indexOf(value));
221
- };
222
- },
217
+ defineProperties(Array.prototype, {
218
+ remove<T>(this: Array<T>, value: T): Option<T> {
219
+ return this.removeIndex(this.indexOf(value));
223
220
  },
224
- removeFn: {
225
- enumerable: false,
226
- get() {
227
- return function removeFn<T>(
228
- this: Array<T>,
229
- predicate: (value: T, index: number, obj: Array<T>) => boolean
230
- ): Option<T> {
231
- return this.removeIndex(this.findIndex(predicate as () => boolean));
232
- };
233
- },
221
+
222
+ removeFn<T>(
223
+ this: Array<T>,
224
+ predicate: (value: T, index: number, obj: Array<T>) => boolean
225
+ ): Option<T> {
226
+ return this.removeIndex(this.findIndex(predicate as () => boolean));
234
227
  },
235
- removeIndex: {
236
- enumerable: false,
237
- get() {
238
- return function removeIndex<T>(this: Array<T>, index: number): Option<T> {
239
- if (!Number.isInteger(index)) {
240
- throw new TypeError(`Array.removeIndex(): index ${index} is not an integer`);
241
- }
242
- if (index < 0 || index >= this.length) {
243
- return None;
244
- }
245
- const removed = this.splice(index, 1).pop();
246
- return Option.from(removed);
247
- };
248
- },
228
+
229
+ removeIndex<T>(this: Array<T>, index: number): Option<T> {
230
+ if (!Number.isInteger(index)) {
231
+ throw new TypeError(`Array.removeIndex(): index ${index} is not an integer`);
232
+ }
233
+ if (index < 0 || index >= this.length) {
234
+ return None;
235
+ }
236
+ const removed = this.splice(index, 1).pop();
237
+ return Option.from(removed);
249
238
  },
250
- insert: {
251
- enumerable: false,
252
- get() {
253
- return function insert<T>(this: Array<T>, value: T, index: number): Array<T> {
254
- if (!Number.isInteger(index)) {
255
- throw new TypeError(`Array.insert(): index ${index} is not an integer`);
256
- }
257
- if (index > this.length || index < 0) {
258
- throw new RangeError(`Array.insert: index ${index} out of bounds`);
259
- }
260
- this.splice(index, 0, value);
261
- return this;
262
- };
263
- },
239
+
240
+ insert<T>(this: Array<T>, value: T, index: number): Array<T> {
241
+ if (!Number.isInteger(index)) {
242
+ throw new TypeError(`Array.insert(): index ${index} is not an integer`);
243
+ }
244
+ if (index > this.length || index < 0) {
245
+ throw new RangeError(`Array.insert: index ${index} out of bounds`);
246
+ }
247
+ this.splice(index, 0, value);
248
+ return this;
264
249
  },
265
- insertOrdered: {
266
- enumerable: false,
267
- get() {
268
- return function insertOrdered<T>(
269
- this: Array<T>,
270
- value: T,
271
- cmp: OrderFn<T>,
272
- duplicates: "low" | "high" = "high"
273
- ): Array<T> {
274
- return this.insert(
275
- value,
276
- (duplicates === "low" ? bisectLow : bisectHigh)(cmp, this, value)
277
- );
278
- };
279
- },
250
+
251
+ insertOrdered<T>(
252
+ this: Array<T>,
253
+ value: T,
254
+ cmp: OrderFn<T>,
255
+ duplicates: "low" | "high" = "high"
256
+ ): Array<T> {
257
+ return this.insert(
258
+ value,
259
+ (duplicates === "low" ? bisectLow : bisectHigh)(cmp, this, value)
260
+ );
280
261
  },
281
- present: {
282
- enumerable: false,
283
- get() {
284
- return function present<T>(this: Array<T>): Array<Present<T>> {
285
- return this.filter((value: T): value is Present<T> => value !== undefined);
286
- };
287
- },
262
+
263
+ present<T>(this: Array<T>): Array<Present<T>> {
264
+ return this.filter((value: T): value is Present<T> => value !== undefined);
288
265
  },
289
- nonNullable: {
290
- enumerable: false,
291
- get() {
292
- return function nonNullable<T>(this: Array<T>): Array<NonNullable<T>> {
293
- return this.filter((value: T): value is NonNullable<T> => value !== undefined);
294
- };
295
- },
266
+
267
+ nonNullable<T>(this: Array<T>): Array<NonNullable<T>> {
268
+ return this.filter((value: T): value is NonNullable<T> => value !== undefined);
296
269
  },
297
- get: {
298
- enumerable: false,
299
- get() {
300
- return function get<T>(this: Array<T>, index: number): Option<T> {
301
- return Object.get(this, index);
302
- };
303
- },
270
+
271
+ get<T>(this: Array<T>, index: number): Option<T> {
272
+ return Object.get(this, index);
304
273
  },
305
274
  });
306
275
 
276
+ shimUnscopables("remove");
277
+ shimUnscopables("removeFn");
278
+ shimUnscopables("removeIndex");
279
+ shimUnscopables("insert");
280
+ shimUnscopables("insertOrdered");
281
+ shimUnscopables("present");
282
+ shimUnscopables("nonNullable");
283
+ shimUnscopables("get");
284
+
307
285
  // Iterator
308
286
 
309
- Iterator.empty = function empty<T>(): IteratorObject<T> {
310
- return Iterator.from([]);
311
- };
287
+ defineProperties(Iterator, {
288
+ empty<T>(): IteratorObject<T> {
289
+ return Iterator.from([]);
290
+ },
291
+ });
312
292
 
313
- Iterator.concat = function concat<T>(...inputs: Array<Iterable<T>>): IteratorObject<T> {
314
- if (inputs.length === 0) {
315
- return Iterator.empty();
316
- }
317
- let iter: Iterator<T> = inputs[0][Symbol.iterator]();
318
- let index = 0;
319
- let done = false;
320
- return Iterator.from({
321
- next(): IteratorResult<T, undefined> {
322
- if (!done) {
323
- let result = iter.next();
324
- while (result.done === true && index < inputs.length - 1) {
325
- iter = inputs[++index][Symbol.iterator]();
326
- result = iter.next();
327
- }
328
- if (result.done !== true) {
329
- return result;
293
+ defineProperties(Iterator.prototype, {
294
+ takeOne<T>(this: Iterator<T>): Option<T> {
295
+ const result = this.next();
296
+ return result.done === true ? None : Some(result.value);
297
+ },
298
+
299
+ takeWhile<T>(
300
+ this: IteratorObject<T, undefined>,
301
+ predicate: (value: T, index: number) => boolean
302
+ ): IteratorObject<T, undefined> {
303
+ const iter = this;
304
+ let index = 0;
305
+ let done = false;
306
+ return Iterator.from<T>({
307
+ next(): IteratorResult<T, undefined> {
308
+ if (!done) {
309
+ const result = iter.next();
310
+ if (result.done === true) {
311
+ return result;
312
+ }
313
+ if (predicate(result.value, index++)) {
314
+ return result;
315
+ }
330
316
  }
331
- }
332
- done = true;
333
- return { done: true, value: undefined };
334
- },
335
- });
336
- };
337
-
338
- Iterator.prototype.takeOne = function takeOne<T>(this: Iterator<T>): Option<T> {
339
- const result = this.next();
340
- return result.done === true ? None : Some(result.value);
341
- };
342
-
343
- Iterator.prototype.takeWhile = function takeWhile<T>(
344
- this: IteratorObject<T, undefined>,
345
- predicate: (value: T, index: number) => boolean
346
- ): IteratorObject<T, undefined> {
347
- const iter = this;
348
- let index = 0;
349
- let done = false;
350
- return Iterator.from<T>({
351
- next(): IteratorResult<T, undefined> {
352
- if (!done) {
353
- const result = iter.next();
354
- if (result.done === true) {
355
- return result;
317
+ done = true;
318
+ return { done: true, value: undefined };
319
+ },
320
+ });
321
+ },
322
+
323
+ skipWhile<T>(
324
+ this: IteratorObject<T, undefined>,
325
+ predicate: (value: T, index: number) => boolean
326
+ ): IteratorObject<T, undefined> {
327
+ const iter = this;
328
+ let index = 0;
329
+ let skipped = false;
330
+ return Iterator.from<T>({
331
+ next(): IteratorResult<T, undefined> {
332
+ if (skipped) {
333
+ return iter.next();
356
334
  }
357
- if (predicate(result.value, index++)) {
358
- return result;
335
+ while (true) {
336
+ const result = iter.next();
337
+ if (result.done === true) {
338
+ return result;
339
+ }
340
+ if (!predicate(result.value, index++)) {
341
+ skipped = true;
342
+ return result;
343
+ }
359
344
  }
345
+ },
346
+ });
347
+ },
348
+
349
+ findMap<T, U>(
350
+ this: IteratorObject<T, undefined>,
351
+ mapFn: (value: T, index: number) => NonNullable<U> | undefined
352
+ ): NonNullable<U> | undefined {
353
+ let index = 0;
354
+ while (true) {
355
+ const result = this.next();
356
+ if (result.done === true) {
357
+ return undefined;
360
358
  }
361
- done = true;
362
- return { done: true, value: undefined };
363
- },
364
- });
365
- };
366
-
367
- Iterator.prototype.skipWhile = function skipWhile<T>(
368
- this: IteratorObject<T, undefined>,
369
- predicate: (value: T, index: number) => boolean
370
- ): IteratorObject<T, undefined> {
371
- const iter = this;
372
- let index = 0;
373
- let skipped = false;
374
- return Iterator.from<T>({
375
- next(): IteratorResult<T, undefined> {
376
- if (skipped) {
377
- return iter.next();
359
+ const mapped = mapFn(result.value, index++);
360
+ if (mapped !== undefined) {
361
+ return mapped;
378
362
  }
379
- while (true) {
380
- const result = iter.next();
381
- if (result.done === true) {
382
- return result;
363
+ }
364
+ },
365
+
366
+ partition<T>(
367
+ this: IteratorObject<T, undefined>,
368
+ size: number
369
+ ): IteratorObject<Array<T>, undefined> {
370
+ const iter = this;
371
+ let done = false;
372
+ return Iterator.from<Array<T>>({
373
+ next(): IteratorResult<Array<T>, undefined> {
374
+ if (done) {
375
+ return { done: true, value: undefined };
383
376
  }
384
- if (!predicate(result.value, index++)) {
385
- skipped = true;
386
- return result;
377
+ const part = [];
378
+ while (true) {
379
+ const result = iter.next();
380
+ if (result.done === true) {
381
+ done = true;
382
+ return part.length > 0
383
+ ? { done: false, value: part }
384
+ : { done: true, value: undefined };
385
+ }
386
+ part.push(result.value);
387
+ if (part.length === size) {
388
+ return { done: false, value: part };
389
+ }
387
390
  }
388
- }
389
- },
390
- });
391
- };
392
-
393
- Iterator.prototype.findMap = function findMap<T, U>(
394
- this: IteratorObject<T, undefined>,
395
- mapFn: (value: T, index: number) => NonNullable<U> | undefined
396
- ): NonNullable<U> | undefined {
397
- let index = 0;
398
- while (true) {
399
- const result = this.next();
400
- if (result.done === true) {
401
- return undefined;
391
+ },
392
+ });
393
+ },
394
+
395
+ frontBiasedPartition<T>(this: IteratorObject<T, undefined>, size: number): Array<Array<T>> {
396
+ const input = this.toArray();
397
+ let inputPos = 0;
398
+ const firstLength = input.length % size;
399
+ const output: Array<Array<T>> = [];
400
+ if (firstLength > 0) {
401
+ output.push(input.slice(0, firstLength));
402
+ inputPos = firstLength;
402
403
  }
403
- const mapped = mapFn(result.value, index++);
404
- if (mapped !== undefined) {
405
- return mapped;
404
+ while (inputPos < input.length) {
405
+ output.push(input.slice(inputPos, inputPos + size));
406
+ inputPos += size;
406
407
  }
407
- }
408
- };
409
-
410
- Iterator.prototype.partition = function partition<T>(
411
- this: IteratorObject<T, undefined>,
412
- size: number
413
- ): IteratorObject<Array<T>, undefined> {
414
- const iter = this;
415
- let done = false;
416
- return Iterator.from<Array<T>>({
417
- next(): IteratorResult<Array<T>, undefined> {
418
- if (done) {
419
- return { done: true, value: undefined };
420
- }
421
- const part = [];
422
- while (true) {
423
- const result = iter.next();
424
- if (result.done === true) {
425
- done = true;
426
- return part.length > 0
427
- ? { done: false, value: part }
428
- : { done: true, value: undefined };
429
- }
430
- part.push(result.value);
431
- if (part.length === size) {
432
- return { done: false, value: part };
433
- }
434
- }
435
- },
436
- });
437
- };
438
-
439
- Iterator.prototype.frontBiasedPartition = function frontBiasedPartition<T>(
440
- this: IteratorObject<T, undefined>,
441
- size: number
442
- ): Array<Array<T>> {
443
- const input = this.toArray();
444
- let inputPos = 0;
445
- const firstLength = input.length % size;
446
- const output: Array<Array<T>> = [];
447
- if (firstLength > 0) {
448
- output.push(input.slice(0, firstLength));
449
- inputPos = firstLength;
450
- }
451
- while (inputPos < input.length) {
452
- output.push(input.slice(inputPos, inputPos + size));
453
- inputPos += size;
454
- }
455
- assert(inputPos === input.length);
456
- return output;
457
- };
458
-
459
- Iterator.prototype.present = function present<T>(
460
- this: IteratorObject<T, undefined>
461
- ): IteratorObject<Present<T>, undefined> {
462
- return Iterator.from(this.filter((item): item is Present<T> => item !== undefined));
463
- };
464
-
465
- Iterator.prototype.nonNullable = function nonNullable<T>(
466
- this: IteratorObject<T, undefined>
467
- ): IteratorObject<NonNullable<T>, undefined> {
468
- return Iterator.from(
469
- this.filter((item): item is NonNullable<T> => item !== undefined && item !== null)
470
- );
471
- };
408
+ assert(inputPos === input.length);
409
+ return output;
410
+ },
411
+
412
+ present<T>(this: IteratorObject<T, undefined>): IteratorObject<Present<T>, undefined> {
413
+ return Iterator.from(this.filter((item): item is Present<T> => item !== undefined));
414
+ },
415
+
416
+ nonNullable<T>(this: IteratorObject<T, undefined>): IteratorObject<NonNullable<T>, undefined> {
417
+ return Iterator.from(
418
+ this.filter((item): item is NonNullable<T> => item !== undefined && item !== null)
419
+ );
420
+ },
421
+ });