@nlozgachev/pipelined 0.32.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.
@@ -3,7 +3,7 @@ import {
3
3
  Maybe,
4
4
  Result,
5
5
  Task
6
- } from "./chunk-TK5ZCGP2.mjs";
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 >= 0 ? Maybe.some(data[idx]) : Maybe.none();
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])) return Maybe.some(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 >= 0 ? Maybe.some(idx) : Maybe.none();
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++) result[i] = f(data[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++) result[i] = f(i, data[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])) result.push(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") result.push(mapped.value);
64
+ if (mapped.kind === "Some") {
65
+ result.push(mapped.value);
66
+ }
57
67
  }
58
68
  return result;
59
69
  };
@@ -65,18 +75,52 @@ var Arr;
65
75
  }
66
76
  return [pass, fail];
67
77
  };
78
+ Arr2.compact = (data) => {
79
+ const result = [];
80
+ for (const item of data) {
81
+ if (item.kind === "Some") {
82
+ result.push(item.value);
83
+ }
84
+ }
85
+ return result;
86
+ };
87
+ Arr2.separate = (data) => {
88
+ const errors = [];
89
+ const successes = [];
90
+ for (const item of data) {
91
+ if (item.kind === "Ok") {
92
+ successes.push(item.value);
93
+ } else {
94
+ errors.push(item.error);
95
+ }
96
+ }
97
+ return [errors, successes];
98
+ };
99
+ Arr2.partitionMap = (f) => (data) => {
100
+ const errors = [];
101
+ const successes = [];
102
+ for (const item of data) {
103
+ const mapped = f(item);
104
+ if (mapped.kind === "Ok") {
105
+ successes.push(mapped.value);
106
+ } else {
107
+ errors.push(mapped.error);
108
+ }
109
+ }
110
+ return [errors, successes];
111
+ };
68
112
  Arr2.groupBy = (f) => (data) => {
69
113
  const result = {};
70
114
  for (const a of data) {
71
115
  const key = f(a);
72
- if (!result[key]) result[key] = [];
116
+ if (!result[key]) {
117
+ result[key] = [];
118
+ }
73
119
  result[key].push(a);
74
120
  }
75
121
  return result;
76
122
  };
77
- Arr2.uniq = (data) => [
78
- ...new Set(data)
79
- ];
123
+ Arr2.uniq = (data) => [...new Set(data)];
80
124
  Arr2.uniqBy = (f) => (data) => {
81
125
  const seen = /* @__PURE__ */ new Set();
82
126
  const result = [];
@@ -100,12 +144,16 @@ var Arr;
100
144
  };
101
145
  Arr2.sortBy = (compare) => (data) => {
102
146
  const arr = data;
103
- if (typeof arr.toSorted === "function") return arr.toSorted(compare);
104
- return [...data].sort(compare);
147
+ if (typeof arr.toSorted === "function") {
148
+ return arr.toSorted(compare);
149
+ }
150
+ return [...data].toSorted(compare);
105
151
  };
106
152
  Arr2.sortWith = (ord) => (data) => {
107
153
  const arr = data;
108
- if (typeof arr.toSorted === "function") return arr.toSorted(ord);
154
+ if (typeof arr.toSorted === "function") {
155
+ return arr.toSorted(ord);
156
+ }
109
157
  return [...data].sort(ord);
110
158
  };
111
159
  Arr2.zip = (other) => (data) => {
@@ -125,7 +173,9 @@ var Arr;
125
173
  return result;
126
174
  };
