@nlozgachev/pipelined 0.33.0 → 0.34.0
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 +67 -37
- package/dist/{Task-5na0QzS4.d.mts → Task-DXsuurnc.d.mts} +54 -55
- package/dist/{Task-DeiWgoeJ.d.ts → Task-zAY4kSVB.d.ts} +54 -55
- package/dist/{chunk-FZX4MTRI.mjs → chunk-5AWUAG7G.mjs} +445 -308
- package/dist/{chunk-NRF2FVPZ.mjs → chunk-AHEZFTMT.mjs} +64 -32
- package/dist/{chunk-GSTKY7MF.mjs → chunk-DLBHVYII.mjs} +69 -52
- package/dist/{chunk-W53ZYTLX.mjs → chunk-IJFFWBKW.mjs} +184 -64
- package/dist/composition.d.mts +8 -7
- package/dist/composition.d.ts +8 -7
- package/dist/composition.js +64 -32
- package/dist/composition.mjs +1 -1
- package/dist/core.d.mts +172 -163
- package/dist/core.d.ts +172 -163
- package/dist/core.js +535 -384
- package/dist/core.mjs +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +783 -480
- package/dist/index.mjs +4 -4
- package/dist/utils.d.mts +8 -7
- package/dist/utils.d.ts +8 -7
- package/dist/utils.js +252 -115
- package/dist/utils.mjs +2 -2
- package/package.json +9 -9
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
Maybe,
|
|
4
4
|
Result,
|
|
5
5
|
Task
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-DLBHVYII.mjs";
|
|
7
7
|
import {
|
|
8
8
|
isNonEmptyList
|
|
9
9
|
} from "./chunk-DBIC62UV.mjs";
|
|
@@ -17,35 +17,43 @@ var Arr;
|
|
|
17
17
|
Arr2.init = (data) => data.length > 0 ? Maybe.some(data.slice(0, -1)) : Maybe.none();
|
|
18
18
|
Arr2.findFirst = (predicate) => (data) => {
|
|
19
19
|
const idx = data.findIndex(predicate);
|
|
20
|
-
return idx
|
|
20
|
+
return idx !== -1 ? Maybe.some(data[idx]) : Maybe.none();
|
|
21
21
|
};
|
|
22
22
|
Arr2.findLast = (predicate) => (data) => {
|
|
23
23
|
for (let i = data.length - 1; i >= 0; i--) {
|
|
24
|
-
if (predicate(data[i]))
|
|
24
|
+
if (predicate(data[i])) {
|
|
25
|
+
return Maybe.some(data[i]);
|
|
26
|
+
}
|
|
25
27
|
}
|
|
26
28
|
return Maybe.none();
|
|
27
29
|
};
|
|
28
30
|
Arr2.findIndex = (predicate) => (data) => {
|
|
29
31
|
const idx = data.findIndex(predicate);
|
|
30
|
-
return idx
|
|
32
|
+
return idx !== -1 ? Maybe.some(idx) : Maybe.none();
|
|
31
33
|
};
|
|
32
34
|
Arr2.map = (f) => (data) => {
|
|
33
35
|
const n = data.length;
|
|
34
36
|
const result = new Array(n);
|
|
35
|
-
for (let i = 0; i < n; i++)
|
|
37
|
+
for (let i = 0; i < n; i++) {
|
|
38
|
+
result[i] = f(data[i]);
|
|
39
|
+
}
|
|
36
40
|
return result;
|
|
37
41
|
};
|
|
38
42
|
Arr2.mapWithIndex = (f) => (data) => {
|
|
39
43
|
const n = data.length;
|
|
40
44
|
const result = new Array(n);
|
|
41
|
-
for (let i = 0; i < n; i++)
|
|
45
|
+
for (let i = 0; i < n; i++) {
|
|
46
|
+
result[i] = f(i, data[i]);
|
|
47
|
+
}
|
|
42
48
|
return result;
|
|
43
49
|
};
|
|
44
50
|
Arr2.filter = (predicate) => (data) => {
|
|
45
51
|
const n = data.length;
|
|
46
52
|
const result = [];
|
|
47
53
|
for (let i = 0; i < n; i++) {
|
|
48
|
-
if (predicate(data[i]))
|
|
54
|
+
if (predicate(data[i])) {
|
|
55
|
+
result.push(data[i]);
|
|
56
|
+
}
|
|
49
57
|
}
|
|
50
58
|
return result;
|
|
51
59
|
};
|
|
@@ -53,7 +61,9 @@ var Arr;
|
|
|
53
61
|
const result = [];
|
|
54
62
|
for (let i = 0; i < data.length; i++) {
|
|
55
63
|
const mapped = f(data[i]);
|
|
56
|
-
if (mapped.kind === "Some")
|
|
64
|
+
if (mapped.kind === "Some") {
|
|
65
|
+
result.push(mapped.value);
|
|
66
|
+
}
|
|
57
67
|
}
|
|
58
68
|
return result;
|
|
59
69
|
};
|
|
@@ -103,14 +113,14 @@ var Arr;
|
|
|
103
113
|
const result = {};
|
|
104
114
|
for (const a of data) {
|
|
105
115
|
const key = f(a);
|
|
106
|
-
if (!result[key])
|
|
116
|
+
if (!result[key]) {
|
|
117
|
+
result[key] = [];
|
|
118
|
+
}
|
|
107
119
|
result[key].push(a);
|
|
108
120
|
}
|
|
109
121
|
return result;
|
|
110
122
|
};
|
|
111
|
-
Arr2.uniq = (data) => [
|
|
112
|
-
...new Set(data)
|
|
113
|
-
];
|
|
123
|
+
Arr2.uniq = (data) => [...new Set(data)];
|
|
114
124
|
Arr2.uniqBy = (f) => (data) => {
|
|
115
125
|
const seen = /* @__PURE__ */ new Set();
|
|
116
126
|
const result = [];
|
|
@@ -134,12 +144,16 @@ var Arr;
|
|
|
134
144
|
};
|
|
135
145
|
Arr2.sortBy = (compare) => (data) => {
|
|
136
146
|
const arr = data;
|
|
137
|
-
if (typeof arr.toSorted === "function")
|
|
138
|
-
|
|
147
|
+
if (typeof arr.toSorted === "function") {
|
|
148
|
+
return arr.toSorted(compare);
|
|
149
|
+
}
|
|
150
|
+
return [...data].toSorted(compare);
|
|
139
151
|
};
|
|
140
152
|
Arr2.sortWith = (ord) => (data) => {
|
|
141
153
|
const arr = data;
|
|
142
|
-
if (typeof arr.toSorted === "function")
|
|
154
|
+
if (typeof arr.toSorted === "function") {
|
|
155
|
+
return arr.toSorted(ord);
|
|
156
|
+
}
|
|
143
157
|
return [...data].sort(ord);
|
|
144
158
|
};
|
|
145
159
|
Arr2.zip = (other) => (data) => {
|
|
@@ -159,7 +173,9 @@ var Arr;
|
|
|
159
173
|
return result;
|
|
160
174
|
};
|
|
161
175
|
Arr2.intersperse = (sep) => (data) => {
|
|
162
|
-
if (data.length <= 1)
|
|
176
|
+
if (data.length <= 1) {
|
|
177
|
+
return data;
|
|
178
|
+
}
|
|
163
179
|
const result = [data[0]];
|
|
164
180
|
for (let i = 1; i < data.length; i++) {
|
|
165
181
|
result.push(sep, data[i]);
|
|
@@ -167,7 +183,9 @@ var Arr;
|
|
|
167
183
|
return result;
|
|
168
184
|
};
|
|
169
185
|
Arr2.chunksOf = (n) => (data) => {
|
|
170
|
-
if (n <= 0)
|
|
186
|
+
if (n <= 0) {
|
|
187
|
+
return [];
|
|
188
|
+
}
|
|
171
189
|
const result = [];
|
|
172
190
|
for (let i = 0; i < data.length; i += n) {
|
|
173
191
|
result.push(data.slice(i, i + n));
|
|
@@ -197,7 +215,9 @@ var Arr;
|
|
|
197
215
|
for (let i = 0; i < n; i++) {
|
|
198
216
|
const chunk = f(data[i]);
|
|
199
217
|
const m = chunk.length;
|
|
200
|
-
for (let j = 0; j < m; j++)
|
|
218
|
+
for (let j = 0; j < m; j++) {
|
|
219
|
+
result.push(chunk[j]);
|
|
220
|
+
}
|
|
201
221
|
}
|
|
202
222
|
return result;
|
|
203
223
|
};
|
|
@@ -207,7 +227,9 @@ var Arr;
|
|
|
207
227
|
const result = new Array(n);
|
|
208
228
|
for (let i = 0; i < n; i++) {
|
|
209
229
|
const mapped = f(data[i]);
|
|
210
|
-
if (mapped.kind === "None")
|
|
230
|
+
if (mapped.kind === "None") {
|
|
231
|
+
return Maybe.none();
|
|
232
|
+
}
|
|
211
233
|
result[i] = mapped.value;
|
|
212
234
|
}
|
|
213
235
|
return Maybe.some(result);
|
|
@@ -217,7 +239,9 @@ var Arr;
|
|
|
217
239
|
const result = new Array(n);
|
|
218
240
|
for (let i = 0; i < n; i++) {
|
|
219
241
|
const mapped = f(data[i]);
|
|
220
|
-
if (mapped.kind === "
|
|
242
|
+
if (mapped.kind === "Err") {
|
|
243
|
+
return mapped;
|
|
244
|
+
}
|
|
221
245
|
result[i] = mapped.value;
|
|
222
246
|
}
|
|
223
247
|
return Result.ok(result);
|
|
@@ -230,7 +254,9 @@ var Arr;
|
|
|
230
254
|
const result = [];
|
|
231
255
|
for (const a of data) {
|
|
232
256
|
const r = await Deferred.toPromise(f(a)());
|
|
233
|
-
if (Result.
|
|
257
|
+
if (Result.isErr(r)) {
|
|
258
|
+
return r;
|
|
259
|
+
}
|
|
234
260
|
result.push(r.value);
|
|
235
261
|
}
|
|
236
262
|
return Result.ok(result);
|
|
@@ -240,27 +266,41 @@ var Arr;
|
|
|
240
266
|
Arr2.size = (data) => data.length;
|
|
241
267
|
Arr2.some = (predicate) => (data) => {
|
|
242
268
|
const n = data.length;
|
|
243
|
-
for (let i = 0; i < n; i++)
|
|
269
|
+
for (let i = 0; i < n; i++) {
|
|
270
|
+
if (predicate(data[i])) {
|
|
271
|
+
return true;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
244
274
|
return false;
|
|
245
275
|
};
|
|
246
276
|
Arr2.every = (predicate) => (data) => {
|
|
247
277
|
const n = data.length;
|
|
248
|
-
for (let i = 0; i < n; i++)
|
|
278
|
+
for (let i = 0; i < n; i++) {
|
|
279
|
+
if (!predicate(data[i])) {
|
|
280
|
+
return false;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
249
283
|
return true;
|
|
250
284
|
};
|
|
251
|
-
Arr2.reverse = (data) => [...data].
|
|
285
|
+
Arr2.reverse = (data) => [...data].toReversed();
|
|
252
286
|
Arr2.insertAt = (index, item) => (data) => {
|
|
253
287
|
const i = Math.max(0, Math.min(index, data.length));
|
|
254
288
|
const arr = data;
|
|
255
|
-
if (typeof arr.toSpliced === "function")
|
|
289
|
+
if (typeof arr.toSpliced === "function") {
|
|
290
|
+
return arr.toSpliced(i, 0, item);
|
|
291
|
+
}
|
|
256
292
|
const result = [...data];
|
|
257
293
|
result.splice(i, 0, item);
|
|
258
294
|
return result;
|
|
259
295
|
};
|
|
260
296
|
Arr2.removeAt = (index) => (data) => {
|
|
261
|
-
if (index < 0 || index >= data.length)
|
|
297
|
+
if (index < 0 || index >= data.length) {
|
|
298
|
+
return data;
|
|
299
|
+
}
|
|
262
300
|
const arr = data;
|
|
263
|
-
if (typeof arr.toSpliced === "function")
|
|
301
|
+
if (typeof arr.toSpliced === "function") {
|
|
302
|
+
return arr.toSpliced(index, 1);
|
|
303
|
+
}
|
|
264
304
|
const result = [...data];
|
|
265
305
|
result.splice(index, 1);
|
|
266
306
|
return result;
|
|
@@ -270,14 +310,18 @@ var Arr;
|
|
|
270
310
|
Arr2.takeWhile = (predicate) => (data) => {
|
|
271
311
|
const result = [];
|
|
272
312
|
for (const a of data) {
|
|
273
|
-
if (!predicate(a))
|
|
313
|
+
if (!predicate(a)) {
|
|
314
|
+
break;
|
|
315
|
+
}
|
|
274
316
|
result.push(a);
|
|
275
317
|
}
|
|
276
318
|
return result;
|
|
277
319
|
};
|
|
278
320
|
Arr2.dropWhile = (predicate) => (data) => {
|
|
279
321
|
let i = 0;
|
|
280
|
-
while (i < data.length && predicate(data[i]))
|
|
322
|
+
while (i < data.length && predicate(data[i])) {
|
|
323
|
+
i++;
|
|
324
|
+
}
|
|
281
325
|
return data.slice(i);
|
|
282
326
|
};
|
|
283
327
|
Arr2.scan = (initial, f) => (data) => {
|
|
@@ -308,8 +352,11 @@ var Dict;
|
|
|
308
352
|
for (const item of items) {
|
|
309
353
|
const key = keyFn(item);
|
|
310
354
|
const arr = result.get(key);
|
|
311
|
-
if (arr !== void 0)
|
|
312
|
-
|
|
355
|
+
if (arr !== void 0) {
|
|
356
|
+
arr.push(item);
|
|
357
|
+
} else {
|
|
358
|
+
result.set(key, [item]);
|
|
359
|
+
}
|
|
313
360
|
}
|
|
314
361
|
return result;
|
|
315
362
|
};
|
|
@@ -326,7 +373,9 @@ var Dict;
|
|
|
326
373
|
return result;
|
|
327
374
|
};
|
|
328
375
|
Dict2.remove = (key) => (m) => {
|
|
329
|
-
if (!m.has(key))
|
|
376
|
+
if (!m.has(key)) {
|
|
377
|
+
return m;
|
|
378
|
+
}
|
|
330
379
|
const result = new globalThis.Map(m);
|
|
331
380
|
result.delete(key);
|
|
332
381
|
return result;
|
|
@@ -353,21 +402,27 @@ var Dict;
|
|
|
353
402
|
Dict2.filter = (predicate) => (m) => {
|
|
354
403
|
const result = new globalThis.Map();
|
|
355
404
|
for (const [k, v] of m) {
|
|
356
|
-
if (predicate(v))
|
|
405
|
+
if (predicate(v)) {
|
|
406
|
+
result.set(k, v);
|
|
407
|
+
}
|
|
357
408
|
}
|
|
358
409
|
return result;
|
|
359
410
|
};
|
|
360
411
|
Dict2.filterWithKey = (predicate) => (m) => {
|
|
361
412
|
const result = new globalThis.Map();
|
|
362
413
|
for (const [k, v] of m) {
|
|
363
|
-
if (predicate(k, v))
|
|
414
|
+
if (predicate(k, v)) {
|
|
415
|
+
result.set(k, v);
|
|
416
|
+
}
|
|
364
417
|
}
|
|
365
418
|
return result;
|
|
366
419
|
};
|
|
367
420
|
Dict2.compact = (m) => {
|
|
368
421
|
const result = new globalThis.Map();
|
|
369
422
|
for (const [k, v] of m) {
|
|
370
|
-
if (v.kind === "Some")
|
|
423
|
+
if (v.kind === "Some") {
|
|
424
|
+
result.set(k, v.value);
|
|
425
|
+
}
|
|
371
426
|
}
|
|
372
427
|
return result;
|
|
373
428
|
};
|
|
@@ -375,7 +430,9 @@ var Dict;
|
|
|
375
430
|
const result = new globalThis.Map();
|
|
376
431
|
for (const [key, value] of m) {
|
|
377
432
|
const mapped = f(value);
|
|
378
|
-
if (mapped.kind === "Some")
|
|
433
|
+
if (mapped.kind === "Some") {
|
|
434
|
+
result.set(key, mapped.value);
|
|
435
|
+
}
|
|
379
436
|
}
|
|
380
437
|
return result;
|
|
381
438
|
};
|
|
@@ -389,14 +446,18 @@ var Dict;
|
|
|
389
446
|
Dict2.intersection = (other) => (m) => {
|
|
390
447
|
const result = new globalThis.Map();
|
|
391
448
|
for (const [k, v] of m) {
|
|
392
|
-
if (other.has(k))
|
|
449
|
+
if (other.has(k)) {
|
|
450
|
+
result.set(k, v);
|
|
451
|
+
}
|
|
393
452
|
}
|
|
394
453
|
return result;
|
|
395
454
|
};
|
|
396
455
|
Dict2.difference = (other) => (m) => {
|
|
397
456
|
const result = new globalThis.Map();
|
|
398
457
|
for (const [k, v] of m) {
|
|
399
|
-
if (!other.has(k))
|
|
458
|
+
if (!other.has(k)) {
|
|
459
|
+
result.set(k, v);
|
|
460
|
+
}
|
|
400
461
|
}
|
|
401
462
|
return result;
|
|
402
463
|
};
|
|
@@ -421,7 +482,9 @@ var Dict;
|
|
|
421
482
|
var Num;
|
|
422
483
|
((Num2) => {
|
|
423
484
|
Num2.range = (from, to, step = 1) => {
|
|
424
|
-
if (step <= 0 || from > to)
|
|
485
|
+
if (step <= 0 || from > to) {
|
|
486
|
+
return [];
|
|
487
|
+
}
|
|
425
488
|
const count = Math.floor((to - from) / step) + 1;
|
|
426
489
|
const result = new Array(count);
|
|
427
490
|
for (let i = 0; i < count; i++) {
|
|
@@ -432,7 +495,9 @@ var Num;
|
|
|
432
495
|
Num2.clamp = (min2, max2) => (n) => Math.min(Math.max(n, min2), max2);
|
|
433
496
|
Num2.between = (min2, max2) => (n) => n >= min2 && n <= max2;
|
|
434
497
|
Num2.parse = (s) => {
|
|
435
|
-
if (s.trim() === "")
|
|
498
|
+
if (s.trim() === "") {
|
|
499
|
+
return Maybe.none();
|
|
500
|
+
}
|
|
436
501
|
const n = Number(s);
|
|
437
502
|
return isNaN(n) ? Maybe.none() : Maybe.some(n);
|
|
438
503
|
};
|
|
@@ -448,23 +513,33 @@ var Num;
|
|
|
448
513
|
Num2.remainder = (divisor) => (n) => divisor === 0 ? Maybe.none() : Maybe.some(n % divisor);
|
|
449
514
|
Num2.sum = (ns) => {
|
|
450
515
|
let result = 0;
|
|
451
|
-
for (let i = 0; i < ns.length; i++)
|
|
516
|
+
for (let i = 0; i < ns.length; i++) {
|
|
517
|
+
result += ns[i];
|
|
518
|
+
}
|
|
452
519
|
return result;
|
|
453
520
|
};
|
|
454
521
|
Num2.mean = (ns) => ns.length === 0 ? Maybe.none() : Maybe.some((0, Num2.sum)(ns) / ns.length);
|
|
455
522
|
Num2.min = (ns) => {
|
|
456
|
-
if (ns.length === 0)
|
|
523
|
+
if (ns.length === 0) {
|
|
524
|
+
return Maybe.none();
|
|
525
|
+
}
|
|
457
526
|
let [result] = ns;
|
|
458
527
|
for (let i = 1; i < ns.length; i++) {
|
|
459
|
-
if (ns[i] < result)
|
|
528
|
+
if (ns[i] < result) {
|
|
529
|
+
result = ns[i];
|
|
530
|
+
}
|
|
460
531
|
}
|
|
461
532
|
return Maybe.some(result);
|
|
462
533
|
};
|
|
463
534
|
Num2.max = (ns) => {
|
|
464
|
-
if (ns.length === 0)
|
|
535
|
+
if (ns.length === 0) {
|
|
536
|
+
return Maybe.none();
|
|
537
|
+
}
|
|
465
538
|
let [result] = ns;
|
|
466
539
|
for (let i = 1; i < ns.length; i++) {
|
|
467
|
-
if (ns[i] > result)
|
|
540
|
+
if (ns[i] > result) {
|
|
541
|
+
result = ns[i];
|
|
542
|
+
}
|
|
468
543
|
}
|
|
469
544
|
return Maybe.some(result);
|
|
470
545
|
};
|
|
@@ -476,16 +551,33 @@ var Rec;
|
|
|
476
551
|
Rec2.map = (f) => (data) => {
|
|
477
552
|
const keys2 = Object.keys(data);
|
|
478
553
|
const vals = Object.values(data);
|
|
479
|
-
const result =
|
|
554
|
+
const result = Object.create(Object.getPrototypeOf(data));
|
|
480
555
|
for (let i = 0; i < keys2.length; i++) {
|
|
481
556
|
Object.defineProperty(result, keys2[i], { value: f(vals[i]), writable: true, enumerable: true, configurable: true });
|
|
482
557
|
}
|
|
483
558
|
return result;
|
|
484
559
|
};
|
|
560
|
+
Rec2.filterMap = (f) => (data) => {
|
|
561
|
+
const keys2 = Object.keys(data);
|
|
562
|
+
const vals = Object.values(data);
|
|
563
|
+
const result = Object.create(Object.getPrototypeOf(data));
|
|
564
|
+
for (let i = 0; i < keys2.length; i++) {
|
|
565
|
+
const maybeVal = f(vals[i]);
|
|
566
|
+
if (maybeVal.kind === "Some") {
|
|
567
|
+
Object.defineProperty(result, keys2[i], {
|
|
568
|
+
value: maybeVal.value,
|
|
569
|
+
writable: true,
|
|
570
|
+
enumerable: true,
|
|
571
|
+
configurable: true
|
|
572
|
+
});
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
return result;
|
|
576
|
+
};
|
|
485
577
|
Rec2.mapWithKey = (f) => (data) => {
|
|
486
578
|
const keys2 = Object.keys(data);
|
|
487
579
|
const vals = Object.values(data);
|
|
488
|
-
const result =
|
|
580
|
+
const result = Object.create(Object.getPrototypeOf(data));
|
|
489
581
|
for (let i = 0; i < keys2.length; i++) {
|
|
490
582
|
Object.defineProperty(result, keys2[i], {
|
|
491
583
|
value: f(keys2[i], vals[i]),
|
|
@@ -497,10 +589,12 @@ var Rec;
|
|
|
497
589
|
return result;
|
|
498
590
|
};
|
|
499
591
|
Rec2.filter = (predicate) => (data) => {
|
|
500
|
-
const
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
592
|
+
const keys2 = Object.keys(data);
|
|
593
|
+
const vals = Object.values(data);
|
|
594
|
+
const result = Object.create(Object.getPrototypeOf(data));
|
|
595
|
+
for (let i = 0; i < keys2.length; i++) {
|
|
596
|
+
if (predicate(vals[i])) {
|
|
597
|
+
Object.defineProperty(result, keys2[i], { value: vals[i], writable: true, enumerable: true, configurable: true });
|
|
504
598
|
}
|
|
505
599
|
}
|
|
506
600
|
return result;
|
|
@@ -633,8 +727,8 @@ var Str;
|
|
|
633
727
|
Str2.parseJson = (s) => {
|
|
634
728
|
try {
|
|
635
729
|
return Result.ok(JSON.parse(s));
|
|
636
|
-
} catch (
|
|
637
|
-
return Result.error
|
|
730
|
+
} catch (error) {
|
|
731
|
+
return Result.err(error);
|
|
638
732
|
}
|
|
639
733
|
};
|
|
640
734
|
})(Str || (Str = {}));
|
|
@@ -650,20 +744,28 @@ var Uniq;
|
|
|
650
744
|
Uniq2.isEmpty = (s) => s.size === 0;
|
|
651
745
|
Uniq2.isSubsetOf = (other) => (s) => {
|
|
652
746
|
const set = s;
|
|
653
|
-
if (typeof set.isSubsetOf === "function")
|
|
747
|
+
if (typeof set.isSubsetOf === "function") {
|
|
748
|
+
return set.isSubsetOf(other);
|
|
749
|
+
}
|
|
654
750
|
for (const item of s) {
|
|
655
|
-
if (!other.has(item))
|
|
751
|
+
if (!other.has(item)) {
|
|
752
|
+
return false;
|
|
753
|
+
}
|
|
656
754
|
}
|
|
657
755
|
return true;
|
|
658
756
|
};
|
|
659
757
|
Uniq2.insert = (item) => (s) => {
|
|
660
|
-
if (s.has(item))
|
|
758
|
+
if (s.has(item)) {
|
|
759
|
+
return s;
|
|
760
|
+
}
|
|
661
761
|
const result = new globalThis.Set(s);
|
|
662
762
|
result.add(item);
|
|
663
763
|
return result;
|
|
664
764
|
};
|
|
665
765
|
Uniq2.remove = (item) => (s) => {
|
|
666
|
-
if (!s.has(item))
|
|
766
|
+
if (!s.has(item)) {
|
|
767
|
+
return s;
|
|
768
|
+
}
|
|
667
769
|
const result = new globalThis.Set(s);
|
|
668
770
|
result.delete(item);
|
|
669
771
|
return result;
|
|
@@ -678,29 +780,47 @@ var Uniq;
|
|
|
678
780
|
Uniq2.filter = (predicate) => (s) => {
|
|
679
781
|
const result = new globalThis.Set();
|
|
680
782
|
for (const item of s) {
|
|
681
|
-
if (predicate(item))
|
|
783
|
+
if (predicate(item)) {
|
|
784
|
+
result.add(item);
|
|
785
|
+
}
|
|
682
786
|
}
|
|
683
787
|
return result;
|
|
684
788
|
};
|
|
685
789
|
Uniq2.union = (other) => (s) => {
|
|
686
790
|
const set = s;
|
|
687
|
-
if (typeof set.union === "function")
|
|
791
|
+
if (typeof set.union === "function") {
|
|
792
|
+
return set.union(other);
|
|
793
|
+
}
|
|
688
794
|
const result = new globalThis.Set(s);
|
|
689
|
-
for (const item of other)
|
|
795
|
+
for (const item of other) {
|
|
796
|
+
result.add(item);
|
|
797
|
+
}
|
|
690
798
|
return result;
|
|
691
799
|
};
|
|
692
800
|
Uniq2.intersection = (other) => (s) => {
|
|
693
801
|
const set = s;
|
|
694
|
-
if (typeof set.intersection === "function")
|
|
802
|
+
if (typeof set.intersection === "function") {
|
|
803
|
+
return set.intersection(other);
|
|
804
|
+
}
|
|
695
805
|
const result = new globalThis.Set();
|
|
696
|
-
for (const item of s)
|
|
806
|
+
for (const item of s) {
|
|
807
|
+
if (other.has(item)) {
|
|
808
|
+
result.add(item);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
697
811
|
return result;
|
|
698
812
|
};
|
|
699
813
|
Uniq2.difference = (other) => (s) => {
|
|
700
814
|
const set = s;
|
|
701
|
-
if (typeof set.difference === "function")
|
|
815
|
+
if (typeof set.difference === "function") {
|
|
816
|
+
return set.difference(other);
|
|
817
|
+
}
|
|
702
818
|
const result = new globalThis.Set();
|
|
703
|
-
for (const item of s)
|
|
819
|
+
for (const item of s) {
|
|
820
|
+
if (!other.has(item)) {
|
|
821
|
+
result.add(item);
|
|
822
|
+
}
|
|
823
|
+
}
|
|
704
824
|
return result;
|
|
705
825
|
};
|
|
706
826
|
Uniq2.reduce = (init, f) => (s) => {
|
package/dist/composition.d.mts
CHANGED
|
@@ -144,6 +144,7 @@ declare const flip: <A, B, C>(f: (a: A) => (b: B) => C) => (b: B) => (a: A) => C
|
|
|
144
144
|
* processUser({ name: "Bob" }); // "Hello, BOB!"
|
|
145
145
|
*
|
|
146
146
|
* // Compare with pipe (one-time use):
|
|
147
|
+
* const user: User = { name: "Alice" };
|
|
147
148
|
* pipe(
|
|
148
149
|
* user,
|
|
149
150
|
* u => u.name,
|
|
@@ -363,7 +364,7 @@ declare const on: <A, B, C>(f: (b1: B, b2: B) => C, g: (a: A) => B) => (a: A, b:
|
|
|
363
364
|
* @example
|
|
364
365
|
* ```ts
|
|
365
366
|
* // Basic usage
|
|
366
|
-
* const
|
|
367
|
+
* const doubledPlusOne = pipe(
|
|
367
368
|
* 5,
|
|
368
369
|
* n => n * 2,
|
|
369
370
|
* n => n + 1
|
|
@@ -374,15 +375,15 @@ declare const on: <A, B, C>(f: (b1: B, b2: B) => C, g: (a: A) => B) => (a: A, b:
|
|
|
374
375
|
* Maybe.some("Alice"),
|
|
375
376
|
* Maybe.map(name => name.toUpperCase()),
|
|
376
377
|
* Maybe.map(name => `Hello, ${name}!`),
|
|
377
|
-
* Maybe.getOrElse("Hello!")
|
|
378
|
+
* Maybe.getOrElse(() => "Hello!")
|
|
378
379
|
* ); // "Hello, ALICE!"
|
|
379
380
|
*
|
|
380
381
|
* // Error handling with Result
|
|
381
|
-
* const
|
|
382
|
-
* Result.tryCatch(() => JSON.parse(
|
|
383
|
-
* Result.map(data => data.value),
|
|
384
|
-
* Result.getOrElse(null)
|
|
385
|
-
* );
|
|
382
|
+
* const parsed = pipe(
|
|
383
|
+
* Result.tryCatch(() => JSON.parse('{"value": 42}'), () => "Invalid JSON"),
|
|
384
|
+
* Result.map((data: { value: number }) => data.value),
|
|
385
|
+
* Result.getOrElse(() => null)
|
|
386
|
+
* ); // 42
|
|
386
387
|
* ```
|
|
387
388
|
*
|
|
388
389
|
* @see {@link flow} for creating reusable pipelines without an initial value
|
package/dist/composition.d.ts
CHANGED
|
@@ -144,6 +144,7 @@ declare const flip: <A, B, C>(f: (a: A) => (b: B) => C) => (b: B) => (a: A) => C
|
|
|
144
144
|
* processUser({ name: "Bob" }); // "Hello, BOB!"
|
|
145
145
|
*
|
|
146
146
|
* // Compare with pipe (one-time use):
|
|
147
|
+
* const user: User = { name: "Alice" };
|
|
147
148
|
* pipe(
|
|
148
149
|
* user,
|
|
149
150
|
* u => u.name,
|
|
@@ -363,7 +364,7 @@ declare const on: <A, B, C>(f: (b1: B, b2: B) => C, g: (a: A) => B) => (a: A, b:
|
|
|
363
364
|
* @example
|
|
364
365
|
* ```ts
|
|
365
366
|
* // Basic usage
|
|
366
|
-
* const
|
|
367
|
+
* const doubledPlusOne = pipe(
|
|
367
368
|
* 5,
|
|
368
369
|
* n => n * 2,
|
|
369
370
|
* n => n + 1
|
|
@@ -374,15 +375,15 @@ declare const on: <A, B, C>(f: (b1: B, b2: B) => C, g: (a: A) => B) => (a: A, b:
|
|
|
374
375
|
* Maybe.some("Alice"),
|
|
375
376
|
* Maybe.map(name => name.toUpperCase()),
|
|
376
377
|
* Maybe.map(name => `Hello, ${name}!`),
|
|
377
|
-
* Maybe.getOrElse("Hello!")
|
|
378
|
+
* Maybe.getOrElse(() => "Hello!")
|
|
378
379
|
* ); // "Hello, ALICE!"
|
|
379
380
|
*
|
|
380
381
|
* // Error handling with Result
|
|
381
|
-
* const
|
|
382
|
-
* Result.tryCatch(() => JSON.parse(
|
|
383
|
-
* Result.map(data => data.value),
|
|
384
|
-
* Result.getOrElse(null)
|
|
385
|
-
* );
|
|
382
|
+
* const parsed = pipe(
|
|
383
|
+
* Result.tryCatch(() => JSON.parse('{"value": 42}'), () => "Invalid JSON"),
|
|
384
|
+
* Result.map((data: { value: number }) => data.value),
|
|
385
|
+
* Result.getOrElse(() => null)
|
|
386
|
+
* ); // 42
|
|
386
387
|
* ```
|
|
387
388
|
*
|
|
388
389
|
* @see {@link flow} for creating reusable pipelines without an initial value
|