ts-data-forge 6.13.0 → 7.0.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 +2 -2
- package/dist/array/impl/array-utils-iterators.mjs +6 -0
- package/dist/array/impl/array-utils-iterators.mjs.map +1 -1
- package/dist/array/impl/array-utils-modification.mjs +6 -0
- package/dist/array/impl/array-utils-modification.mjs.map +1 -1
- package/dist/array/impl/array-utils-reducing-value.mjs +6 -0
- package/dist/array/impl/array-utils-reducing-value.mjs.map +1 -1
- package/dist/array/impl/array-utils-search.mjs +6 -0
- package/dist/array/impl/array-utils-search.mjs.map +1 -1
- package/dist/array/impl/array-utils-slice-clamped.mjs +6 -0
- package/dist/array/impl/array-utils-slice-clamped.mjs.map +1 -1
- package/dist/array/impl/array-utils-slicing.mjs +6 -0
- package/dist/array/impl/array-utils-slicing.mjs.map +1 -1
- package/dist/array/impl/array-utils-transformation.mjs +6 -0
- package/dist/array/impl/array-utils-transformation.mjs.map +1 -1
- package/dist/array/impl/array-utils-validation.mjs +6 -0
- package/dist/array/impl/array-utils-validation.mjs.map +1 -1
- package/dist/collections/imap-mapped.mjs +6 -0
- package/dist/collections/imap-mapped.mjs.map +1 -1
- package/dist/collections/imap.mjs +6 -0
- package/dist/collections/imap.mjs.map +1 -1
- package/dist/collections/iset-mapped.mjs +6 -0
- package/dist/collections/iset-mapped.mjs.map +1 -1
- package/dist/collections/iset.mjs +6 -0
- package/dist/collections/iset.mjs.map +1 -1
- package/dist/collections/queue.mjs +6 -0
- package/dist/collections/queue.mjs.map +1 -1
- package/dist/collections/stack.mjs +6 -0
- package/dist/collections/stack.mjs.map +1 -1
- package/dist/entry-point.mjs +6 -0
- package/dist/entry-point.mjs.map +1 -1
- package/dist/functional/pipe.d.mts +6 -18
- package/dist/functional/pipe.d.mts.map +1 -1
- package/dist/functional/pipe.mjs +35 -15
- package/dist/functional/pipe.mjs.map +1 -1
- package/dist/index.mjs +6 -0
- package/dist/index.mjs.map +1 -1
- package/dist/iterator/range.mjs +6 -0
- package/dist/iterator/range.mjs.map +1 -1
- package/dist/json/json.mjs +6 -0
- package/dist/json/json.mjs.map +1 -1
- package/dist/number/branded-types/finite-number.d.mts +1 -1
- package/dist/number/branded-types/index.d.mts +6 -0
- package/dist/number/branded-types/index.d.mts.map +1 -1
- package/dist/number/branded-types/index.mjs +6 -0
- package/dist/number/branded-types/index.mjs.map +1 -1
- package/dist/number/branded-types/int.d.mts +1 -2
- package/dist/number/branded-types/int.d.mts.map +1 -1
- package/dist/number/branded-types/int16.d.mts +2 -3
- package/dist/number/branded-types/int16.d.mts.map +1 -1
- package/dist/number/branded-types/int32.d.mts +2 -3
- package/dist/number/branded-types/int32.d.mts.map +1 -1
- package/dist/number/branded-types/negative-finite-number.d.mts +143 -0
- package/dist/number/branded-types/negative-finite-number.d.mts.map +1 -0
- package/dist/number/branded-types/negative-finite-number.mjs +156 -0
- package/dist/number/branded-types/negative-finite-number.mjs.map +1 -0
- package/dist/number/branded-types/negative-int.d.mts +120 -0
- package/dist/number/branded-types/negative-int.d.mts.map +1 -0
- package/dist/number/branded-types/negative-int.mjs +125 -0
- package/dist/number/branded-types/negative-int.mjs.map +1 -0
- package/dist/number/branded-types/negative-safe-int.d.mts +132 -0
- package/dist/number/branded-types/negative-safe-int.d.mts.map +1 -0
- package/dist/number/branded-types/negative-safe-int.mjs +136 -0
- package/dist/number/branded-types/negative-safe-int.mjs.map +1 -0
- package/dist/number/branded-types/non-negative-finite-number.d.mts +1 -1
- package/dist/number/branded-types/non-negative-int16.d.mts +1 -1
- package/dist/number/branded-types/non-negative-int32.d.mts +1 -1
- package/dist/number/branded-types/non-positive-finite-number.d.mts +130 -0
- package/dist/number/branded-types/non-positive-finite-number.d.mts.map +1 -0
- package/dist/number/branded-types/non-positive-finite-number.mjs +134 -0
- package/dist/number/branded-types/non-positive-finite-number.mjs.map +1 -0
- package/dist/number/branded-types/non-positive-int.d.mts +224 -0
- package/dist/number/branded-types/non-positive-int.d.mts.map +1 -0
- package/dist/number/branded-types/non-positive-int.mjs +222 -0
- package/dist/number/branded-types/non-positive-int.mjs.map +1 -0
- package/dist/number/branded-types/non-positive-safe-int.d.mts +119 -0
- package/dist/number/branded-types/non-positive-safe-int.d.mts.map +1 -0
- package/dist/number/branded-types/non-positive-safe-int.mjs +116 -0
- package/dist/number/branded-types/non-positive-safe-int.mjs.map +1 -0
- package/dist/number/branded-types/non-zero-finite-number.d.mts +5 -17
- package/dist/number/branded-types/non-zero-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-finite-number.mjs +5 -17
- package/dist/number/branded-types/non-zero-finite-number.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int.d.mts +5 -33
- package/dist/number/branded-types/non-zero-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int.mjs +5 -25
- package/dist/number/branded-types/non-zero-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int16.d.mts +6 -43
- package/dist/number/branded-types/non-zero-int16.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int16.mjs +5 -25
- package/dist/number/branded-types/non-zero-int16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-int32.d.mts +6 -39
- package/dist/number/branded-types/non-zero-int32.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-int32.mjs +5 -25
- package/dist/number/branded-types/non-zero-int32.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.d.mts +5 -37
- package/dist/number/branded-types/non-zero-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-safe-int.mjs +5 -28
- package/dist/number/branded-types/non-zero-safe-int.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.d.mts +6 -33
- package/dist/number/branded-types/non-zero-uint16.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-uint16.mjs +5 -17
- package/dist/number/branded-types/non-zero-uint16.mjs.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.d.mts +6 -31
- package/dist/number/branded-types/non-zero-uint32.d.mts.map +1 -1
- package/dist/number/branded-types/non-zero-uint32.mjs +5 -17
- package/dist/number/branded-types/non-zero-uint32.mjs.map +1 -1
- package/dist/number/branded-types/positive-finite-number.d.mts +4 -2
- package/dist/number/branded-types/positive-finite-number.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int.d.mts +4 -2
- package/dist/number/branded-types/positive-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int16.d.mts +4 -2
- package/dist/number/branded-types/positive-int16.d.mts.map +1 -1
- package/dist/number/branded-types/positive-int32.d.mts +4 -2
- package/dist/number/branded-types/positive-int32.d.mts.map +1 -1
- package/dist/number/branded-types/positive-safe-int.d.mts +4 -2
- package/dist/number/branded-types/positive-safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/positive-uint16.d.mts +4 -2
- package/dist/number/branded-types/positive-uint16.d.mts.map +1 -1
- package/dist/number/branded-types/positive-uint32.d.mts +4 -2
- package/dist/number/branded-types/positive-uint32.d.mts.map +1 -1
- package/dist/number/branded-types/safe-int.d.mts +1 -2
- package/dist/number/branded-types/safe-int.d.mts.map +1 -1
- package/dist/number/branded-types/safe-uint.d.mts +1 -1
- package/dist/number/branded-types/uint.d.mts +1 -1
- package/dist/number/branded-types/uint16.d.mts +1 -1
- package/dist/number/branded-types/uint32.d.mts +1 -1
- package/dist/number/index.d.mts +1 -0
- package/dist/number/index.d.mts.map +1 -1
- package/dist/number/index.mjs +6 -0
- package/dist/number/index.mjs.map +1 -1
- package/dist/number/num-arithmetic-types.d.mts +74 -0
- package/dist/number/num-arithmetic-types.d.mts.map +1 -0
- package/dist/number/num-arithmetic-types.mjs +2 -0
- package/dist/number/num-arithmetic-types.mjs.map +1 -0
- package/dist/number/num.d.mts +53 -9
- package/dist/number/num.d.mts.map +1 -1
- package/dist/number/num.mjs +64 -12
- package/dist/number/num.mjs.map +1 -1
- package/dist/number/refined-number-utils.d.mts +12 -9
- package/dist/number/refined-number-utils.d.mts.map +1 -1
- package/dist/number/refined-number-utils.mjs.map +1 -1
- package/dist/object/object.mjs +6 -0
- package/dist/object/object.mjs.map +1 -1
- package/package.json +5 -2
- package/src/functional/pipe.mts +104 -78
- package/src/functional/pipe.test.mts +57 -1
- package/src/number/branded-types/index.mts +6 -0
- package/src/number/branded-types/negative-finite-number.mts +210 -0
- package/src/number/branded-types/negative-finite-number.test.mts +172 -0
- package/src/number/branded-types/negative-int.mts +160 -0
- package/src/number/branded-types/negative-int.test.mts +146 -0
- package/src/number/branded-types/negative-safe-int.mts +173 -0
- package/src/number/branded-types/negative-safe-int.test.mts +120 -0
- package/src/number/branded-types/non-positive-finite-number.mts +191 -0
- package/src/number/branded-types/non-positive-finite-number.test.mts +286 -0
- package/src/number/branded-types/non-positive-int.mts +251 -0
- package/src/number/branded-types/non-positive-int.test.mts +197 -0
- package/src/number/branded-types/non-positive-safe-int.mts +147 -0
- package/src/number/branded-types/non-positive-safe-int.test.mts +223 -0
- package/src/number/branded-types/non-zero-finite-number.mts +14 -22
- package/src/number/branded-types/non-zero-finite-number.test.mts +0 -12
- package/src/number/branded-types/non-zero-int.mts +10 -32
- package/src/number/branded-types/non-zero-int.test.mts +0 -20
- package/src/number/branded-types/non-zero-int16.mts +8 -32
- package/src/number/branded-types/non-zero-int16.test.mts +0 -30
- package/src/number/branded-types/non-zero-int32.mts +8 -32
- package/src/number/branded-types/non-zero-int32.test.mts +0 -30
- package/src/number/branded-types/non-zero-safe-int.mts +8 -35
- package/src/number/branded-types/non-zero-safe-int.test.mts +0 -32
- package/src/number/branded-types/non-zero-uint16.mts +8 -22
- package/src/number/branded-types/non-zero-uint16.test.mts +0 -16
- package/src/number/branded-types/non-zero-uint32.mts +8 -22
- package/src/number/branded-types/non-zero-uint32.test.mts +0 -16
- package/src/number/index.mts +1 -0
- package/src/number/num-arithmetic-types.mts +269 -0
- package/src/number/num-arithmetic-types.test.mts +130 -0
- package/src/number/num-arithmetic.test.mts +102 -0
- package/src/number/num.mts +96 -15
- package/src/number/refined-number-utils.mts +19 -9
- package/src/others/map-nullable.test.mts +3 -4
package/dist/number/num.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Decrement, type FiniteNumber, type Increment, type Index, type Int, type Min, type NaNType, type NegativeIndex, type NonNegativeNumber, type NonZeroNumber, type PositiveNumber, type PositiveSafeIntWithSmallInt, type RelaxedExclude, type SmallInt, type SmallUint } from 'ts-type-forge';
|
|
2
2
|
import { Result } from '../functional/index.mjs';
|
|
3
3
|
import { type SmallPositiveInt } from '../types.mjs';
|
|
4
|
+
import { type AddResult, type DivIntResult, type DivResult, type MulResult, type SubResult } from './num-arithmetic-types.mjs';
|
|
4
5
|
/**
|
|
5
6
|
* Namespace providing utility functions for number manipulation and validation.
|
|
6
7
|
*
|
|
@@ -395,17 +396,60 @@ export declare namespace Num {
|
|
|
395
396
|
export function clamp(target: number, lowerBound: number, upperBound: number): number;
|
|
396
397
|
export function clamp(lowerBound: number, upperBound: number): (target: number) => number;
|
|
397
398
|
/**
|
|
398
|
-
*
|
|
399
|
+
* Adds two numbers, returning the tightest sound branded result type.
|
|
400
|
+
*
|
|
401
|
+
* The sign of the result is computed exactly (e.g. a non-negative plus a
|
|
402
|
+
* non-negative is non-negative); the integer/finite level is preserved, with
|
|
403
|
+
* `SafeInt` operands widening to `Int` because the sum may exceed the safe
|
|
404
|
+
* range. No clamping is performed — for a result that stays inside a bounded
|
|
405
|
+
* type, use that type's branded `add` instead.
|
|
406
|
+
*
|
|
407
|
+
* @param a - The first addend.
|
|
408
|
+
* @param b - The second addend.
|
|
409
|
+
* @returns `a + b`, typed as the tightest branded type guaranteed to contain
|
|
410
|
+
* it.
|
|
411
|
+
*/
|
|
412
|
+
export const add: <A extends number, B extends number>(a: A, b: B) => AddResult<A, B>;
|
|
413
|
+
/**
|
|
414
|
+
* Subtracts `b` from `a`, returning the tightest sound branded result type.
|
|
399
415
|
*
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
*
|
|
416
|
+
* The sign is computed exactly; the level is preserved (with `SafeInt`
|
|
417
|
+
* widening to `Int`). No clamping — for saturating subtraction that stays in a
|
|
418
|
+
* bounded type (e.g. `Uint.sub` clamping at `0`), use that type's branded
|
|
419
|
+
* `sub`.
|
|
403
420
|
*
|
|
404
|
-
* @param a - The
|
|
405
|
-
* @param b - The
|
|
406
|
-
* @returns
|
|
421
|
+
* @param a - The minuend.
|
|
422
|
+
* @param b - The subtrahend.
|
|
423
|
+
* @returns `a - b`, typed as the tightest branded type guaranteed to contain
|
|
424
|
+
* it.
|
|
425
|
+
*/
|
|
426
|
+
export const sub: <A extends number, B extends number>(a: A, b: B) => SubResult<A, B>;
|
|
427
|
+
/**
|
|
428
|
+
* Multiplies two numbers, returning the tightest sound branded result type.
|
|
429
|
+
*
|
|
430
|
+
* The sign follows the usual product rule (e.g. negative times negative is
|
|
431
|
+
* positive); the level is preserved (with `SafeInt` widening to `Int`). No
|
|
432
|
+
* clamping.
|
|
433
|
+
*
|
|
434
|
+
* @param a - The first factor.
|
|
435
|
+
* @param b - The second factor.
|
|
436
|
+
* @returns `a * b`, typed as the tightest branded type guaranteed to contain
|
|
437
|
+
* it.
|
|
438
|
+
*/
|
|
439
|
+
export const mul: <A extends number, B extends number>(a: A, b: B) => MulResult<A, B>;
|
|
440
|
+
/**
|
|
441
|
+
* Performs type-safe exact division with a compile-time zero-check.
|
|
442
|
+
*
|
|
443
|
+
* The divisor must be typed as `NonZeroNumber` or a non-zero numeric literal.
|
|
444
|
+
* The result sign follows the quotient rule; because exact division can be
|
|
445
|
+
* fractional, the level is `finite` (or `number`).
|
|
446
|
+
*
|
|
447
|
+
* @param a - The dividend.
|
|
448
|
+
* @param b - The divisor (must be non-zero, enforced by types).
|
|
449
|
+
* @returns `a / b`, typed as the tightest branded type guaranteed to contain
|
|
450
|
+
* it.
|
|
407
451
|
*/
|
|
408
|
-
export const div:
|
|
452
|
+
export const div: <A extends number, B extends NonZeroNumber | SmallInt<"!=0">>(a: A, b: B) => DivResult<A, B>;
|
|
409
453
|
/**
|
|
410
454
|
* Performs integer division using floor division.
|
|
411
455
|
*
|
|
@@ -419,7 +463,7 @@ export declare namespace Num {
|
|
|
419
463
|
* @param b - The divisor
|
|
420
464
|
* @returns The integer quotient, or `NaN` if b is zero
|
|
421
465
|
*/
|
|
422
|
-
export const divInt:
|
|
466
|
+
export const divInt: <A extends number, B extends NonZeroNumber | SmallInt<"!=0">>(a: A, b: B) => DivIntResult<A, B>;
|
|
423
467
|
/**
|
|
424
468
|
* Rounds a number to a specified number of decimal places.
|
|
425
469
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"num.d.mts","sourceRoot":"","sources":["../../src/number/num.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,GAAG,EACR,KAAK,GAAG,EACR,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,2BAA2B,EAChC,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,SAAS,EAEf,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AACjD,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"num.d.mts","sourceRoot":"","sources":["../../src/number/num.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,GAAG,EACR,KAAK,GAAG,EACR,KAAK,OAAO,EACZ,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,2BAA2B,EAChC,KAAK,cAAc,EACnB,KAAK,QAAQ,EACb,KAAK,SAAS,EAEf,MA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C,GAAG,CAAC,EACJ,GAAG,CAAC,KACH,YAAY,CAAC,CAAC,EAAE,CAAC,CAMnB,CAAC;IAEF;;;;;;;;;OASG;IACH,MAAM,CAAC,MAAM,OAAO,GAClB,KAAK,MAAM,EACX,WAAW,2BAA2B,KACrC,MAKF,CAAC;IAEF;;;;;;;;;OASG;IAEH,MAAM,CAAC,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,GAAmC,CAAC;IAE7E;;;;;;;;;OASG;IACH,MAAM,CAAC,MAAM,KAAK,GAChB,OAAO,2BAA2B,KACjC,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAM1B,CAAC;IAEF;;;;;;;;;;OAUG;IACH,MAAM,CAAC,MAAM,gBAAgB,GAAI,CAAC,SAAS,MAAM,EAC/C,KAAK,CAAC,KACL,cAAc,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,SAIS,CAAC;IAE1C;;;;;;;;;;OAUG;IACH,MAAM,CAAC,MAAM,SAAS,GAAI,CAAC,SAAS,SAAS,EAAE,GAAG,CAAC,KAAG,SAAS,CAAC,CAAC,CAExC,CAAC;IAE1B;;;;;;;;;;OAUG;IACH,MAAM,CAAC,MAAM,SAAS,GAAI,CAAC,SAAS,gBAAgB,EAAE,GAAG,CAAC,KAAG,SAAS,CAAC,CAAC,CAE/C,CAAC;;CAC3B"}
|
package/dist/number/num.mjs
CHANGED
|
@@ -381,19 +381,68 @@ var Num;
|
|
|
381
381
|
}
|
|
382
382
|
Num.clamp = clamp;
|
|
383
383
|
/**
|
|
384
|
-
*
|
|
384
|
+
* Adds two numbers, returning the tightest sound branded result type.
|
|
385
|
+
*
|
|
386
|
+
* The sign of the result is computed exactly (e.g. a non-negative plus a
|
|
387
|
+
* non-negative is non-negative); the integer/finite level is preserved, with
|
|
388
|
+
* `SafeInt` operands widening to `Int` because the sum may exceed the safe
|
|
389
|
+
* range. No clamping is performed — for a result that stays inside a bounded
|
|
390
|
+
* type, use that type's branded `add` instead.
|
|
391
|
+
*
|
|
392
|
+
* @param a - The first addend.
|
|
393
|
+
* @param b - The second addend.
|
|
394
|
+
* @returns `a + b`, typed as the tightest branded type guaranteed to contain
|
|
395
|
+
* it.
|
|
396
|
+
*/
|
|
397
|
+
Num.add = (a, b) =>
|
|
398
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
399
|
+
(a + b);
|
|
400
|
+
/**
|
|
401
|
+
* Subtracts `b` from `a`, returning the tightest sound branded result type.
|
|
385
402
|
*
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
403
|
+
* The sign is computed exactly; the level is preserved (with `SafeInt`
|
|
404
|
+
* widening to `Int`). No clamping — for saturating subtraction that stays in a
|
|
405
|
+
* bounded type (e.g. `Uint.sub` clamping at `0`), use that type's branded
|
|
406
|
+
* `sub`.
|
|
389
407
|
*
|
|
390
|
-
* @param a - The
|
|
391
|
-
* @param b - The
|
|
392
|
-
* @returns
|
|
408
|
+
* @param a - The minuend.
|
|
409
|
+
* @param b - The subtrahend.
|
|
410
|
+
* @returns `a - b`, typed as the tightest branded type guaranteed to contain
|
|
411
|
+
* it.
|
|
412
|
+
*/
|
|
413
|
+
Num.sub = (a, b) =>
|
|
414
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
415
|
+
(a - b);
|
|
416
|
+
/**
|
|
417
|
+
* Multiplies two numbers, returning the tightest sound branded result type.
|
|
418
|
+
*
|
|
419
|
+
* The sign follows the usual product rule (e.g. negative times negative is
|
|
420
|
+
* positive); the level is preserved (with `SafeInt` widening to `Int`). No
|
|
421
|
+
* clamping.
|
|
422
|
+
*
|
|
423
|
+
* @param a - The first factor.
|
|
424
|
+
* @param b - The second factor.
|
|
425
|
+
* @returns `a * b`, typed as the tightest branded type guaranteed to contain
|
|
426
|
+
* it.
|
|
427
|
+
*/
|
|
428
|
+
Num.mul = (a, b) =>
|
|
429
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
430
|
+
(a * b);
|
|
431
|
+
/**
|
|
432
|
+
* Performs type-safe exact division with a compile-time zero-check.
|
|
433
|
+
*
|
|
434
|
+
* The divisor must be typed as `NonZeroNumber` or a non-zero numeric literal.
|
|
435
|
+
* The result sign follows the quotient rule; because exact division can be
|
|
436
|
+
* fractional, the level is `finite` (or `number`).
|
|
437
|
+
*
|
|
438
|
+
* @param a - The dividend.
|
|
439
|
+
* @param b - The divisor (must be non-zero, enforced by types).
|
|
440
|
+
* @returns `a / b`, typed as the tightest branded type guaranteed to contain
|
|
441
|
+
* it.
|
|
393
442
|
*/
|
|
394
443
|
Num.div = (a, b) =>
|
|
395
|
-
// eslint-disable-next-line total-functions/no-partial-division
|
|
396
|
-
a / b;
|
|
444
|
+
// eslint-disable-next-line total-functions/no-partial-division, total-functions/no-unsafe-type-assertion
|
|
445
|
+
(a / b);
|
|
397
446
|
/**
|
|
398
447
|
* Performs integer division using floor division.
|
|
399
448
|
*
|
|
@@ -407,9 +456,12 @@ var Num;
|
|
|
407
456
|
* @param b - The divisor
|
|
408
457
|
* @returns The integer quotient, or `NaN` if b is zero
|
|
409
458
|
*/
|
|
410
|
-
Num.divInt = (a, b) =>
|
|
411
|
-
|
|
412
|
-
|
|
459
|
+
Num.divInt = (a, b) => {
|
|
460
|
+
// eslint-disable-next-line total-functions/no-partial-division
|
|
461
|
+
const quotient = Math.floor(Math.floor(a) / Math.floor(b));
|
|
462
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
463
|
+
return quotient;
|
|
464
|
+
};
|
|
413
465
|
/**
|
|
414
466
|
* Rounds a number to a specified number of decimal places.
|
|
415
467
|
*
|
package/dist/number/num.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"num.mjs","sources":["../../src/number/num.mts"],"sourcesContent":[null],"names":["Result.err","Result.ok"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"num.mjs","sources":["../../src/number/num.mts"],"sourcesContent":[null],"names":["Result.err","Result.ok"],"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AG,EAAE,IAAI,SAAS;;QAG7B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,GAAG,KAAK;AACxC,IAAA,CAAC;AAED;;;;;;;;;AASG;;AAEU,IAAA,GAAA,CAAA,UAAU,GAAG,CAAC,GAAW,KAAU,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,CAAQ;AAE5E;;;;;;;;;AASG;AACU,IAAA,GAAA,CAAA,KAAK,GAAG,CACnB,KAAkC,KACL;AAC7B,QAAA,MAAM,SAAS,GAAG,EAAE,IAAI,KAAK;QAE7B,OAAO,CAAC,MAAc;;QAEpB,GAAA,CAAA,UAAU,CAAC,SAAS,GAAG,MAAM,CAAC,GAAG,SAAS;AAC9C,IAAA,CAAC;AAED;;;;;;;;;;AAUG;IACU,GAAA,CAAA,gBAAgB,GAAG,CAC9B,GAAM,KAEN,MAAM,CAAC,KAAK,CAAC,GAAG;AACd,UAAE;AACF;AACG,YAAA,GAAkC;AAEzC;;;;;;;;;;AAUG;AACU,IAAA,GAAA,CAAA,SAAS,GAAG,CAAsB,CAAI;;AAEjD,KAAC,CAAC,GAAG,CAAC,CAAiB;AAEzB;;;;;;;;;;AAUG;AACU,IAAA,GAAA,CAAA,SAAS,GAAG,CAA6B,CAAI;;AAExD,KAAC,CAAC,GAAG,CAAC,CAAiB;AAC3B,CAAC,EAtqBgB,GAAG,KAAH,GAAG,GAAA,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Brand, type ChangeBaseBrand, type GetBrandValuePart, type Int, type IntersectBrand, type NonNegativeNumber, type NonZeroNumber, type RelaxedExclude, type TypeEq, type UnknownBrand, type UnwrapBrandFalseKeys, type UnwrapBrandTrueKeys, type WithSmallInt } from 'ts-type-forge';
|
|
1
|
+
import { type Brand, type ChangeBaseBrand, type GetBrandValuePart, type Int, type IntersectBrand, type NonNegativeNumber, type NonZeroNumber, type PositiveNumber, type RelaxedExclude, type TypeEq, type UnknownBrand, type UnwrapBrandFalseKeys, type UnwrapBrandTrueKeys, type WithSmallInt } from 'ts-type-forge';
|
|
2
2
|
/** @internal */
|
|
3
3
|
export declare namespace TsDataForgeInternals {
|
|
4
4
|
/**
|
|
@@ -40,7 +40,7 @@ export declare namespace TsDataForgeInternals {
|
|
|
40
40
|
* @template N - A branded number type
|
|
41
41
|
* @internal
|
|
42
42
|
*/
|
|
43
|
-
export type ToNonNegative<N extends UnknownNumberBrand> = IntersectBrand<N, NonNegativeNumber>;
|
|
43
|
+
export type ToNonNegative<N extends UnknownNumberBrand> = '!=0' extends UnwrapBrandTrueKeys<N> ? IntersectBrand<N, PositiveNumber> : IntersectBrand<N, NonNegativeNumber>;
|
|
44
44
|
/**
|
|
45
45
|
* Removes the non-zero brand constraint from a branded number type. Used
|
|
46
46
|
* when operations may produce zero values.
|
|
@@ -48,7 +48,7 @@ export declare namespace TsDataForgeInternals {
|
|
|
48
48
|
* @template N - A branded number type
|
|
49
49
|
* @internal
|
|
50
50
|
*/
|
|
51
|
-
export type RemoveNonZeroBrandKey<N extends UnknownNumberBrand> = Brand<GetBrandValuePart<N>, RelaxedExclude<UnwrapBrandTrueKeys<N>, '!=0'> & string, UnwrapBrandFalseKeys<N> & string>;
|
|
51
|
+
export type RemoveNonZeroBrandKey<N extends UnknownNumberBrand> = Brand<GetBrandValuePart<N>, RelaxedExclude<UnwrapBrandTrueKeys<N>, '!=0'> & string, RelaxedExclude<UnwrapBrandFalseKeys<N>, '<=0' | '>=0'> & string>;
|
|
52
52
|
type CastToInt<N> = N extends Int ? N : never;
|
|
53
53
|
/**
|
|
54
54
|
* Generates a type-safe API for a branded number type based on its
|
|
@@ -66,7 +66,9 @@ export declare namespace TsDataForgeInternals {
|
|
|
66
66
|
* 'positive' | 'range'
|
|
67
67
|
* @internal
|
|
68
68
|
*/
|
|
69
|
-
|
|
69
|
+
/** The closed binary arithmetic operations a branded namespace may expose. */
|
|
70
|
+
export type NumberClassBinOp = 'add' | 'div' | 'mul' | 'sub';
|
|
71
|
+
export type NumberClass<N extends UnknownNumberBrand, classes extends 'int' | 'non-negative' | 'positive' | 'range', binOps extends NumberClassBinOp = NumberClassBinOp> = ('int' extends classes ? unknown : 'positive' extends classes ? Readonly<{
|
|
70
72
|
floor: (x: N, y: N) => RemoveNonZeroBrandKey<ToInt<N>>;
|
|
71
73
|
ceil: (x: N, y: N) => ToInt<N>;
|
|
72
74
|
round: (x: N, y: N) => RemoveNonZeroBrandKey<ToInt<N>>;
|
|
@@ -86,16 +88,17 @@ export declare namespace TsDataForgeInternals {
|
|
|
86
88
|
MIN_VALUE: number;
|
|
87
89
|
MAX_VALUE: number;
|
|
88
90
|
clamp: (a: number) => N;
|
|
89
|
-
}> : unknown) & Readonly<{
|
|
91
|
+
}> : unknown) & Pick<Readonly<{
|
|
92
|
+
add: (x: N, y: N) => N;
|
|
93
|
+
sub: (x: N, y: N) => N;
|
|
94
|
+
mul: (x: N, y: N) => N;
|
|
95
|
+
div: (x: N, y: ToNonZero<N>) => N;
|
|
96
|
+
}>, binOps> & Readonly<{
|
|
90
97
|
is: (a: number) => a is N;
|
|
91
98
|
min: (...values: readonly N[]) => N;
|
|
92
99
|
max: (...values: readonly N[]) => N;
|
|
93
100
|
random: (min: N, max: N) => N;
|
|
94
101
|
pow: (x: N, y: N) => N;
|
|
95
|
-
add: (x: N, y: N) => N;
|
|
96
|
-
sub: (x: N, y: N) => N;
|
|
97
|
-
mul: (x: N, y: N) => N;
|
|
98
|
-
div: (x: N, y: ToNonZero<N>) => N;
|
|
99
102
|
}>;
|
|
100
103
|
type OperatorsForInteger<ElementType extends Int, MIN_VALUE extends number, MAX_VALUE extends number, ElementTypeWithSmallInt extends WithSmallInt<ElementType> = WithSmallInt<ElementType>> = Readonly<{
|
|
101
104
|
MIN_VALUE: MIN_VALUE;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refined-number-utils.d.mts","sourceRoot":"","sources":["../../src/number/refined-number-utils.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,GAAG,EACR,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAClB,MAAM,eAAe,CAAC;AAKvB,gBAAgB;AAChB,yBAAiB,oBAAoB,CAAC;IACpC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,UAAiB,kBAAkB,CAAC;QAclC,KAAK,kBAAkB,GAAG,eAAe,CAAC,YAAY,EAAE,MAAM,CAAC,CAAC;QAEhE;;;;;WAKG;QACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,kBAAkB,IAAI,cAAc,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAEzE,KAAK,SAAS,CAAC,CAAC,SAAS,kBAAkB,IAAI,cAAc,CAC3D,CAAC,EACD,aAAa,CACd,CAAC;QAMF,KAAK,wBAAwB,CAAC,CAAC,SAAS,GAAG,IAAI,YAAY,CACzD,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CACxB,CAAC;QAEF;;;;;WAKG;QACH,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,kBAAkB,
|
|
1
|
+
{"version":3,"file":"refined-number-utils.d.mts","sourceRoot":"","sources":["../../src/number/refined-number-utils.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,GAAG,EACR,KAAK,cAAc,EACnB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,MAAM,EACX,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EAClB,MAAM,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S,EAAE,SAAS,CAAC;YACrB,iBAAiB,EAAE,MAAM,CAAC;SAC3B,CAAC,KAAG,iBAAiB,CAAC,WAAW,EAAE,SAAS,EAAE,SAAS,CAoFvD,CAAC;;KACH;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refined-number-utils.mjs","sources":["../../src/number/refined-number-utils.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"refined-number-utils.mjs","sources":["../../src/number/refined-number-utils.mts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAoBA;IACiB;AAAjB,CAAA,UAAiB,oBAAoB,EAAA;AAuBnC,IAAA,CAAA,UAAiB,kBAAkB,EAAA;AACjC,QAAA,MAAM,YAAY,GAChB,CACE,EAAmC,EACnC,sBAA8B,KAEhC,CAAmB,CAAI,KAAqB;AAC1C,YAAA,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE;gBACV,MAAM,IAAI,SAAS,CAAC,CAAA,SAAA,EAAY,sBAAsB,CAAA,OAAA,EAAU,CAAC,CAAA,CAAE,CAAC;;AAGtE,YAAA,OAAO,CAAC;AACV,QAAA,CAAC;QAiBH,MAAM,SAAS,GAAG,CAChB,CAAI,KACsB,CAAC,KAAK,CAAC;QAoJnC,MAAM,eAAe,GAAG,CACtB,GAAuB,EACvB,GAAuB,KAEvB,GAAG,KAAK;cACJ,GAAG,KAAK;AACR,kBAAE;kBACA,CAAC,CAAC,KAAK,CAAC,IAAI;cACd,GAAG,KAAK;kBACN,CAAC,CAAC,KAAK,GAAG,IAAI;kBACd,GAAG,CAAC,kBAAkB,CAAC,GAAG,EAAE,GAAG,CAAC;QAExC,MAAM,kBAAkB,GAAG,CACzB,GAAuB,EACvB,GAAuB,KAEvB,GAAG,KAAK;cACJ,GAAG,KAAK;AACR,kBAAE;AACF,kBAAE,CAAC,CAAC,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;cACxB,GAAG,KAAK;A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SAAS;gBACT,EAAE;gBACF,GAAG;AACH,gBAAA,GAAG,EAAE,IAAI;AACT,gBAAA,GAAG,EAAE,IAAI;gBACT,GAAG;gBACH,GAAG;gBACH,GAAG;gBACH,GAAG;gBACH,GAAG;gBACH,MAAM;gBACN,aAAa;gBACb,QAAQ;;AAGR,gBAAA,KAAK,EAAE,KAEuB;aACtB;AACZ,QAAA,CAAC;AACH,IAAA,CAAC,EAlpBgB,oBAAA,CAAA,kBAAkB,KAAlB,uCAAkB,GAAA,EAAA,CAAA,CAAA;AAmpBrC,CAAC,EA1qBgB,oBAAoB,KAApB,oBAAoB,GAAA,EAAA,CAAA,CAAA;;;;"}
|
package/dist/object/object.mjs
CHANGED
|
@@ -2,9 +2,15 @@ import '../number/branded-types/finite-number.mjs';
|
|
|
2
2
|
import '../number/branded-types/int.mjs';
|
|
3
3
|
import '../number/branded-types/int16.mjs';
|
|
4
4
|
import '../number/branded-types/int32.mjs';
|
|
5
|
+
import '../number/branded-types/negative-finite-number.mjs';
|
|
6
|
+
import '../number/branded-types/negative-int.mjs';
|
|
7
|
+
import '../number/branded-types/negative-safe-int.mjs';
|
|
5
8
|
import '../number/branded-types/non-negative-finite-number.mjs';
|
|
6
9
|
import '../number/branded-types/non-negative-int16.mjs';
|
|
7
10
|
import '../number/branded-types/non-negative-int32.mjs';
|
|
11
|
+
import '../number/branded-types/non-positive-finite-number.mjs';
|
|
12
|
+
import '../number/branded-types/non-positive-int.mjs';
|
|
13
|
+
import '../number/branded-types/non-positive-safe-int.mjs';
|
|
8
14
|
import '../number/branded-types/non-zero-finite-number.mjs';
|
|
9
15
|
import '../number/branded-types/non-zero-int.mjs';
|
|
10
16
|
import '../number/branded-types/non-zero-int16.mjs';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.mjs","sources":["../../src/object/object.mts"],"sourcesContent":[null],"names":["Arr.isNonEmpty"],"mappings":"
|
|
1
|
+
{"version":3,"file":"object.mjs","sources":["../../src/object/object.mts"],"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"private": false,
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -42,6 +42,9 @@
|
|
|
42
42
|
"clean": "pnpm run /clean:.*/",
|
|
43
43
|
"clean:logs": "npx rimraf ./*.log",
|
|
44
44
|
"codemod": "run-s codemod:uncommitted:as-const fmt codemod:uncommitted:readonly fmt",
|
|
45
|
+
"codemod:diff": "run-s codemod:diff:as-const fmt codemod:diff:readonly fmt",
|
|
46
|
+
"codemod:diff:as-const": "append-as-const --diff-from origin/main '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
47
|
+
"codemod:diff:readonly": "convert-to-readonly --diff-from origin/main '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
45
48
|
"codemod:full": "run-s codemod:full:as-const fmt codemod:full:readonly fmt",
|
|
46
49
|
"codemod:full:as-const": "append-as-const '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
47
50
|
"codemod:full:readonly": "convert-to-readonly '{src,scripts,samples,test}/**/*.{mts,tsx}'",
|
|
@@ -83,7 +86,7 @@
|
|
|
83
86
|
},
|
|
84
87
|
"dependencies": {
|
|
85
88
|
"@sindresorhus/is": "^8.1.0",
|
|
86
|
-
"ts-type-forge": "^
|
|
89
|
+
"ts-type-forge": "^4.0.0"
|
|
87
90
|
},
|
|
88
91
|
"devDependencies": {
|
|
89
92
|
"@emotion/react": "11.14.0",
|
package/src/functional/pipe.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { expectType } from '../expect-type.mjs';
|
|
2
2
|
import { Optional, type UnknownOptional } from './optional/index.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -19,36 +19,71 @@ import { Optional, type UnknownOptional } from './optional/index.mjs';
|
|
|
19
19
|
* @param a The initial value to wrap in a pipe.
|
|
20
20
|
* @returns A pipe object with chaining methods appropriate for the value type.
|
|
21
21
|
*/
|
|
22
|
-
export
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
22
|
+
export const pipe = <const A,>(a: A): Pipe<A> =>
|
|
23
|
+
// eslint-disable-next-line total-functions/no-unsafe-type-assertion
|
|
24
|
+
({
|
|
25
|
+
value: a,
|
|
26
|
+
map: (fn) => pipe(fn(a)),
|
|
27
|
+
mapNullable: (fn) => pipe(a == null ? undefined : fn(a)),
|
|
28
|
+
|
|
29
|
+
...(Optional.isOptional(a)
|
|
30
|
+
? {
|
|
31
|
+
mapOptional: (fn) => pipe(Optional.map(a, fn)),
|
|
32
|
+
}
|
|
33
|
+
: {}),
|
|
34
|
+
}) satisfies PipeImpl<A> as unknown as Pipe<A>;
|
|
35
|
+
|
|
36
|
+
// `PipeBase<A>` is always present; the conditional only *adds* `mapOptional`
|
|
37
|
+
// for Optional values. Two subtleties motivate this shape:
|
|
38
|
+
//
|
|
39
|
+
// 1. The check is `[A] extends [UnknownOptional]` (a 1-tuple), not the bare
|
|
40
|
+
// `A extends UnknownOptional`. A bare check distributes over unions, so a
|
|
41
|
+
// piped union value such as `Result<D, E> | undefined` would expand into
|
|
42
|
+
// `Pipe<Ok<D>> | Pipe<Err<E>> | Pipe<undefined>`. Calling a chained method
|
|
43
|
+
// on that union of pipe objects forces TypeScript to synthesize a merged
|
|
44
|
+
// call signature, during which a branded member like `Ok<D>` is widened to
|
|
45
|
+
// its constraint (`Ok<number>`) — losing the brand `D`.
|
|
46
|
+
//
|
|
47
|
+
// 2. `value: A` lives on `PipeBase<A>`, *outside* the conditional. If `value`
|
|
48
|
+
// flowed through the conditional, then for a not-yet-resolved generic `A`
|
|
49
|
+
// the deferred true branch narrows `A` to `A & UnknownOptional`, so
|
|
50
|
+
// `.value` would surface as the noisy `(A & UnknownOptional) | A`. Keeping
|
|
51
|
+
// it on the unconditional base yields a clean `A`.
|
|
52
|
+
// transformer-ignore-next-line convert-to-readonly
|
|
53
|
+
export type Pipe<A> = PipeBase<A> &
|
|
54
|
+
PipeMapNullable<A> &
|
|
55
|
+
([A] extends [UnknownOptional] ? PipeMapOptional<A> : unknown);
|
|
56
|
+
|
|
57
|
+
// NOTE: 以下では 'typing when used with generics' test で型エラーが出る。
|
|
58
|
+
// 詳細は documents/reports/pipe-typing.md の 「mapNullable を条件付きで含めるのがうまくいかない理由」を参照。
|
|
59
|
+
// export type Pipe<A> = PipeBase<A> &
|
|
60
|
+
// ([A] extends [UnknownOptional] ? PipeMapOptional<A> : unknown) &
|
|
61
|
+
// ([undefined] extends [A] ? PipeMapNullable<A> : unknown) &
|
|
62
|
+
// ([null] extends [A] ? PipeMapNullable<A> : unknown);
|
|
63
|
+
|
|
64
|
+
expectType<Optional<number>, UnknownOptional>('<=');
|
|
65
|
+
|
|
66
|
+
expectType<number | undefined, undefined>('>=');
|
|
67
|
+
|
|
68
|
+
expectType<keyof Pipe<number | undefined>, 'value' | 'map' | 'mapNullable'>(
|
|
69
|
+
'=',
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
expectType<
|
|
73
|
+
keyof Pipe<Optional<number>>,
|
|
74
|
+
'value' | 'map' | 'mapNullable' | 'mapOptional'
|
|
75
|
+
>('=');
|
|
76
|
+
|
|
77
|
+
expectType<
|
|
78
|
+
keyof Pipe<Optional<number | undefined>>,
|
|
79
|
+
'value' | 'map' | 'mapNullable' | 'mapOptional'
|
|
80
|
+
>('=');
|
|
81
|
+
|
|
82
|
+
expectType<
|
|
83
|
+
keyof Pipe<Optional<number> | undefined>,
|
|
84
|
+
'value' | 'map' | 'mapNullable'
|
|
85
|
+
>('=');
|
|
45
86
|
|
|
46
|
-
/**
|
|
47
|
-
* @template A The type of the current value in the pipe.
|
|
48
|
-
* @internal
|
|
49
|
-
* Base pipe interface providing core functionality.
|
|
50
|
-
* All pipe types extend this interface.
|
|
51
|
-
*/
|
|
52
87
|
type PipeBase<A> = Readonly<{
|
|
53
88
|
/** The current value being piped. */
|
|
54
89
|
value: A;
|
|
@@ -71,7 +106,9 @@ type PipeBase<A> = Readonly<{
|
|
|
71
106
|
* @returns A new pipe containing the transformed value.
|
|
72
107
|
*/
|
|
73
108
|
map: <B>(fn: (a: A) => B) => Pipe<B>;
|
|
109
|
+
}>;
|
|
74
110
|
|
|
111
|
+
type PipeMapNullable<A> = Readonly<{
|
|
75
112
|
/**
|
|
76
113
|
* Maps the current value only if it's not null or undefined. If the current
|
|
77
114
|
* value is null/undefined, the transformation is skipped and undefined is
|
|
@@ -100,56 +137,45 @@ type PipeBase<A> = Readonly<{
|
|
|
100
137
|
mapNullable: <B>(fn: (a: NonNullable<A>) => B) => Pipe<B | undefined>;
|
|
101
138
|
}>;
|
|
102
139
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
* ```
|
|
133
|
-
*
|
|
134
|
-
* @template B The type of the transformed inner value.
|
|
135
|
-
* @param fn Function to transform the inner value of the Optional.
|
|
136
|
-
* @returns A new pipe containing an Optional with the transformed value.
|
|
137
|
-
*/
|
|
138
|
-
mapOptional: <B>(fn: (a: Optional.Unwrap<A>) => B) => Pipe<Optional<B>>;
|
|
139
|
-
}>
|
|
140
|
-
>;
|
|
140
|
+
type PipeMapOptional<A extends UnknownOptional> = Readonly<{
|
|
141
|
+
/**
|
|
142
|
+
* Maps the value inside an Optional using Optional.map semantics. If the
|
|
143
|
+
* Optional is None, the transformation is skipped and None is propagated.
|
|
144
|
+
* If the Optional is Some, the transformation is applied to the inner
|
|
145
|
+
* value.
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
*
|
|
149
|
+
* ```ts
|
|
150
|
+
* const result = pipe(Optional.some(10))
|
|
151
|
+
* .mapOptional((value) => value * 2)
|
|
152
|
+
* .mapOptional((value) => value + 5);
|
|
153
|
+
*
|
|
154
|
+
* assert.deepStrictEqual(result.value, Optional.some(25));
|
|
155
|
+
*
|
|
156
|
+
* const empty = pipe(Optional.none as Optional<number>).mapOptional(
|
|
157
|
+
* (value) => value * 2,
|
|
158
|
+
* );
|
|
159
|
+
*
|
|
160
|
+
* assert.isTrue(Optional.isNone(empty.value));
|
|
161
|
+
* ```
|
|
162
|
+
*
|
|
163
|
+
* @template B The type of the transformed inner value.
|
|
164
|
+
* @param fn Function to transform the inner value of the Optional.
|
|
165
|
+
* @returns A new pipe containing an Optional with the transformed value.
|
|
166
|
+
*/
|
|
167
|
+
mapOptional: <B>(fn: (a: Optional.Unwrap<A>) => B) => Pipe<Optional<B>>;
|
|
168
|
+
}>;
|
|
141
169
|
|
|
142
170
|
/** @internal */
|
|
143
171
|
type Cast<T, U> = T & U;
|
|
144
172
|
|
|
145
173
|
/** @internal */
|
|
146
|
-
type PipeImpl<A> =
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
}>
|
|
155
|
-
>;
|
|
174
|
+
type PipeImpl<A> = Readonly<{
|
|
175
|
+
value: A;
|
|
176
|
+
map: <B>(fn: (a: A) => B) => PipeImpl<B>;
|
|
177
|
+
mapNullable?: <B>(fn: (a: NonNullable<A>) => B) => PipeImpl<B | undefined>;
|
|
178
|
+
mapOptional?: <B>(
|
|
179
|
+
fn: (a: Optional.Unwrap<Cast<A, UnknownOptional>>) => B,
|
|
180
|
+
) => PipeImpl<Optional<B>>;
|
|
181
|
+
}>;
|