@nlozgachev/pipelined 0.63.0 → 0.64.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/dist/data.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { a as NonEmptyArr, N as NonEmpty } from './InternalTypes-GFn4RTwD.cjs';
2
- import { M as Maybe, R as Result, E as Equality, b as Ordering, T as Task } from './Validation-KFUpea_k.cjs';
2
+ import { M as Maybe, R as Result, E as Equality, b as Ordering, T as Task } from './Task-C_goFYQ1.cjs';
3
3
  import { B as Brand } from './Duration-DeyxG6VQ.cjs';
4
4
  import './types.cjs';
5
5
 
@@ -24,7 +24,7 @@ declare namespace ArrTaskResult {
24
24
  * )(); // Deferred<Err("non-positive")>
25
25
  * ```
26
26
  */
27
- const traverse: <E, A, B>(f: (a: A) => Task<Result<E, B>>) => (data: readonly A[]) => Task<Result<E, readonly B[]>>;
27
+ const traverse: <E, A, B>(f: (a: A) => Task.Result<E, B>) => (data: readonly A[]) => Task.Result<E, readonly B[]>;
28
28
  /**
29
29
  * Collects an array of Task.Results into a Task.Result of array.
30
30
  * Returns the first Err if any element is Err, runs sequentially.
@@ -37,7 +37,7 @@ declare namespace ArrTaskResult {
37
37
  * )(); // Deferred<Ok([1, 2])>
38
38
  * ```
39
39
  */
40
- const sequence: <E, A>(data: readonly Task<Result<E, A>>[]) => Task<Result<E, readonly A[]>>;
40
+ const sequence: <E, A>(data: readonly Task.Result<E, A>[]) => Task.Result<E, readonly A[]>;
41
41
  }