127
175
  Arr2.intersperse = (sep) => (data) => {
128
- if (data.length <= 1) return data;
176
+ if (data.length <= 1) {
177
+ return data;
178
+ }
129
179
  const result = [data[0]];
130
180
  for (let i = 1; i < data.length; i++) {
131
181
  result.push(sep, data[i]);
@@ -133,7 +183,9 @@ var Arr;
133
183
  return result;
134
184
  };
135
185
  Arr2.chunksOf = (n) => (data) => {
136
- if (n <= 0) return [];
186
+ if (n <= 0) {
187
+ return [];
188
+ }
137
189
  const result = [];
138
190
  for (let i = 0; i < data.length; i += n) {
139
191
  result.push(data.slice(i, i + n));
@@ -163,7 +215,9 @@ var Arr;
163
215
  for (let i = 0; i < n; i++) {
164
216
  const chunk = f(data[i]);
165
217
  const m = chunk.length;
166
- for (let j = 0; j < m; j++) result.push(chunk[j]);
218
+ for (let j = 0; j < m; j++) {
219
+ result.push(chunk[j]);
220
+ }
167
221
  }
168
222
  return result;
169
223
  };
@@ -173,7 +227,9 @@ var Arr;
173
227
  const result = new Array(n);
174
228
  for (let i = 0; i < n; i++) {
175
229
  const mapped = f(data[i]);
176
- if (mapped.kind === "None") return Maybe.none();
230
+ if (mapped.kind === "None") {
231
+ return Maybe.none();
232
+ }
177
233
  result[i] = mapped.value;
178
234
  }
179
235
  return Maybe.some(result);
@@ -183,7 +239,9 @@ var Arr;
183
239
  const result = new Array(n);
184
240
  for (let i = 0; i < n; i++) {
185
241
  const mapped = f(data[i]);
186
- if (mapped.kind === "Error") return mapped;
242
+ if (mapped.kind === "Err") {
243
+ return mapped;
244
+ }
187
245
  result[i] = mapped.value;
188
246
  }
189
247
  return Result.ok(result);
@@ -196,7 +254,9 @@ var Arr;
196
254
  const result = [];
197
255
  for (const a of data) {
198
256
  const r = await Deferred.toPromise(f(a)());
199
- if (Result.isError(r)) return r;
257
+ if (Result.isErr(r)) {
258
+ return r;
259
+ }
200
260
  result.push(r.value);
201
261
  }
202
262
  return Result.ok(result);
@@ -206,27 +266,41 @@ var Arr;
206
266
  Arr2.size = (data) => data.length;
207
267
  Arr2.some = (predicate) => (data) => {
208
268
  const n = data.length;
209
- for (let i = 0; i < n; i++) if (predicate(data[i])) return true;
269
+ for (let i = 0; i < n; i++) {
270
+ if (predicate(data[i])) {
271
+ return true;
272
+ }
273
+ }
210
274
  return false;
211
275
  };
212
276
  Arr2.every = (predicate) => (data) => {
213
277
  const n = data.length;
214
- for (let i = 0; i < n; i++) if (!predicate(data[i])) return false;
278
+ for (let i = 0; i < n; i++) {
279
+ if (!predicate(data[i])) {
280
+ return false;
281
+ }
282
+ }
215
283
  return true;
216
284
  };
217
- Arr2.reverse = (data) => [...data].reverse();
285
+ Arr2.reverse = (data) => [...data].toReversed();
218
286
  Arr2.insertAt = (index, item) => (data) => {
219
287
  const i = Math.max(0, Math.min(index, data.length));
220
288
  const arr = data;
221
- if (typeof arr.toSpliced === "function") return arr.toSpliced(i, 0, item);
289
+ if (typeof arr.toSpliced === "function") {
290
+ return arr.toSpliced(i, 0, item);
291
+ }
222
292
  const result = [...data];
223
293
  result.splice(i, 0, item);
224
294
  return result;
225
295
  };
226
296
  Arr2.removeAt = (index) => (data) => {
227
- if (index < 0 || index >= data.length) return data;
297
+ if (index < 0 || index >= data.length) {
298
+ return data;
299
+ }
228
300
  const arr = data;
229
- if (typeof arr.toSpliced === "function") return arr.toSpliced(index, 1);
301
+ if (typeof arr.toSpliced === "function") {
302
+ return arr.toSpliced(index, 1);
303
+ }
230
304
  const result = [...data];
231
305
  result.splice(index, 1);
232
306
  return result;
@@ -236,14 +310,18 @@ var Arr;
236
310
  Arr2.takeWhile = (predicate) => (data) => {
237
311
  const result = [];
238
312
  for (const a of data) {
239
- if (!predicate(a)) break;
313
+ if (!predicate(a)) {
314
+ break;
315
+ }
240
316
  result.push(a);
241
317
  }
242
318
  return result;
243
319
  };
244
320
  Arr2.dropWhile = (predicate) => (data) => {
245
321
  let i = 0;
246
- while (i < data.length && predicate(data[i])) i++;
322
+ while (i < data.length && predicate(data[i])) {
323
+ i++;
324
+ }
247
325
  return data.slice(i);
248
326
  };
249
327
  Arr2.scan = (initial, f) => (data) => {
@@ -274,8 +352,11 @@ var Dict;
274
352
  for (const item of items) {
275
353
  const key = keyFn(item);
276
354
  const arr = result.get(key);
277
- if (arr !== void 0) arr.push(item);
278
- else result.set(key, [item]);
355
+ if (arr !== void 0) {
356
+ arr.push(item);
357
+ } else {
358
+ result.set(key, [item]);
359
+ }
279
360
  }
280
361
  return result;
281
362
  };
@@ -292,7 +373,9 @@ var Dict;
292
373
  return result;
293
374
  };
294
375
  Dict2.remove = (key) => (m) => {
295
- if (!m.has(key)) return m;
376
+ if (!m.has(key)) {
377
+ return m;
378
+ }
296
379
  const result = new globalThis.Map(m);
297
380
  result.delete(key);
298
381
  return result;
@@ -319,21 +402,27 @@ var Dict;
319
402
  Dict2.filter = (predicate) => (m) => {
320
403
  const result = new globalThis.Map();
321
404
  for (const [k, v] of m) {
322
- if (predicate(v)) result.set(k, v);
405
+ if (predicate(v)) {
406
+ result.set(k, v);
407
+ }
323
408
  }
324
409
  return result;
325
410
  };
326
411
  Dict2.filterWithKey = (predicate) => (m) => {
327
412
  const result = new globalThis.Map();
328
413
  for (const [k, v] of m) {
329
- if (predicate(k, v)) result.set(k, v);
414
+ if (predicate(k, v)) {
415
+ result.set(k, v);
416
+ }
330
417
  }
331
418
  return result;
332
419
  };
333
420
  Dict2.compact = (m) => {
334
421
  const result = new globalThis.Map();
335
422
  for (const [k, v] of m) {
336
- if (v.kind === "Some") result.set(k, v.value);
423
+ if (v.kind === "Some") {
424
+ result.set(k, v.value);
425
+ }
337
426
  }
338
427
  return result;
339
428
  };
@@ -341,7 +430,9 @@ var Dict;
341
430
  const result = new globalThis.Map();
342
431
  for (const [key, value] of m) {
343
432
  const mapped = f(value);
344
- if (mapped.kind === "Some") result.set(key, mapped.value);
433
+ if (mapped.kind === "Some") {
434
+ result.set(key, mapped.value);
435
+ }
345
436
  }
346
437
  return result;
347
438
  };
@@ -355,14 +446,18 @@ var Dict;
355
446
  Dict2.intersection = (other) => (m) => {
356
447
  const result = new globalThis.Map();
357
448
  for (const [k, v] of m) {
358
- if (other.has(k)) result.set(k, v);
449
+ if (other.has(k)) {
450
+ result.set(k, v);
451
+ }
359
452
  }
360
453
  return result;
361
454
  };
362
455
  Dict2.difference = (other) => (m) => {
363
456
  const result = new globalThis.Map();
364
457
  for (const [k, v] of m) {
365
- if (!other.has(k)) result.set(k, v);
458
+ if (!other.has(k)) {
459
+ result.set(k, v);
460
+ }
366
461
  }
367
462
  return result;
368
463
  };
@@ -387,7 +482,9 @@ var Dict;
387
482
  var Num;
388
483
  ((Num2) => {
389
484
  Num2.range = (from, to, step = 1) => {
390
- if (step <= 0 || from > to) return [];
485
+ if (step <= 0 || from > to) {
486
+ return [];
487
+ }
391
488
  const count = Math.floor((to - from) / step) + 1;
392
489
  const result = new Array(count);
393
490
  for (let i = 0; i < count; i++) {
@@ -398,7 +495,9 @@ var Num;
398
495
  Num2.clamp = (min2, max2) => (n) => Math.min(Math.max(n, min2), max2);
399
496
  Num2.between = (min2, max2) => (n) => n >= min2 && n <= max2;
400
497
  Num2.parse = (s) => {
401
- if (s.trim() === "") return Maybe.none();
498
+ if (s.trim() === "") {
499
+ return Maybe.none();
500
+ }
402
501
  const n = Number(s);
403
502
  return isNaN(n) ? Maybe.none() : Maybe.some(n);
404
503
  };
@@ -414,23 +513,33 @@ var Num;
414
513
  Num2.remainder = (divisor) => (n) => divisor === 0 ? Maybe.none() : Maybe.some(n % divisor);
415
514
  Num2.sum = (ns) => {
416
515
  let result = 0;
417
- for (let i = 0; i < ns.length; i++) result += ns[i];
516
+ for (let i = 0; i < ns.length; i++) {
517
+ result += ns[i];
518
+ }
418
519
  return result;
419
520
  };
420
521
  Num2.mean = (ns) => ns.length === 0 ? Maybe.none() : Maybe.some((0, Num2.sum)(ns) / ns.length);
421
522
  Num2.min = (ns) => {
422
- if (ns.length === 0) return Maybe.none();
523
+ if (ns.length === 0) {
524
+ return Maybe.none();
525
+ }
423
526
  let [result] = ns;
424
527
  for (let i = 1; i < ns.length; i++) {
425
- if (ns[i] < result) result = ns[i];
528
+ if (ns[i] < result) {
529
+ result = ns[i];
530
+ }
426
531
  }
427
532
  return Maybe.some(result);
428
533
  };
429
534
  Num2.max = (ns) => {
430
- if (ns.length === 0) return Maybe.none();
535
+ if (ns.length === 0) {
536
+ return Maybe.none();
537
+ }
431
538
  let [result] = ns;
432
539
  for (let i = 1; i < ns.length; i++) {
433
- if (ns[i] > result) result = ns[i];
540
+ if (ns[i] > result) {
541
+ result = ns[i];
542
+ }
434
543
  }
435
544
  return Maybe.some(result);
436
545
  };
@@ -442,16 +551,33 @@ var Rec;
442
551
  Rec2.map = (f) => (data) => {
443
552
  const keys2 = Object.keys(data);
444
553
  const vals = Object.values(data);
445
- const result = {};
554
+ const result = Object.create(Object.getPrototypeOf(data));
446
555
  for (let i = 0; i < keys2.length; i++) {
447
556
  Object.defineProperty(result, keys2[i], { value: f(vals[i]), writable: true, enumerable: true, configurable: true });
448
557
  }
449
558
  return result;
450
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
+ };
451
577
  Rec2.mapWithKey = (f) => (data) => {
452
578
  const keys2 = Object.keys(data);
453
579
  const vals = Object.values(data);
454
- const result = {};
580
+ const result = Object.create(Object.getPrototypeOf(data));
455
581
  for (let i = 0; i < keys2.length; i++) {
456
582
  Object.defineProperty(result, keys2[i], {
457
583
  value: f(keys2[i], vals[i]),
@@ -463,10 +589,12 @@ var Rec;
463
589
  return result;
464
590
  };
465
591
  Rec2.filter = (predicate) => (data) => {
466
- const result = {};
467
- for (const [k, v] of Object.entries(data)) {
468
- if (predicate(v)) {
469
- Object.defineProperty(result, k, { value: v, writable: true, enumerable: true, configurable: true });
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 });
470
598
  }
471
599
  }
472
600
  return result;
@@ -596,6 +724,13 @@ var Str;
596
724
  return isNaN(n) ? Maybe.none() : Maybe.some(n);
597
725
  }
598
726
  };
727
+ Str2.parseJson = (s) => {
728
+ try {
729
+ return Result.ok(JSON.parse(s));
730
+ } catch (error) {
731
+ return Result.err(error);
732
+ }
733
+ };
599
734
  })(Str || (Str = {}));
600
735
 
601
736
  // src/Utils/Uniq.ts
@@ -609,20 +744,28 @@ var Uniq;
609
744
  Uniq2.isEmpty = (s) => s.size === 0;
610
745
  Uniq2.isSubsetOf = (other) => (s) => {
611
746
  const set = s;
612
- if (typeof set.isSubsetOf === "function") return set.isSubsetOf(other);
747
+ if (typeof set.isSubsetOf === "function") {
748
+ return set.isSubsetOf(other);
749
+ }
613
750
  for (const item of s) {
614
- if (!other.has(item)) return false;
751
+ if (!other.has(item)) {
752
+ return false;
753
+ }
615
754
  }
616
755
  return true;
617
756
  };
618
757
  Uniq2.insert = (item) => (s) => {
619
- if (s.has(item)) return s;
758
+ if (s.has(item)) {
759
+ return s;
760
+ }
620
761
  const result = new globalThis.Set(s);
621
762
  result.add(item);
622
763
  return result;
623
764
  };
624
765
  Uniq2.remove = (item) => (s) => {
625
- if (!s.has(item)) return s;
766
+ if (!s.has(item)) {
767
+ return s;
768
+ }
626
769
  const result = new globalThis.Set(s);
627
770
  result.delete(item);
628
771
  return result;
@@ -637,29 +780,47 @@ var Uniq;
637
780
  Uniq2.filter = (predicate) => (s) => {
638
781
  const result = new globalThis.Set();
639
782
  for (const item of s) {
640
- if (predicate(item)) result.add(item);
783
+ if (predicate(item)) {
784
+ result.add(item);
785
+ }
641
786
  }
642
787
  return result;
643
788
  };
644
789
  Uniq2.union = (other) => (s) => {
645
790
  const set = s;
646
- if (typeof set.union === "function") return set.union(other);
791
+ if (typeof set.union === "function") {
792
+ return set.union(other);
793
+ }
647
794
  const result = new globalThis.Set(s);
648
- for (const item of other) result.add(item);
795
+ for (const item of other) {
796
+ result.add(item);
797
+ }
649
798
  return result;
650
799
  };
651
800
  Uniq2.intersection = (other) => (s) => {
652
801
  const set = s;
653
- if (typeof set.intersection === "function") return set.intersection(other);
802
+ if (typeof set.intersection === "function") {
803
+ return set.intersection(other);
804
+ }
654
805
  const result = new globalThis.Set();
655
- for (const item of s) if (other.has(item)) result.add(item);
806
+ for (const item of s) {
807
+ if (other.has(item)) {
808
+ result.add(item);
809
+ }
810
+ }
656
811
  return result;
657
812
  };
658
813
  Uniq2.difference = (other) => (s) => {
659
814
  const set = s;
660
- if (typeof set.difference === "function") return set.difference(other);
815
+ if (typeof set.difference === "function") {
816
+ return set.difference(other);
817
+ }
661
818
  const result = new globalThis.Set();
662
- for (const item of s) if (!other.has(item)) result.add(item);
819
+ for (const item of s) {
820
+ if (!other.has(item)) {
821
+ result.add(item);
822
+ }
823
+ }
663
824
  return result;
664
825
  };
665
826
  Uniq2.reduce = (init, f) => (s) => {
File without changes
@@ -0,0 +1,29 @@
1
+ // src/Types/Brand.ts
2
+ var Brand;
3
+ ((Brand2) => {
4
+ Brand2.wrap = () => (value) => value;
5
+ Brand2.unwrap = (branded) => branded;
6
+ })(Brand || (Brand = {}));
7
+
8
+ // src/Types/Duration.ts
9
+ var Duration;
10
+ ((Duration2) => {
11
+ const wrap = Brand.wrap();
12
+ Duration2.milliseconds = (ms) => wrap(ms);
13
+ Duration2.seconds = (s) => wrap(s * 1e3);
14
+ Duration2.minutes = (m) => wrap(m * 60 * 1e3);
15
+ Duration2.hours = (h) => wrap(h * 60 * 60 * 1e3);
16
+ Duration2.days = (d) => wrap(d * 24 * 60 * 60 * 1e3);
17
+ Duration2.toMilliseconds = (d) => Brand.unwrap(d);
18
+ Duration2.toSeconds = (d) => Brand.unwrap(d) / 1e3;
19
+ Duration2.toMinutes = (d) => Brand.unwrap(d) / (60 * 1e3);
20
+ Duration2.toHours = (d) => Brand.unwrap(d) / (60 * 60 * 1e3);
21
+ Duration2.toDays = (d) => Brand.unwrap(d) / (24 * 60 * 60 * 1e3);
22
+ Duration2.add = (other) => (self) => wrap(Brand.unwrap(self) + Brand.unwrap(other));
23
+ Duration2.subtract = (other) => (self) => wrap(Brand.unwrap(self) - Brand.unwrap(other));
24
+ })(Duration || (Duration = {}));
25
+
26
+ export {
27
+ Brand,
28
+ Duration
29
+ };
@@ -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 result = pipe(
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 result = pipe(
382
- * Result.tryCatch(() => JSON.parse(input), e => "Invalid JSON"),
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
@@ -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 result = pipe(
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 result = pipe(
382
- * Result.tryCatch(() => JSON.parse(input), e => "Invalid JSON"),
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