42
42
  interface TaskTraverse {
43
43
  <A, B>(f: (a: A) => Task<B>): (data: readonly A[]) => Task<readonly B[]>;
@@ -155,6 +155,60 @@ declare namespace Arr {
155
155
  * ```
156
156
  */
157
157
  declare const BigNum: {
158
+ is: {
159
+ /**
160
+ * Returns `true` when the bigint is equal to zero (`0n`).
161
+ *
162
+ * @example
163
+ * ```ts
164
+ * BigNum.is.zero(0n); // true
165
+ * BigNum.is.zero(5n); // false
166
+ * ```
167
+ */
168
+ zero: (b: bigint) => boolean;
169
+ /**
170
+ * Returns `true` when the bigint is an even integer.
171
+ *
172
+ * @example
173
+ * ```ts
174
+ * BigNum.is.even(4n); // true
175
+ * BigNum.is.even(3n); // false
176
+ * ```
177
+ */
178
+ even: (b: bigint) => boolean;
179
+ /**
180
+ * Returns `true` when the bigint is an odd integer.
181
+ *
182
+ * @example
183
+ * ```ts
184
+ * BigNum.is.odd(3n); // true
185
+ * BigNum.is.odd(4n); // false
186
+ * ```
187
+ */
188
+ odd: (b: bigint) => boolean;
189
+ /**
190
+ * Returns `true` when the bigint is strictly greater than zero (`0n`).
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * BigNum.is.positive(5n); // true
195
+ * BigNum.is.positive(0n); // false
196
+ * BigNum.is.positive(-5n); // false
197
+ * ```
198
+ */
199
+ positive: (b: bigint) => boolean;
200
+ /**
201
+ * Returns `true` when the bigint is strictly less than zero (`0n`).
202
+ *
203
+ * @example
204
+ * ```ts
205
+ * BigNum.is.negative(-5n); // true
206
+ * BigNum.is.negative(0n); // false
207
+ * BigNum.is.negative(5n); // false
208
+ * ```
209
+ */
210
+ negative: (b: bigint) => boolean;
211
+ };
158
212
  from: {
159
213
  /**
160
214
  * Safely parses a string into a `bigint`. Returns `None` if parsing fails.
@@ -283,6 +337,293 @@ declare const BigNum: {
283
337
  max: (b: bigint) => (a: bigint) => bigint;
284
338
  };
285
339
 
340
+ type BoolMatchCases<A, B> = {
341
+ readonly true: () => A;
342
+ readonly false: () => B;
343
+ };
344
+ declare const Bool: {
345
+ is: {
346
+ /**
347
+ * Type guard — checks if a value is a primitive boolean.
348
+ *
349
+ * @example
350
+ * ```ts
351
+ * Bool.is.boolean(true); // true
352
+ * Bool.is.boolean(false); // true
353
+ * Bool.is.boolean("true"); // false
354
+ * Bool.is.boolean(null); // false
355
+ * ```
356
+ */
357
+ boolean: (u: unknown) => u is boolean;
358
+ /**
359
+ * Narrowing guard — checks if a value is strictly `true`.
360
+ *
361
+ * @example
362
+ * ```ts
363
+ * Bool.is.true(true); // true
364
+ * Bool.is.true(false); // false
365
+ * ```
366
+ */
367
+ true: (u: unknown) => u is true;
368
+ /**
369
+ * Narrowing guard — checks if a value is strictly `false`.
370
+ *
371
+ * @example
372
+ * ```ts
373
+ * Bool.is.false(false); // true
374
+ * Bool.is.false(true); // false
375
+ * ```
376
+ */
377
+ false: (u: unknown) => u is false;
378
+ /**
379
+ * Type guard — checks if a value is truthy (not `false`, `0`, `0n`, `""`, `null`, `undefined`, or `NaN`).
380
+ *
381
+ * @example
382
+ * ```ts
383
+ * Bool.is.truthy("hello"); // true
384
+ * Bool.is.truthy(42); // true
385
+ * Bool.is.truthy(0); // false
386
+ * Bool.is.truthy(null); // false
387
+ * ```
388
+ */
389
+ truthy: <T>(u: T) => u is Exclude<T, false | 0 | 0n | "" | null | undefined>;
390
+ /**
391
+ * Type guard — checks if a value is falsy (`false`, `0`, `0n`, `""`, `null`, `undefined`, or `NaN`).
392
+ *
393
+ * @example
394
+ * ```ts
395
+ * Bool.is.falsy(""); // true
396
+ * Bool.is.falsy(null); // true
397
+ * Bool.is.falsy("content"); // false
398
+ * ```
399
+ */
400
+ falsy: (u: unknown) => u is false | 0 | 0n | "" | null | undefined;
401
+ };
402
+ /**
403
+ * Unary boolean negation: inverts the given boolean value.
404
+ *
405
+ * @example
406
+ * ```ts
407
+ * Bool.not(true); // false
408
+ * Bool.not(false); // true
409
+ * ```
410
+ */
411
+ not: (b: boolean) => boolean;
412
+ /**
413
+ * Logical AND combinator. Returns `true` only if both `self` and `that` are `true`.
414
+ *
415
+ * Data-last: `pipe(self, Bool.and(that))`.
416
+ *
417
+ * @example
418
+ * ```ts
419
+ * pipe(true, Bool.and(true)); // true
420
+ * pipe(true, Bool.and(false)); // false
421
+ * ```
422
+ */
423
+ and: (that: boolean) => (self: boolean) => boolean;
424
+ /**
425
+ * Logical OR combinator. Returns `true` if either `self` or `that` is `true`.
426
+ *
427
+ * Data-last: `pipe(self, Bool.or(that))`.
428
+ *
429
+ * @example
430
+ * ```ts
431
+ * pipe(false, Bool.or(true)); // true
432
+ * pipe(false, Bool.or(false)); // false
433
+ * ```
434
+ */
435
+ or: (that: boolean) => (self: boolean) => boolean;
436
+ /**
437
+ * Logical XOR (exclusive OR) combinator. Returns `true` if exactly one of `self` and `that` is `true`.
438
+ *
439
+ * Data-last: `pipe(self, Bool.xor(that))`.
440
+ *
441
+ * @example
442
+ * ```ts
443
+ * pipe(true, Bool.xor(false)); // true
444
+ * pipe(true, Bool.xor(true)); // false
445
+ * ```
446
+ */
447
+ xor: (that: boolean) => (self: boolean) => boolean;
448
+ /**
449
+ * Lazy logical AND combinator.
450
+ * If `self` is `false`, the `that` computation is never evaluated.
451
+ *
452
+ * Data-last: `pipe(self, Bool.andLazy(that))`.
453
+ *
454
+ * @example
455
+ * ```ts
456
+ * pipe(
457
+ * isCached,
458
+ * Bool.andLazy(() => checkPermissions())
459
+ * );
460
+ * ```
461
+ */
462
+ andLazy: (that: () => boolean) => (self: boolean) => boolean;
463
+ /**
464
+ * Lazy logical OR combinator.
465
+ * If `self` is `true`, the `that` computation is never evaluated.
466
+ *
467
+ * Data-last: `pipe(self, Bool.orLazy(that))`.
468
+ *
469
+ * @example
470
+ * ```ts
471
+ * pipe(
472
+ * isAdmin,
473
+ * Bool.orLazy(() => hasAccess(userId))
474
+ * );
475
+ * ```
476
+ */
477
+ orLazy: (that: () => boolean) => (self: boolean) => boolean;
478
+ /**
479
+ * N-ary AND aggregation across an array of booleans.
480
+ * Returns `true` if every boolean is `true`, or for an empty array (vacuous truth).
481
+ * Short-circuits on the first `false`.
482
+ *
483
+ * @example
484
+ * ```ts
485
+ * Bool.all([true, true, true]); // true
486
+ * Bool.all([true, false, true]); // false
487
+ * Bool.all([]); // true
488
+ * ```
489
+ */
490
+ all: (booleans: readonly boolean[]) => boolean;
491
+ /**
492
+ * N-ary OR aggregation across an array of booleans.
493
+ * Returns `true` if at least one boolean is `true`. Returns `false` for an empty array.
494
+ * Short-circuits on the first `true`.
495
+ *
496
+ * @example
497
+ * ```ts
498
+ * Bool.any([false, true, false]); // true
499
+ * Bool.any([false, false]); // false
500
+ * Bool.any([]); // false
501
+ * ```
502
+ */
503
+ any: (booleans: readonly boolean[]) => boolean;
504
+ /**
505
+ * Catamorphism for boolean: evaluates `onFalse()` when `false` and `onTrue()` when `true`.
506
+ *
507
+ * Positional ordering: `onFalse` first, `onTrue` second.
508
+ * Aligned with `Result.fold(onErr, onOk)` and `Maybe.fold(onNone, onSome)`.
509
+ *
510
+ * @example
511
+ * ```ts
512
+ * pipe(
513
+ * isDarkMode,
514
+ * Bool.fold(
515
+ * () => "light-theme",
516
+ * () => "dark-theme"
517
+ * )
518
+ * );
519
+ * ```
520
+ */
521
+ fold: <A, B>(onFalse: () => A, onTrue: () => B) => (b: boolean) => A | B;
522
+ /**
523
+ * Pattern matching on boolean using named cases `{ true, false }`.
524
+ *
525
+ * @example
526
+ * ```ts
527
+ * pipe(
528
+ * isEnabled,
529
+ * Bool.match({
530
+ * true: () => "Feature Active",
531
+ * false: () => "Feature Disabled",
532
+ * })
533
+ * );
534
+ * ```
535
+ */
536
+ match: <A, B>(cases: BoolMatchCases<A, B>) => (b: boolean) => A | B;
537
+ from: {
538
+ /**
539
+ * Parses a string into a `Maybe<boolean>`.
540
+ * Returns `Some(true)` for `"true"`, `Some(false)` for `"false"` (case-insensitive & trimmed),
541
+ * and `None` for any other string.
542
+ *
543
+ * @example
544
+ * ```ts
545
+ * Bool.from.string("true"); // Some(true)
546
+ * Bool.from.string("FALSE"); // Some(false)
547
+ * Bool.from.string("yes"); // None
548
+ * ```
549
+ */
550
+ string: (s: string) => Maybe<boolean>;
551
+ /**
552
+ * Converts a number into a `Maybe<boolean>`.
553
+ * Returns `Some(true)` for `1`, `Some(false)` for `0`, and `None` for any other number.
554
+ *
555
+ * @example
556
+ * ```ts
557
+ * Bool.from.number(1); // Some(true)
558
+ * Bool.from.number(0); // Some(false)
559
+ * Bool.from.number(42); // None
560
+ * ```
561
+ */
562
+ number: (n: number) => Maybe<boolean>;
563
+ /**
564
+ * Coerces any unknown value into a boolean via standard JS `Boolean(value)`.
565
+ *
566
+ * @example
567
+ * ```ts
568
+ * Bool.from.truthy("hello"); // true
569
+ * Bool.from.truthy(0); // false
570
+ * ```
571
+ */
572
+ truthy: (value: unknown) => boolean;
573
+ };
574
+ to: {
575
+ /**
576
+ * Lifts a boolean condition into a `Maybe`.
577
+ * Returns `Some(onTrue())` when `true`, and `None` when `false`.
578
+ *
579
+ * @example
580
+ * ```ts
581
+ * pipe(
582
+ * user.isVerified,
583
+ * Bool.to.Maybe(() => user.profile)
584
+ * ); // Some(profile) or None
585
+ * ```
586
+ */
587
+ Maybe: <A>(onTrue: () => A) => (b: boolean) => Maybe<A>;
588
+ /**
589
+ * Lifts a boolean condition into a `Result`.
590
+ * Returns `Ok(onOk())` when `true`, and `Err(onErr())` when `false`.
591
+ *
592
+ * @example
593
+ * ```ts
594
+ * pipe(
595
+ * hasPermission,
596
+ * Bool.to.Result(
597
+ * () => "Permission denied",
598
+ * () => sessionData
599
+ * )
600
+ * ); // Ok(sessionData) or Err("Permission denied")
601
+ * ```
602
+ */
603
+ Result: <E, A>(onErr: () => E, onOk: () => A) => (b: boolean) => Result<E, A>;
604
+ /**
605
+ * Converts a boolean to numeric `1` or `0`.
606
+ *
607
+ * @example
608
+ * ```ts
609
+ * Bool.to.number(true); // 1
610
+ * Bool.to.number(false); // 0
611
+ * ```
612
+ */
613
+ number: (b: boolean) => 1 | 0;
614
+ /**
615
+ * Converts a boolean to literal string `"true"` or `"false"`.
616
+ *
617
+ * @example
618
+ * ```ts
619
+ * Bool.to.string(true); // "true"
620
+ * Bool.to.string(false); // "false"
621
+ * ```
622
+ */
623
+ string: (b: boolean) => "true" | "false";
624
+ };
625
+ };
626
+
286
627
  /**
287
628
  * A branded type representing a key-value dictionary with at least one entry.
288
629
  */
@@ -1124,4 +1465,4 @@ declare namespace Uniq {
1124
1465
  type NonEmpty<A> = NonEmptySet<A>;
1125
1466
  }
1126
1467
 
1127
- export { Arr, BigNum, Dict, Json, type NonEmptyMap, type NonEmptyRecord, type NonEmptySet, type NonEmptyString, Num, Rec, Str, Uniq };
1468
+ export { Arr, BigNum, Bool, type BoolMatchCases, Dict, Json, type NonEmptyMap, type NonEmptyRecord, type NonEmptySet, type NonEmptyString, Num, Rec, Str, Uniq };