type-plus 6.8.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 +1053 -356
- package/cjs/array/{array.d.ts → array.at.d.ts} +4 -14
- package/cjs/array/array.at.d.ts.map +1 -0
- package/cjs/array/{pad_left.js → array.at.js} +1 -1
- package/cjs/array/array.at.js.map +1 -0
- package/cjs/array/array.concat.d.ts +13 -0
- package/cjs/array/array.concat.d.ts.map +1 -0
- package/cjs/array/array.concat.js +3 -0
- package/cjs/array/array.concat.js.map +1 -0
- package/cjs/array/array.entries.d.ts +17 -0
- package/cjs/array/array.entries.d.ts.map +1 -0
- package/cjs/array/array.entries.js +3 -0
- package/cjs/array/array.entries.js.map +1 -0
- package/cjs/array/array.find.d.ts +21 -0
- package/cjs/array/array.find.d.ts.map +1 -0
- package/cjs/array/{find_first.js → array.find.js} +1 -1
- package/cjs/array/array.find.js.map +1 -0
- package/cjs/array/array.find_last.d.ts +17 -0
- package/cjs/array/array.find_last.d.ts.map +1 -0
- package/cjs/array/array.find_last.js +3 -0
- package/cjs/array/array.find_last.js.map +1 -0
- package/cjs/array/array.reverse.d.ts +2 -0
- package/cjs/array/array.reverse.d.ts.map +1 -0
- package/cjs/array/array.reverse.js +3 -0
- package/cjs/array/array.reverse.js.map +1 -0
- package/cjs/array/array.some.d.ts +29 -0
- package/cjs/array/array.some.d.ts.map +1 -0
- package/cjs/array/array.some.js +3 -0
- package/cjs/array/array.some.js.map +1 -0
- package/cjs/array/array_index.d.ts +8 -8
- package/cjs/array/array_index.d.ts.map +1 -1
- package/cjs/array/array_plus.d.ts +9 -1
- package/cjs/array/array_plus.d.ts.map +1 -1
- package/cjs/array/array_plus.split_at.d.ts +30 -0
- package/cjs/array/array_plus.split_at.d.ts.map +1 -0
- package/cjs/array/array_plus.split_at.js +3 -0
- package/cjs/array/array_plus.split_at.js.map +1 -0
- package/cjs/array/drop.d.ts +2 -2
- package/cjs/array/drop.d.ts.map +1 -1
- package/cjs/array/index.d.ts +4 -5
- package/cjs/array/index.d.ts.map +1 -1
- package/cjs/array/index.js +4 -5
- package/cjs/array/index.js.map +1 -1
- package/cjs/array/pad_start.d.ts +32 -0
- package/cjs/array/pad_start.d.ts.map +1 -0
- package/cjs/array/{find_last.js → pad_start.js} +1 -1
- package/cjs/array/pad_start.js.map +1 -0
- package/cjs/assertion/assert_type.d.ts +3 -0
- package/cjs/assertion/assert_type.d.ts.map +1 -1
- package/cjs/assertion/assert_type.js +3 -0
- package/cjs/assertion/assert_type.js.map +1 -1
- package/cjs/bigint/cast.d.ts +10 -0
- package/cjs/bigint/cast.d.ts.map +1 -0
- package/cjs/{array/some.js → bigint/cast.js} +1 -1
- package/cjs/bigint/cast.js.map +1 -0
- package/cjs/equal/equal.d.ts +51 -3
- package/cjs/equal/equal.d.ts.map +1 -1
- package/cjs/functional/Maybe.d.ts +2 -2
- package/cjs/functional/Maybe.d.ts.map +1 -1
- package/cjs/index.d.ts +16 -7
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +6 -1
- package/cjs/index.js.map +1 -1
- package/cjs/math/abs.d.ts +6 -0
- package/cjs/math/abs.d.ts.map +1 -0
- package/cjs/math/{Add.js → abs.js} +1 -1
- package/cjs/math/abs.js.map +1 -0
- package/cjs/math/add.d.ts +7 -0
- package/cjs/math/add.d.ts.map +1 -0
- package/cjs/math/{Max.js → add.js} +1 -1
- package/cjs/math/add.js.map +1 -0
- package/cjs/math/greater_than.d.ts +4 -0
- package/cjs/math/greater_than.d.ts.map +1 -0
- package/cjs/math/greater_than.js +3 -0
- package/cjs/math/greater_than.js.map +1 -0
- package/cjs/math/index.d.ts +6 -6
- package/cjs/math/index.d.ts.map +1 -1
- package/cjs/math/math_plus.d.ts +5 -0
- package/cjs/math/math_plus.d.ts.map +1 -0
- package/cjs/math/math_plus.js +3 -0
- package/cjs/math/math_plus.js.map +1 -0
- package/cjs/math/math_plus.to_negative.d.ts +13 -0
- package/cjs/math/math_plus.to_negative.d.ts.map +1 -0
- package/cjs/math/math_plus.to_negative.js +3 -0
- package/cjs/math/math_plus.to_negative.js.map +1 -0
- package/cjs/math/max.d.ts +4 -0
- package/cjs/math/max.d.ts.map +1 -0
- package/cjs/math/{Abs.js → max.js} +1 -1
- package/cjs/math/max.js.map +1 -0
- package/cjs/math/multiply.d.ts +6 -0
- package/cjs/math/multiply.d.ts.map +1 -0
- package/cjs/{array/array.js → math/multiply.js} +1 -1
- package/cjs/math/multiply.js.map +1 -0
- package/cjs/math/numeric_struct.d.ts +1469 -0
- package/cjs/math/numeric_struct.d.ts.map +1 -0
- package/cjs/math/numeric_struct.js +3 -0
- package/cjs/math/numeric_struct.js.map +1 -0
- package/cjs/math/subtract.d.ts +7 -0
- package/cjs/math/subtract.d.ts.map +1 -0
- package/cjs/math/subtract.js +3 -0
- package/cjs/math/subtract.js.map +1 -0
- package/cjs/nominal/brand.js +2 -2
- package/cjs/nominal/brand.js.map +1 -1
- package/cjs/nominal/flavor.js +2 -2
- package/cjs/nominal/flavor.js.map +1 -1
- package/cjs/number/cast.d.ts +10 -0
- package/cjs/number/cast.d.ts.map +1 -0
- package/cjs/number/cast.js +3 -0
- package/cjs/number/cast.js.map +1 -0
- package/cjs/number/number_array.d.ts +0 -2
- package/cjs/number/number_array.d.ts.map +1 -1
- package/cjs/number/number_array.js +14 -1
- package/cjs/number/number_array.js.map +1 -1
- package/cjs/number/number_plus.d.ts +4 -5
- package/cjs/number/number_plus.d.ts.map +1 -1
- package/cjs/number/strict_number_type.d.ts +12 -0
- package/cjs/number/strict_number_type.d.ts.map +1 -1
- package/cjs/numeric/cast.d.ts +27 -0
- package/cjs/numeric/cast.d.ts.map +1 -0
- package/cjs/numeric/cast.js +3 -0
- package/cjs/numeric/cast.js.map +1 -0
- package/{esm/number → cjs/numeric}/integer.d.ts +2 -0
- package/cjs/numeric/integer.d.ts.map +1 -0
- package/cjs/{number → numeric}/integer.js.map +1 -1
- package/cjs/numeric/negative.d.ts.map +1 -0
- package/cjs/{number → numeric}/negative.js.map +1 -1
- package/cjs/numeric/numeric_plus.d.ts +5 -0
- package/cjs/numeric/numeric_plus.d.ts.map +1 -0
- package/cjs/numeric/numeric_plus.js +3 -0
- package/cjs/numeric/numeric_plus.js.map +1 -0
- package/cjs/numeric/numeric_type.d.ts.map +1 -0
- package/cjs/{number → numeric}/numeric_type.js.map +1 -1
- package/cjs/{number → numeric}/positive.d.ts +2 -2
- package/cjs/numeric/positive.d.ts.map +1 -0
- package/cjs/{number → numeric}/positive.js.map +1 -1
- package/cjs/object/ANotB.d.ts +3 -3
- package/cjs/object/ANotB.d.ts.map +1 -1
- package/cjs/object/Partial.d.ts +6 -0
- package/cjs/object/Partial.d.ts.map +1 -1
- package/cjs/object/Required.d.ts +4 -0
- package/cjs/object/Required.d.ts.map +1 -1
- package/cjs/object/index.d.ts +1 -1
- package/cjs/object/index.d.ts.map +1 -1
- package/cjs/object/object_type.d.ts +1 -1
- package/cjs/object/split.d.ts +3 -1
- package/cjs/object/split.d.ts.map +1 -1
- package/cjs/object/split.js.map +1 -1
- package/cjs/predicates/CanAssign.d.ts +35 -0
- package/cjs/predicates/CanAssign.d.ts.map +1 -1
- package/cjs/predicates/CanAssign.js.map +1 -1
- package/cjs/predicates/Extends.d.ts +2 -2
- package/cjs/predicates/Extends.d.ts.map +1 -1
- package/cjs/predicates/index.d.ts +0 -1
- package/cjs/predicates/index.d.ts.map +1 -1
- package/cjs/predicates/index.js +0 -1
- package/cjs/predicates/index.js.map +1 -1
- package/cjs/testing/stub.d.ts.map +1 -1
- package/cjs/testing/stub.js +4 -3
- package/cjs/testing/stub.js.map +1 -1
- package/cjs/testing/test_type.d.ts +125 -50
- package/cjs/testing/test_type.d.ts.map +1 -1
- package/cjs/testing/test_type.js +4 -141
- package/cjs/testing/test_type.js.map +1 -1
- package/cjs/tuple/create_tuple.d.ts +28 -0
- package/cjs/tuple/create_tuple.d.ts.map +1 -0
- package/cjs/{array → tuple}/create_tuple.js.map +1 -1
- package/cjs/tuple/tuple_plus.d.ts +2 -0
- package/cjs/tuple/tuple_plus.d.ts.map +1 -0
- package/cjs/tuple/tuple_plus.js +18 -0
- package/cjs/tuple/tuple_plus.js.map +1 -0
- package/cjs/tuple/tuple_plus.pad_start.d.ts +22 -0
- package/cjs/tuple/tuple_plus.pad_start.d.ts.map +1 -0
- package/cjs/tuple/tuple_plus.pad_start.js +3 -0
- package/cjs/tuple/tuple_plus.pad_start.js.map +1 -0
- package/cjs/{predicates/isType.d.ts → type-guard/is_type.d.ts} +5 -3
- package/cjs/type-guard/is_type.d.ts.map +1 -0
- package/cjs/{predicates/isType.js → type-guard/is_type.js} +8 -2
- package/cjs/type-guard/is_type.js.map +1 -0
- package/esm/array/{array.d.ts → array.at.d.ts} +4 -14
- package/esm/array/array.at.d.ts.map +1 -0
- package/esm/array/array.at.js +2 -0
- package/esm/array/array.at.js.map +1 -0
- package/esm/array/array.concat.d.ts +13 -0
- package/esm/array/array.concat.d.ts.map +1 -0
- package/esm/array/array.concat.js +2 -0
- package/esm/array/array.concat.js.map +1 -0
- package/esm/array/array.entries.d.ts +17 -0
- package/esm/array/array.entries.d.ts.map +1 -0
- package/esm/array/array.entries.js +2 -0
- package/esm/array/array.entries.js.map +1 -0
- package/esm/array/array.find.d.ts +21 -0
- package/esm/array/array.find.d.ts.map +1 -0
- package/esm/array/array.find.js +2 -0
- package/esm/array/array.find.js.map +1 -0
- package/esm/array/array.find_last.d.ts +17 -0
- package/esm/array/array.find_last.d.ts.map +1 -0
- package/esm/array/array.find_last.js +2 -0
- package/esm/array/array.find_last.js.map +1 -0
- package/esm/array/array.reverse.d.ts +2 -0
- package/esm/array/array.reverse.d.ts.map +1 -0
- package/esm/array/array.reverse.js +2 -0
- package/esm/array/array.reverse.js.map +1 -0
- package/esm/array/array.some.d.ts +29 -0
- package/esm/array/array.some.d.ts.map +1 -0
- package/esm/array/array.some.js +2 -0
- package/esm/array/array.some.js.map +1 -0
- package/esm/array/array_index.d.ts +8 -8
- package/esm/array/array_index.d.ts.map +1 -1
- package/esm/array/array_plus.d.ts +9 -1
- package/esm/array/array_plus.d.ts.map +1 -1
- package/esm/array/array_plus.split_at.d.ts +30 -0
- package/esm/array/array_plus.split_at.d.ts.map +1 -0
- package/esm/array/array_plus.split_at.js +2 -0
- package/esm/array/array_plus.split_at.js.map +1 -0
- package/esm/array/drop.d.ts +2 -2
- package/esm/array/drop.d.ts.map +1 -1
- package/esm/array/index.d.ts +4 -5
- package/esm/array/index.d.ts.map +1 -1
- package/esm/array/index.js +4 -5
- package/esm/array/index.js.map +1 -1
- package/esm/array/pad_start.d.ts +32 -0
- package/esm/array/pad_start.d.ts.map +1 -0
- package/esm/array/pad_start.js +2 -0
- package/esm/array/pad_start.js.map +1 -0
- package/esm/assertion/assert_type.d.ts +3 -0
- package/esm/assertion/assert_type.d.ts.map +1 -1
- package/esm/assertion/assert_type.js +3 -0
- package/esm/assertion/assert_type.js.map +1 -1
- package/esm/bigint/cast.d.ts +10 -0
- package/esm/bigint/cast.d.ts.map +1 -0
- package/esm/bigint/cast.js +2 -0
- package/esm/bigint/cast.js.map +1 -0
- package/esm/equal/equal.d.ts +51 -3
- package/esm/equal/equal.d.ts.map +1 -1
- package/esm/functional/Maybe.d.ts +2 -2
- package/esm/functional/Maybe.d.ts.map +1 -1
- package/esm/index.d.ts +16 -7
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +5 -0
- package/esm/index.js.map +1 -1
- package/esm/math/abs.d.ts +6 -0
- package/esm/math/abs.d.ts.map +1 -0
- package/esm/math/abs.js +2 -0
- package/esm/math/abs.js.map +1 -0
- package/esm/math/add.d.ts +7 -0
- package/esm/math/add.d.ts.map +1 -0
- package/esm/math/add.js +2 -0
- package/esm/math/add.js.map +1 -0
- package/esm/math/greater_than.d.ts +4 -0
- package/esm/math/greater_than.d.ts.map +1 -0
- package/esm/math/greater_than.js +2 -0
- package/esm/math/greater_than.js.map +1 -0
- package/esm/math/index.d.ts +6 -6
- package/esm/math/index.d.ts.map +1 -1
- package/esm/math/math_plus.d.ts +5 -0
- package/esm/math/math_plus.d.ts.map +1 -0
- package/esm/math/math_plus.js +2 -0
- package/esm/math/math_plus.js.map +1 -0
- package/esm/math/math_plus.to_negative.d.ts +13 -0
- package/esm/math/math_plus.to_negative.d.ts.map +1 -0
- package/esm/math/math_plus.to_negative.js +2 -0
- package/esm/math/math_plus.to_negative.js.map +1 -0
- package/esm/math/max.d.ts +4 -0
- package/esm/math/max.d.ts.map +1 -0
- package/esm/math/max.js +2 -0
- package/esm/math/max.js.map +1 -0
- package/esm/math/multiply.d.ts +6 -0
- package/esm/math/multiply.d.ts.map +1 -0
- package/esm/math/multiply.js +2 -0
- package/esm/math/multiply.js.map +1 -0
- package/esm/math/numeric_struct.d.ts +1469 -0
- package/esm/math/numeric_struct.d.ts.map +1 -0
- package/esm/math/numeric_struct.js +2 -0
- package/esm/math/numeric_struct.js.map +1 -0
- package/esm/math/subtract.d.ts +7 -0
- package/esm/math/subtract.d.ts.map +1 -0
- package/esm/math/subtract.js +2 -0
- package/esm/math/subtract.js.map +1 -0
- package/esm/nominal/brand.js +1 -1
- package/esm/nominal/brand.js.map +1 -1
- package/esm/nominal/flavor.js +1 -1
- package/esm/nominal/flavor.js.map +1 -1
- package/esm/number/cast.d.ts +10 -0
- package/esm/number/cast.d.ts.map +1 -0
- package/esm/number/cast.js +2 -0
- package/esm/number/cast.js.map +1 -0
- package/esm/number/number_array.d.ts +1 -2
- package/esm/number/number_array.d.ts.map +1 -1
- package/esm/number/number_array.js +14 -0
- package/esm/number/number_array.js.map +1 -1
- package/esm/number/number_plus.d.ts +4 -5
- package/esm/number/number_plus.d.ts.map +1 -1
- package/esm/number/strict_number_type.d.ts +12 -0
- package/esm/number/strict_number_type.d.ts.map +1 -1
- package/esm/numeric/cast.d.ts +27 -0
- package/esm/numeric/cast.d.ts.map +1 -0
- package/esm/numeric/cast.js +2 -0
- package/esm/numeric/cast.js.map +1 -0
- package/{cjs/number → esm/numeric}/integer.d.ts +2 -0
- package/esm/numeric/integer.d.ts.map +1 -0
- package/esm/{number → numeric}/integer.js.map +1 -1
- package/esm/numeric/negative.d.ts.map +1 -0
- package/esm/{number → numeric}/negative.js.map +1 -1
- package/esm/numeric/numeric_plus.d.ts +5 -0
- package/esm/numeric/numeric_plus.d.ts.map +1 -0
- package/esm/numeric/numeric_plus.js +2 -0
- package/esm/numeric/numeric_plus.js.map +1 -0
- package/esm/numeric/numeric_type.d.ts.map +1 -0
- package/esm/{number → numeric}/numeric_type.js.map +1 -1
- package/esm/{number → numeric}/positive.d.ts +2 -2
- package/esm/numeric/positive.d.ts.map +1 -0
- package/esm/{number → numeric}/positive.js.map +1 -1
- package/esm/object/ANotB.d.ts +3 -3
- package/esm/object/ANotB.d.ts.map +1 -1
- package/esm/object/Partial.d.ts +6 -0
- package/esm/object/Partial.d.ts.map +1 -1
- package/esm/object/Required.d.ts +4 -0
- package/esm/object/Required.d.ts.map +1 -1
- package/esm/object/index.d.ts +1 -1
- package/esm/object/index.d.ts.map +1 -1
- package/esm/object/object_type.d.ts +1 -1
- package/esm/object/split.d.ts +3 -1
- package/esm/object/split.d.ts.map +1 -1
- package/esm/object/split.js.map +1 -1
- package/esm/predicates/CanAssign.d.ts +35 -0
- package/esm/predicates/CanAssign.d.ts.map +1 -1
- package/esm/predicates/CanAssign.js.map +1 -1
- package/esm/predicates/Extends.d.ts +2 -2
- package/esm/predicates/Extends.d.ts.map +1 -1
- package/esm/predicates/index.d.ts +0 -1
- package/esm/predicates/index.d.ts.map +1 -1
- package/esm/predicates/index.js +0 -1
- package/esm/predicates/index.js.map +1 -1
- package/esm/testing/stub.d.ts.map +1 -1
- package/esm/testing/stub.js +4 -3
- package/esm/testing/stub.js.map +1 -1
- package/esm/testing/test_type.d.ts +125 -50
- package/esm/testing/test_type.d.ts.map +1 -1
- package/esm/testing/test_type.js +4 -141
- package/esm/testing/test_type.js.map +1 -1
- package/esm/tuple/create_tuple.d.ts +28 -0
- package/esm/tuple/create_tuple.d.ts.map +1 -0
- package/esm/{array → tuple}/create_tuple.js.map +1 -1
- package/esm/tuple/tuple_plus.d.ts +2 -0
- package/esm/tuple/tuple_plus.d.ts.map +1 -0
- package/esm/tuple/tuple_plus.js +2 -0
- package/esm/tuple/tuple_plus.js.map +1 -0
- package/esm/tuple/tuple_plus.pad_start.d.ts +22 -0
- package/esm/tuple/tuple_plus.pad_start.d.ts.map +1 -0
- package/esm/tuple/tuple_plus.pad_start.js +2 -0
- package/esm/tuple/tuple_plus.pad_start.js.map +1 -0
- package/esm/{predicates/isType.d.ts → type-guard/is_type.d.ts} +5 -3
- package/esm/type-guard/is_type.d.ts.map +1 -0
- package/esm/{predicates/isType.js → type-guard/is_type.js} +8 -2
- package/esm/type-guard/is_type.js.map +1 -0
- package/package.json +3 -3
- package/ts/array/{array.ts → array.at.ts} +10 -15
- package/ts/array/array.concat.ts +12 -0
- package/ts/array/array.entries.ts +24 -0
- package/ts/array/array.find.ts +32 -0
- package/ts/array/array.find_last.ts +27 -0
- package/ts/array/array.reverse.ts +16 -0
- package/ts/array/array.some.ts +53 -0
- package/ts/array/array_index.ts +16 -10
- package/ts/array/array_plus.split_at.ts +47 -0
- package/ts/array/array_plus.ts +9 -1
- package/ts/array/drop.ts +2 -2
- package/ts/array/index.ts +4 -5
- package/ts/array/pad_start.ts +43 -0
- package/ts/array/readme.md +184 -4
- package/ts/assertion/assert_type.ts +6 -0
- package/ts/assertion/readme.md +132 -1
- package/ts/bigint/cast.ts +13 -0
- package/ts/bigint/readme.md +17 -17
- package/ts/equal/equal.ts +53 -3
- package/ts/equal/readme.md +30 -16
- package/ts/functional/Maybe.ts +2 -2
- package/ts/index.ts +22 -24
- package/ts/math/README.md +97 -7
- package/ts/math/abs.ts +18 -0
- package/ts/math/add.ts +14 -0
- package/ts/math/greater_than.ts +12 -0
- package/ts/math/index.ts +7 -6
- package/ts/math/math_plus.to_negative.ts +22 -0
- package/ts/math/math_plus.ts +4 -0
- package/ts/math/max.ts +13 -0
- package/ts/math/multiply.ts +12 -0
- package/ts/math/numeric_struct.ts +658 -0
- package/ts/math/subtract.ts +14 -0
- package/ts/nominal/brand.ts +1 -1
- package/ts/nominal/flavor.ts +1 -1
- package/ts/number/cast.ts +17 -0
- package/ts/number/number_array.ts +14 -14
- package/ts/number/number_plus.ts +6 -6
- package/ts/number/readme.md +0 -108
- package/ts/number/strict_number_type.ts +12 -0
- package/ts/numeric/cast.ts +28 -0
- package/ts/{number → numeric}/integer.ts +2 -0
- package/ts/numeric/numeric_plus.ts +12 -0
- package/ts/{number → numeric}/positive.ts +2 -2
- package/ts/numeric/readme.md +115 -0
- package/ts/object/ANotB.ts +3 -3
- package/ts/object/Partial.ts +5 -0
- package/ts/object/Required.ts +4 -0
- package/ts/object/index.ts +1 -1
- package/ts/object/object_type.ts +1 -1
- package/ts/object/split.ts +3 -1
- package/ts/predicates/CanAssign.ts +46 -0
- package/ts/predicates/Extends.ts +2 -2
- package/ts/predicates/index.ts +0 -1
- package/ts/testing/stub.ts +7 -4
- package/ts/testing/test_type.ts +131 -88
- package/ts/tuple/create_tuple.ts +42 -0
- package/ts/tuple/readme.md +11 -10
- package/ts/tuple/tuple_plus.pad_start.ts +42 -0
- package/ts/tuple/tuple_plus.ts +1 -0
- package/ts/{predicates/isType.ts → type-guard/is_type.ts} +11 -3
- package/ts/type-guard/readme.md +37 -0
- package/cjs/array/array.d.ts.map +0 -1
- package/cjs/array/array.js.map +0 -1
- package/cjs/array/create_tuple.d.ts +0 -11
- package/cjs/array/create_tuple.d.ts.map +0 -1
- package/cjs/array/find_first.d.ts +0 -6
- package/cjs/array/find_first.d.ts.map +0 -1
- package/cjs/array/find_first.js.map +0 -1
- package/cjs/array/find_last.d.ts +0 -2
- package/cjs/array/find_last.d.ts.map +0 -1
- package/cjs/array/find_last.js.map +0 -1
- package/cjs/array/pad_left.d.ts +0 -6
- package/cjs/array/pad_left.d.ts.map +0 -1
- package/cjs/array/pad_left.js.map +0 -1
- package/cjs/array/some.d.ts +0 -8
- package/cjs/array/some.d.ts.map +0 -1
- package/cjs/array/some.js.map +0 -1
- package/cjs/math/Abs.d.ts +0 -3
- package/cjs/math/Abs.d.ts.map +0 -1
- package/cjs/math/Abs.js.map +0 -1
- package/cjs/math/Add.d.ts +0 -19
- package/cjs/math/Add.d.ts.map +0 -1
- package/cjs/math/Add.js.map +0 -1
- package/cjs/math/Digit.d.ts +0 -100
- package/cjs/math/Digit.d.ts.map +0 -1
- package/cjs/math/Digit.js +0 -3
- package/cjs/math/Digit.js.map +0 -1
- package/cjs/math/GreaterThan.d.ts +0 -13
- package/cjs/math/GreaterThan.d.ts.map +0 -1
- package/cjs/math/GreaterThan.js +0 -3
- package/cjs/math/GreaterThan.js.map +0 -1
- package/cjs/math/Max.d.ts +0 -4
- package/cjs/math/Max.d.ts.map +0 -1
- package/cjs/math/Max.js.map +0 -1
- package/cjs/math/Subtract.d.ts +0 -19
- package/cjs/math/Subtract.d.ts.map +0 -1
- package/cjs/math/Subtract.js +0 -3
- package/cjs/math/Subtract.js.map +0 -1
- package/cjs/number/integer.d.ts.map +0 -1
- package/cjs/number/negative.d.ts.map +0 -1
- package/cjs/number/numeric_type.d.ts.map +0 -1
- package/cjs/number/positive.d.ts.map +0 -1
- package/cjs/predicates/isType.d.ts.map +0 -1
- package/cjs/predicates/isType.js.map +0 -1
- package/esm/array/array.d.ts.map +0 -1
- package/esm/array/array.js +0 -2
- package/esm/array/array.js.map +0 -1
- package/esm/array/create_tuple.d.ts +0 -11
- package/esm/array/create_tuple.d.ts.map +0 -1
- package/esm/array/find_first.d.ts +0 -6
- package/esm/array/find_first.d.ts.map +0 -1
- package/esm/array/find_first.js +0 -2
- package/esm/array/find_first.js.map +0 -1
- package/esm/array/find_last.d.ts +0 -2
- package/esm/array/find_last.d.ts.map +0 -1
- package/esm/array/find_last.js +0 -2
- package/esm/array/find_last.js.map +0 -1
- package/esm/array/pad_left.d.ts +0 -6
- package/esm/array/pad_left.d.ts.map +0 -1
- package/esm/array/pad_left.js +0 -2
- package/esm/array/pad_left.js.map +0 -1
- package/esm/array/some.d.ts +0 -8
- package/esm/array/some.d.ts.map +0 -1
- package/esm/array/some.js +0 -2
- package/esm/array/some.js.map +0 -1
- package/esm/math/Abs.d.ts +0 -3
- package/esm/math/Abs.d.ts.map +0 -1
- package/esm/math/Abs.js +0 -2
- package/esm/math/Abs.js.map +0 -1
- package/esm/math/Add.d.ts +0 -19
- package/esm/math/Add.d.ts.map +0 -1
- package/esm/math/Add.js +0 -2
- package/esm/math/Add.js.map +0 -1
- package/esm/math/Digit.d.ts +0 -100
- package/esm/math/Digit.d.ts.map +0 -1
- package/esm/math/Digit.js +0 -2
- package/esm/math/Digit.js.map +0 -1
- package/esm/math/GreaterThan.d.ts +0 -13
- package/esm/math/GreaterThan.d.ts.map +0 -1
- package/esm/math/GreaterThan.js +0 -2
- package/esm/math/GreaterThan.js.map +0 -1
- package/esm/math/Max.d.ts +0 -4
- package/esm/math/Max.d.ts.map +0 -1
- package/esm/math/Max.js +0 -2
- package/esm/math/Max.js.map +0 -1
- package/esm/math/Subtract.d.ts +0 -19
- package/esm/math/Subtract.d.ts.map +0 -1
- package/esm/math/Subtract.js +0 -2
- package/esm/math/Subtract.js.map +0 -1
- package/esm/number/integer.d.ts.map +0 -1
- package/esm/number/negative.d.ts.map +0 -1
- package/esm/number/numeric_type.d.ts.map +0 -1
- package/esm/number/positive.d.ts.map +0 -1
- package/esm/predicates/isType.d.ts.map +0 -1
- package/esm/predicates/isType.js.map +0 -1
- package/ts/array/create_tuple.ts +0 -17
- package/ts/array/find_first.ts +0 -16
- package/ts/array/find_last.ts +0 -11
- package/ts/array/pad_left.ts +0 -16
- package/ts/array/some.ts +0 -33
- package/ts/math/Abs.ts +0 -7
- package/ts/math/Add.ts +0 -58
- package/ts/math/Digit.ts +0 -152
- package/ts/math/GreaterThan.ts +0 -55
- package/ts/math/Max.ts +0 -10
- package/ts/math/Subtract.ts +0 -57
- /package/cjs/{number → numeric}/integer.js +0 -0
- /package/cjs/{number → numeric}/negative.d.ts +0 -0
- /package/cjs/{number → numeric}/negative.js +0 -0
- /package/cjs/{number → numeric}/numeric_type.d.ts +0 -0
- /package/cjs/{number → numeric}/numeric_type.js +0 -0
- /package/cjs/{number → numeric}/positive.js +0 -0
- /package/cjs/{array → tuple}/create_tuple.js +0 -0
- /package/esm/{number → numeric}/integer.js +0 -0
- /package/esm/{number → numeric}/negative.d.ts +0 -0
- /package/esm/{number → numeric}/negative.js +0 -0
- /package/esm/{number → numeric}/numeric_type.d.ts +0 -0
- /package/esm/{number → numeric}/numeric_type.js +0 -0
- /package/esm/{number → numeric}/positive.js +0 -0
- /package/esm/{array → tuple}/create_tuple.js +0 -0
- /package/ts/{number → numeric}/negative.ts +0 -0
- /package/ts/{number → numeric}/numeric_type.ts +0 -0
package/ts/testing/test_type.ts
CHANGED
|
@@ -1,181 +1,224 @@
|
|
|
1
1
|
import type { IsAny } from '../any/any_type.js'
|
|
2
|
+
import type { IsArray } from '../array/array_type.js'
|
|
2
3
|
import type { IsBigint } from '../bigint/bigint_type.js'
|
|
3
4
|
import type { IsStrictBigint } from '../bigint/strict_bigint_type.js'
|
|
4
5
|
import type { IsBoolean } from '../boolean/boolean_type.js'
|
|
5
6
|
import type { IsFalse } from '../boolean/false_type.js'
|
|
6
7
|
import type { IsStrictBoolean } from '../boolean/strict_boolean_type.js'
|
|
7
8
|
import type { IsTrue } from '../boolean/true_type.js'
|
|
8
|
-
import type {
|
|
9
|
+
import type { IsEqual } from '../equal/equal.js'
|
|
10
|
+
import type { IsFunction } from '../function/function_type.js'
|
|
11
|
+
import type { IsStrictFunction } from '../function/strict_function_type.js'
|
|
9
12
|
import type { IsNever } from '../never/never_type.js'
|
|
10
13
|
import type { IsNull } from '../null/null_type.js'
|
|
11
14
|
import type { IsNumber } from '../number/number_type.js'
|
|
12
15
|
import type { IsStrictNumber } from '../number/strict_number_type.js'
|
|
13
|
-
import type {
|
|
16
|
+
import type { IsObject } from '../object/object_type.js'
|
|
17
|
+
import type { CanAssign, StrictCanAssign } from '../predicates/CanAssign.js'
|
|
14
18
|
import type { IsStrictString } from '../string/strict_string_type.js'
|
|
15
19
|
import type { IsString } from '../string/string_type.js'
|
|
20
|
+
import type { IsSymbol } from '../symbol/symbol_type.js'
|
|
21
|
+
import type { IsTuple } from '../tuple/tuple_type.js'
|
|
16
22
|
import type { IsUndefined } from '../undefined/undefined_type.js'
|
|
17
23
|
import type { IsUnknown } from '../unknown/unknown_type.js'
|
|
18
24
|
import type { IsVoid } from '../void/void_type.js'
|
|
19
25
|
|
|
20
|
-
|
|
21
|
-
* Check if type `A` is equal to type `B` and `C`.
|
|
22
|
-
*
|
|
23
|
-
* @return `expected` as `A` for type inspection.
|
|
24
|
-
*/
|
|
25
|
-
function equal<A, B, C>(expected: Equal<A, B> & Equal<A, C>): A
|
|
26
|
-
/**
|
|
27
|
-
* Check if type `A` is equal to type `B`.
|
|
28
|
-
*
|
|
29
|
-
* @return `expected` as `A` for type inspection.
|
|
30
|
-
*/
|
|
31
|
-
function equal<A, B>(expected: Equal<A, B>): A
|
|
32
|
-
function equal(expected: unknown) {
|
|
33
|
-
return expected
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Test utilities for types.
|
|
38
|
-
*
|
|
39
|
-
* This is designed specifically for testing.
|
|
40
|
-
* The return value is the input `expected` parameter asserted as the first type parameter,
|
|
41
|
-
* so that the type can be further inspected.
|
|
42
|
-
*/
|
|
43
|
-
export const testType = {
|
|
26
|
+
interface TestType {
|
|
44
27
|
/**
|
|
45
|
-
* Check if type `
|
|
28
|
+
* Check if type `A` is equal to type `B` and `C`.
|
|
46
29
|
*
|
|
47
|
-
* @return `expected` as `
|
|
30
|
+
* @return `expected` as `A` for type inspection.
|
|
48
31
|
*/
|
|
49
|
-
|
|
50
|
-
return expected as T
|
|
51
|
-
},
|
|
32
|
+
equal<A, B, C>(expected: IsEqual<A, B> & IsEqual<A, C>): A
|
|
52
33
|
/**
|
|
53
|
-
* Check if type `
|
|
34
|
+
* Check if type `A` is equal to type `B`.
|
|
35
|
+
*
|
|
36
|
+
* @return `expected` as `A` for type inspection.
|
|
37
|
+
*/
|
|
38
|
+
equal<A, B>(expected: IsEqual<A, B>): A
|
|
39
|
+
/**
|
|
40
|
+
* Check if `A` can assign to `B`.
|
|
41
|
+
*
|
|
42
|
+
* If `A` is a union,
|
|
43
|
+
* the check is distributive.
|
|
44
|
+
*
|
|
45
|
+
* Meaning the result can be `boolean`,
|
|
46
|
+
* meaning both `true` and `false` will pass.
|
|
47
|
+
*
|
|
48
|
+
* If you want to avoid the distributivity,
|
|
49
|
+
* use `testType.strictCanAssign()` instead.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* testType.canAssign<123, number> // true
|
|
54
|
+
*
|
|
55
|
+
* testType.canAssign<number | string, number> // boolean
|
|
56
|
+
* ```
|
|
57
|
+
*
|
|
58
|
+
* @return `expected` as `A` for type inspection.
|
|
59
|
+
*/
|
|
60
|
+
canAssign<A, B>(expected: CanAssign<A, B>): A
|
|
61
|
+
/**
|
|
62
|
+
* Check if `A` can fully assign to `B`.
|
|
63
|
+
*
|
|
64
|
+
* This checks all branches in an union `A` are assignable to `B`.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* testType.strictCanAssign<number | string, number | string> // true
|
|
69
|
+
*
|
|
70
|
+
* testType.strictCanAssign<number | string, number> // false
|
|
71
|
+
* ```
|
|
72
|
+
*
|
|
73
|
+
* @return `expected` as `A` for type inspection.
|
|
74
|
+
*/
|
|
75
|
+
strictCanAssign<A, B>(expected: StrictCanAssign<A, B>): A
|
|
76
|
+
/**
|
|
77
|
+
* Check if type `T` is exactly `any`.
|
|
54
78
|
*
|
|
55
79
|
* @return `expected` as `T` for type inspection.
|
|
56
80
|
*/
|
|
57
|
-
|
|
58
|
-
return expected as T
|
|
59
|
-
},
|
|
81
|
+
any<T>(expected: IsAny<T>): T
|
|
60
82
|
/**
|
|
61
|
-
* Check if type `T` is exactly `
|
|
83
|
+
* Check if type `T` is exactly `array`.
|
|
62
84
|
*
|
|
63
85
|
* @return `expected` as `T` for type inspection.
|
|
64
86
|
*/
|
|
65
|
-
|
|
66
|
-
return expected as T
|
|
67
|
-
},
|
|
87
|
+
array<T>(expected: IsArray<T>): T
|
|
68
88
|
/**
|
|
69
|
-
* Check if type `T` is exactly `
|
|
89
|
+
* Check if type `T` is exactly `bigint`.
|
|
70
90
|
*
|
|
71
91
|
* @return `expected` as `T` for type inspection.
|
|
72
92
|
*/
|
|
73
|
-
|
|
74
|
-
return expected as T
|
|
75
|
-
},
|
|
76
|
-
equal,
|
|
93
|
+
strictBigint<T>(expected: IsStrictBigint<T>): T
|
|
77
94
|
/**
|
|
78
|
-
* Check if `
|
|
95
|
+
* Check if type `T` is `bigint` or bigint literals.
|
|
79
96
|
*
|
|
80
|
-
* @return `expected` as `
|
|
97
|
+
* @return `expected` as `T` for type inspection.
|
|
81
98
|
*/
|
|
82
|
-
|
|
83
|
-
return expected as A
|
|
84
|
-
},
|
|
99
|
+
bigint<T>(expected: IsBigint<T>): T
|
|
85
100
|
/**
|
|
86
101
|
* Check if type `T` is exactly `boolean`.
|
|
87
102
|
*
|
|
88
103
|
* @return `expected` as `T` for type inspection.
|
|
89
104
|
*/
|
|
90
|
-
strictBoolean<T>(expected: IsStrictBoolean<T>)
|
|
91
|
-
return expected as T
|
|
92
|
-
},
|
|
105
|
+
strictBoolean<T>(expected: IsStrictBoolean<T>): T
|
|
93
106
|
/**
|
|
94
107
|
* Check if type `T` is `boolean` and boolean literals.
|
|
95
108
|
*
|
|
96
109
|
* @return `expected` as `T` for type inspection.
|
|
97
110
|
*/
|
|
98
|
-
boolean<T>(expected: IsBoolean<T>)
|
|
99
|
-
return expected as T
|
|
100
|
-
},
|
|
111
|
+
boolean<T>(expected: IsBoolean<T>): T
|
|
101
112
|
/**
|
|
102
113
|
* Check if type `T` is exactly `true`.
|
|
103
114
|
*
|
|
104
115
|
* @return `expected` as `T` for type inspection.
|
|
105
116
|
*/
|
|
106
|
-
true<T>(expected: IsTrue<T>)
|
|
107
|
-
return expected as T
|
|
108
|
-
},
|
|
117
|
+
true<T>(expected: IsTrue<T>): T
|
|
109
118
|
/**
|
|
110
119
|
* Check if type `T` is exactly `false`.
|
|
111
120
|
*
|
|
112
121
|
* @return `expected` as `T` for type inspection.
|
|
113
122
|
*/
|
|
114
|
-
false<T>(expected: IsFalse<T>)
|
|
115
|
-
|
|
116
|
-
|
|
123
|
+
false<T>(expected: IsFalse<T>): T
|
|
124
|
+
/**
|
|
125
|
+
* Check if type `T` is exactly `boolean`.
|
|
126
|
+
*
|
|
127
|
+
* @return `expected` as `T` for type inspection.
|
|
128
|
+
*/
|
|
129
|
+
strictFunction<T>(expected: IsStrictFunction<T>): T
|
|
130
|
+
/**
|
|
131
|
+
* Check if type `T` is `boolean` and boolean literals.
|
|
132
|
+
*
|
|
133
|
+
* @return `expected` as `T` for type inspection.
|
|
134
|
+
*/
|
|
135
|
+
function<T>(expected: IsFunction<T>): T
|
|
136
|
+
/**
|
|
137
|
+
* Check if type `T` is exactly `never`.
|
|
138
|
+
*
|
|
139
|
+
* @return `expected` as `T` for type inspection.
|
|
140
|
+
*/
|
|
141
|
+
never<T>(expected: IsNever<T>): T
|
|
142
|
+
/**
|
|
143
|
+
* Check if type `T` is exactly `null`.
|
|
144
|
+
*
|
|
145
|
+
* @return `expected` as `T` for type inspection.
|
|
146
|
+
*/
|
|
147
|
+
null<T>(expected: IsNull<T>): T
|
|
117
148
|
/**
|
|
118
149
|
* Check if type `T` is exactly `number`.
|
|
119
150
|
*
|
|
120
151
|
* @return `expected` as `T` for type inspection.
|
|
121
152
|
*/
|
|
122
|
-
strictNumber<T>(expected: IsStrictNumber<T>)
|
|
123
|
-
return expected as T
|
|
124
|
-
},
|
|
153
|
+
strictNumber<T>(expected: IsStrictNumber<T>): T
|
|
125
154
|
/**
|
|
126
155
|
* Check if type `T` is `number` or number literals.
|
|
127
156
|
*
|
|
128
157
|
* @return `expected` as `T` for type inspection.
|
|
129
158
|
*/
|
|
130
|
-
number<T>(expected: IsNumber<T>)
|
|
131
|
-
|
|
132
|
-
|
|
159
|
+
number<T>(expected: IsNumber<T>): T
|
|
160
|
+
/**
|
|
161
|
+
* Check if type `T` is `object`.
|
|
162
|
+
*
|
|
163
|
+
* Note that `Function`, `Array`, and *tuple* are also `object`.
|
|
164
|
+
*
|
|
165
|
+
* @return `expected` as `T` for type inspection.
|
|
166
|
+
*/
|
|
167
|
+
object<T>(expected: IsObject<T>): T
|
|
133
168
|
/**
|
|
134
169
|
* Check if type `T` is exactly `string`.
|
|
135
170
|
*
|
|
136
171
|
* @return `expected` as `T` for type inspection.
|
|
137
172
|
*/
|
|
138
|
-
strictString<T>(expected: IsStrictString<T>)
|
|
139
|
-
return expected as T
|
|
140
|
-
},
|
|
173
|
+
strictString<T>(expected: IsStrictString<T>): T
|
|
141
174
|
/**
|
|
142
175
|
* Check if type `T` is `string` or string literals.
|
|
143
176
|
*
|
|
144
177
|
* @return `expected` as `T` for type inspection.
|
|
145
178
|
*/
|
|
146
|
-
string<T>(expected: IsString<T>)
|
|
147
|
-
return expected as T
|
|
148
|
-
},
|
|
179
|
+
string<T>(expected: IsString<T>): T
|
|
149
180
|
/**
|
|
150
|
-
* Check if type `T` is
|
|
181
|
+
* Check if type `T` is a `symbol`.
|
|
151
182
|
*
|
|
152
183
|
* @return `expected` as `T` for type inspection.
|
|
153
184
|
*/
|
|
154
|
-
|
|
155
|
-
return expected as T
|
|
156
|
-
},
|
|
185
|
+
symbol<T>(expected: IsSymbol<T>): T
|
|
157
186
|
/**
|
|
158
|
-
* Check if type `T` is
|
|
187
|
+
* Check if type `T` is a *tuple*.
|
|
159
188
|
*
|
|
160
189
|
* @return `expected` as `T` for type inspection.
|
|
161
190
|
*/
|
|
162
|
-
|
|
163
|
-
return expected as T
|
|
164
|
-
},
|
|
191
|
+
tuple<T>(expected: IsTuple<T>): T
|
|
165
192
|
/**
|
|
166
193
|
* Check if type `T` is exactly `undefined`.
|
|
167
194
|
*
|
|
168
195
|
* @return `expected` as `T` for type inspection.
|
|
169
196
|
*/
|
|
170
|
-
undefined<T>(expected: IsUndefined<T>)
|
|
171
|
-
|
|
172
|
-
},
|
|
197
|
+
undefined<T>(expected: IsUndefined<T>): T
|
|
198
|
+
// hasUndefined<T>(expected: CanAssign<T, undefined>): T
|
|
173
199
|
/**
|
|
174
|
-
* Check if type `T` is exactly `
|
|
200
|
+
* Check if type `T` is exactly `unknown`.
|
|
175
201
|
*
|
|
176
202
|
* @return `expected` as `T` for type inspection.
|
|
177
203
|
*/
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
204
|
+
unknown<T>(expected: IsUnknown<T>): T
|
|
205
|
+
/**
|
|
206
|
+
* Check if type `T` is exactly `void`.
|
|
207
|
+
*
|
|
208
|
+
* @return `expected` as `T` for type inspection.
|
|
209
|
+
*/
|
|
210
|
+
void<T>(expected: IsVoid<T>): T
|
|
181
211
|
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Test utilities for types.
|
|
215
|
+
*
|
|
216
|
+
* This is designed specifically for testing.
|
|
217
|
+
* The return value is the input `expected` parameter asserted as the first type parameter,
|
|
218
|
+
* so that the type can be further inspected.
|
|
219
|
+
*/
|
|
220
|
+
export const testType = new Proxy({} as TestType, {
|
|
221
|
+
get(_target, _prop, _receiver) {
|
|
222
|
+
return (expected: unknown) => expected
|
|
223
|
+
}
|
|
224
|
+
})
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { DigitArray } from '../math/numeric_struct.js'
|
|
2
|
+
import type { IsInteger } from '../numeric/integer.js'
|
|
3
|
+
import type { IsPositive } from '../numeric/positive.js'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Creates `Tuple<T>` with `L` number of elements.
|
|
7
|
+
* @note Other cool implementations by @lazytype, @jcalz:
|
|
8
|
+
* @see https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787
|
|
9
|
+
* @see https://github.com/microsoft/TypeScript/issues/47874#issuecomment-1039157322
|
|
10
|
+
*/
|
|
11
|
+
export type CreateTuple<L extends number, T = unknown, Fail = never> = number extends L
|
|
12
|
+
? T[]
|
|
13
|
+
: IsPositive<L> extends true
|
|
14
|
+
? IsInteger<L> extends true
|
|
15
|
+
? ToTuple<[], DigitArray.FromString<`${L}`>, T>
|
|
16
|
+
: Fail
|
|
17
|
+
: Fail
|
|
18
|
+
export type ToTuple<R extends any[], S extends number[], X = any> = S['length'] extends 0
|
|
19
|
+
? R
|
|
20
|
+
: S['length'] extends 1
|
|
21
|
+
? [...R, ...DigitToTuple<X>[S[0]]]
|
|
22
|
+
: S extends [any, ...infer T]
|
|
23
|
+
? T extends any[]
|
|
24
|
+
? ToTuple<Multi10<[...R, ...DigitToTuple<X>[S[0]]]>, T>
|
|
25
|
+
: never
|
|
26
|
+
: never
|
|
27
|
+
|
|
28
|
+
type DigitToTuple<T = 1> = {
|
|
29
|
+
[k in number]: any[]
|
|
30
|
+
} & {
|
|
31
|
+
0: []
|
|
32
|
+
1: [T]
|
|
33
|
+
2: [T, T]
|
|
34
|
+
3: [T, T, T]
|
|
35
|
+
4: [T, T, T, T]
|
|
36
|
+
5: [T, T, T, T, T]
|
|
37
|
+
6: [T, T, T, T, T, T]
|
|
38
|
+
7: [T, T, T, T, T, T, T]
|
|
39
|
+
8: [T, T, T, T, T, T, T, T]
|
|
40
|
+
9: [T, T, T, T, T, T, T, T, T]
|
|
41
|
+
}
|
|
42
|
+
type Multi10<C extends any[]> = [...C, ...C, ...C, ...C, ...C, ...C, ...C, ...C, ...C, ...C]
|
package/ts/tuple/readme.md
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Tuple
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
It is a "safer" variant of `any` that you cannot use the value until there are some type guards or type assertions to the value.
|
|
3
|
+
A *tuple type* is another sort of `Array` type that knows exactly how many elements it contains, and exactly which types it contains at specific positions.
|
|
5
4
|
|
|
6
5
|
## Type Checking
|
|
7
6
|
|
|
@@ -10,18 +9,20 @@ The `TupleType<T>` and friends are used to check if `T` is a tuple, excluding ar
|
|
|
10
9
|
```ts
|
|
11
10
|
import type { TupleType } from 'type-plus'
|
|
12
11
|
|
|
13
|
-
type R = TupleType<
|
|
12
|
+
type R = TupleType<[]> // []
|
|
13
|
+
type R = TupleType<[1]> // [1]
|
|
14
14
|
|
|
15
|
-
type R = TupleType<
|
|
15
|
+
type R = TupleType<number[]> // never
|
|
16
|
+
type R = TupleType<number> // never
|
|
16
17
|
```
|
|
17
18
|
|
|
18
|
-
- [`TupleType<T, Then = T, Else = never>`](
|
|
19
|
-
- [`
|
|
20
|
-
- [`
|
|
21
|
-
- [`
|
|
19
|
+
- [`TupleType<T, Then = T, Else = never>`](tuple_type.ts#L16): check if `T` is a *tuple*.
|
|
20
|
+
- [`IsTuple<T, Then = true, Else = false`](tuple_type.ts#L35): is `T` *tuple*.
|
|
21
|
+
- [`NotTupleType<T, Then = T, Else = never>`](tuple_type.ts#L50): check if `T` is not *tuple*.
|
|
22
|
+
- [`IsNotTuple<T, Then = true, Else = false>`](tuple_type.ts#L65): is `T` not *tuple*.
|
|
22
23
|
|
|
23
24
|
## References
|
|
24
25
|
|
|
25
26
|
- [Handbook]
|
|
26
27
|
|
|
27
|
-
[handbook]: https://www.typescriptlang.org/docs/handbook/2/
|
|
28
|
+
[handbook]: https://www.typescriptlang.org/docs/handbook/2/objects.html#tuple-types
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pads the start of a tuple with `PadWith`.
|
|
3
|
+
*
|
|
4
|
+
* If the `MaxLength` is less than the length of the tuple,
|
|
5
|
+
* the `Tuple` will be returned unchanged.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* PadStart<[1, 2, 3], 5, 0> // [0, 0, 1, 2, 3]
|
|
10
|
+
*
|
|
11
|
+
* // Ignore if MaxLength is less than the length of the tuple
|
|
12
|
+
* PadStart<[1, 2, 3], 5, 0> // [0, 0, 1, 2, 3]
|
|
13
|
+
*
|
|
14
|
+
* // Default to unknown
|
|
15
|
+
* PadStart<[1, 2, 3], 5> // [unknown, unknown, 1, 2, 3]
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export type PadStart<Tuple extends unknown[], MaxLength extends number, PadWith = unknown> = PadStartDevice<
|
|
19
|
+
Tuple,
|
|
20
|
+
MaxLength,
|
|
21
|
+
PadWith,
|
|
22
|
+
[]
|
|
23
|
+
>
|
|
24
|
+
|
|
25
|
+
type PadStartDevice<
|
|
26
|
+
Source extends unknown[],
|
|
27
|
+
MaxLength extends number,
|
|
28
|
+
PadWith,
|
|
29
|
+
Result extends unknown[]
|
|
30
|
+
> = Result['length'] extends MaxLength
|
|
31
|
+
? Source extends []
|
|
32
|
+
? Result
|
|
33
|
+
: Source extends [...infer Head, infer Tail]
|
|
34
|
+
? [Tail, ...Result] extends infer R extends unknown[]
|
|
35
|
+
? PadStartDevice<Head, R['length'], PadWith, R>
|
|
36
|
+
: never
|
|
37
|
+
: never
|
|
38
|
+
: Source extends []
|
|
39
|
+
? PadStartDevice<Source, MaxLength, PadWith, [PadWith, ...Result]>
|
|
40
|
+
: Source extends [...infer Head, infer Tail]
|
|
41
|
+
? PadStartDevice<Head, MaxLength, PadWith, [Tail, ...Result]>
|
|
42
|
+
: Source
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './tuple_plus.pad_start.js'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IsEqual } from '../equal/equal.js'
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Is the subject of type T
|
|
@@ -12,20 +12,28 @@ export function isType(subject: unknown, validator?: (s: unknown) => unknown) {
|
|
|
12
12
|
return validator ? !!validator(subject) : true
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* @deprecated use `isType<T>()` or `testType.true<T>()` instead
|
|
17
|
+
*/
|
|
15
18
|
isType.t = function <T extends true>(subject?: T) {
|
|
16
19
|
return subject === undefined || subject === true
|
|
17
20
|
}
|
|
18
21
|
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated use `isType<T>()` or `testType.false<T>()` instead
|
|
24
|
+
*/
|
|
19
25
|
isType.f = function <T extends false>(subject?: T) {
|
|
20
26
|
return subject === undefined || subject === false
|
|
21
27
|
}
|
|
22
28
|
|
|
23
29
|
/**
|
|
24
30
|
* Check is the type `never`
|
|
31
|
+
* @deprecated use `isType<T>()` or `testType.never<T>()` instead
|
|
25
32
|
*/
|
|
26
33
|
function isNever<S extends never>(): unknown
|
|
27
34
|
/**
|
|
28
35
|
* Check is the value is type `never`
|
|
36
|
+
* @deprecated use `isType<T>()` or `testType.never<T>()` instead
|
|
29
37
|
*/
|
|
30
38
|
function isNever(subject: never): subject is never
|
|
31
39
|
function isNever(subject?: unknown): subject is never {
|
|
@@ -39,6 +47,6 @@ isType.never = isNever
|
|
|
39
47
|
* Easier to use than `isType.t<>()` and `isType.f<>()`,
|
|
40
48
|
* when doing type level only equality comparison as you don't have to import `Equal<>`.
|
|
41
49
|
*
|
|
42
|
-
* @deprecated use `
|
|
50
|
+
* @deprecated use `testType.equal()` instead
|
|
43
51
|
*/
|
|
44
|
-
isType.equal = function <C extends
|
|
52
|
+
isType.equal = function <C extends IsEqual<A, B>, A, B>() {}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Type Guard
|
|
2
|
+
|
|
3
|
+
[User-defined type guard functions][type_guard] is a function which its return type is specified as `x as T`.
|
|
4
|
+
|
|
5
|
+
It is introduced in TypeScript 1.6.
|
|
6
|
+
|
|
7
|
+
For example:
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
function isBool(x: unknown): x is boolean {
|
|
11
|
+
return typeof x === 'boolean';
|
|
12
|
+
}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## isType
|
|
16
|
+
|
|
17
|
+
> `isType<T>(subject: T): subject is T`
|
|
18
|
+
|
|
19
|
+
✔️ `immediate`
|
|
20
|
+
|
|
21
|
+
It ensures `subject` satisfies `T`.
|
|
22
|
+
You need to specify `T`.
|
|
23
|
+
|
|
24
|
+
> `isType<T>(subject: unknown, validator: (s: T) => unknown): subject is T`
|
|
25
|
+
|
|
26
|
+
It is a generic type guard.
|
|
27
|
+
You can use it for do quick type guard without creating a custom one.
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
const s: unknown = 1
|
|
31
|
+
|
|
32
|
+
if (isType<1>(s, v => v === 1)) {
|
|
33
|
+
// s is narrowed to type `1` here.
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
[type_guard]: https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates
|
package/cjs/array/array.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../ts/array/array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE/C;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,EAAE,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,SAAS,MAAM,EAAE,IAAI,GAAG,KAAK,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,SAAS,MAAM,CAAC,GACtG,CAAC,SAAS,MAAM,GACf,CAAC,CAAC,CAAC,CAAC,GACJ,IAAI,GACL,KAAK,CAAA;AAER;;;;;;;;;;GAUG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,SAAS,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA"}
|
package/cjs/array/array.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array.js","sourceRoot":"","sources":["../../ts/array/array.ts"],"names":[],"mappings":""}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { DigitArray } from '../math/index.js';
|
|
2
|
-
import type { IsInteger } from '../number/integer.js';
|
|
3
|
-
import type { IsPositive } from '../number/positive.js';
|
|
4
|
-
/**
|
|
5
|
-
* Creates `Tuple<T>` with `L` number of elements.
|
|
6
|
-
* @note Other cool implementations by @lazytype, @jcalz:
|
|
7
|
-
* @see https://github.com/microsoft/TypeScript/issues/26223#issuecomment-674514787
|
|
8
|
-
* @see https://github.com/microsoft/TypeScript/issues/47874#issuecomment-1039157322
|
|
9
|
-
*/
|
|
10
|
-
export type CreateTuple<L extends number, T = unknown, Fail = never> = number extends L ? T[] : IsPositive<L> extends true ? IsInteger<L> extends true ? DigitArray.ToTuple<[], DigitArray.FromNumber<L>, T> : Fail : Fail;
|
|
11
|
-
//# sourceMappingURL=create_tuple.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create_tuple.d.ts","sourceRoot":"","sources":["../../ts/array/create_tuple.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AAEvD;;;;;GAKG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,GAAG,OAAO,EAAE,IAAI,GAAG,KAAK,IAAI,MAAM,SAAS,CAAC,GACpF,CAAC,EAAE,GACH,UAAU,CAAC,CAAC,CAAC,SAAS,IAAI,GAC1B,SAAS,CAAC,CAAC,CAAC,SAAS,IAAI,GACxB,UAAU,CAAC,OAAO,CAAC,EAAE,EAAE,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,GACnD,IAAI,GACL,IAAI,CAAA"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export type FindFirst<A extends Array<any>, Criteria> = number extends A['length'] ? A[0] extends Criteria ? A[0] : never : A['length'] extends 0 ? never : A extends [any, ...infer Tail] ? A[0] extends Criteria ? A[0] : FindFirst<Tail, Criteria> : never;
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated use FindFirst
|
|
4
|
-
*/
|
|
5
|
-
export type First<A extends any[], Criteria> = FindFirst<A, Criteria>;
|
|
6
|
-
//# sourceMappingURL=find_first.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find_first.d.ts","sourceRoot":"","sources":["../../ts/array/find_first.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,EAAE,QAAQ,IAAI,MAAM,SAAS,CAAC,CAAC,QAAQ,CAAC,GAC/E,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GACpB,CAAC,CAAC,CAAC,CAAC,GACJ,KAAK,GACN,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACrB,KAAK,GACL,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,MAAM,IAAI,CAAC,GAC9B,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GACpB,CAAC,CAAC,CAAC,CAAC,GACJ,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,GAC1B,KAAK,CAAA;AAER;;GAEG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,QAAQ,IAAI,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find_first.js","sourceRoot":"","sources":["../../ts/array/find_first.ts"],"names":[],"mappings":""}
|
package/cjs/array/find_last.d.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export type FindLast<A extends Array<any>, Criteria> = number extends A['length'] ? A[0] extends Criteria ? A[0] : never : A['length'] extends 0 ? never : A extends [...infer Heads, infer Last] ? Last extends Criteria ? Last : FindLast<Heads, Criteria> : never;
|
|
2
|
-
//# sourceMappingURL=find_last.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find_last.d.ts","sourceRoot":"","sources":["../../ts/array/find_last.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,EAAE,QAAQ,IAAI,MAAM,SAAS,CAAC,CAAC,QAAQ,CAAC,GAC9E,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GACpB,CAAC,CAAC,CAAC,CAAC,GACJ,KAAK,GACN,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACrB,KAAK,GACL,CAAC,SAAS,CAAC,GAAG,MAAM,KAAK,EAAE,MAAM,IAAI,CAAC,GACtC,IAAI,SAAS,QAAQ,GACpB,IAAI,GACJ,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,GAC1B,KAAK,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"find_last.js","sourceRoot":"","sources":["../../ts/array/find_last.ts"],"names":[],"mappings":""}
|
package/cjs/array/pad_left.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { IsAny } from '../any/any_type.js';
|
|
2
|
-
import type { Equal } from '../equal/equal.js';
|
|
3
|
-
import type { CreateTuple } from './create_tuple.js';
|
|
4
|
-
import type { UnionOfValues } from './union_of_values.js';
|
|
5
|
-
export type PadLeft<A extends any[], Total extends number, PadWith = any> = number extends A['length'] ? IsAny<UnionOfValues<A>> extends true ? A : Equal<UnionOfValues<A>, PadWith> extends true ? A : PadLeft<[...CreateTuple<Total, PadWith>, ...A], Total, PadWith> : CreateTuple<Total, any> extends [...infer U, ...A] ? number extends U['length'] ? A : [...CreateTuple<U['length'], PadWith>, ...A] : A;
|
|
6
|
-
//# sourceMappingURL=pad_left.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pad_left.d.ts","sourceRoot":"","sources":["../../ts/array/pad_left.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEzD,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,KAAK,SAAS,MAAM,EAAE,OAAO,GAAG,GAAG,IAAI,MAAM,SAAS,CAAC,CAAC,QAAQ,CAAC,GACnG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,GACnC,CAAC,GACD,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,SAAS,IAAI,GAC7C,CAAC,GACD,OAAO,CAAC,CAAC,GAAG,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,GAChE,WAAW,CAAC,KAAK,EAAE,GAAG,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC,GAClD,MAAM,SAAS,CAAC,CAAC,QAAQ,CAAC,GACzB,CAAC,GACD,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC,GAC7C,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"pad_left.js","sourceRoot":"","sources":["../../ts/array/pad_left.ts"],"names":[],"mappings":""}
|
package/cjs/array/some.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Equal } from '../equal/equal.js';
|
|
2
|
-
import type { Tail } from './tail.js';
|
|
3
|
-
import type { UnionOfValues } from './union_of_values.js';
|
|
4
|
-
export type Some<A extends any[], Criteria, Mode extends 'strict' | 'loose' = 'loose', Then = true, Else = false> = Mode extends 'strict' ? Some.Strict<A, Criteria, Then, Else> : number extends A['length'] ? UnionOfValues<A> extends Criteria ? Then : Else : A['length'] extends 0 ? Else : A[0] extends Criteria ? Then : Some<Tail<A>, Criteria, 'loose', Then, Else>;
|
|
5
|
-
export declare namespace Some {
|
|
6
|
-
type Strict<A extends any[], Criteria, Then, Else> = number extends A['length'] ? Equal<UnionOfValues<A>, Criteria> extends true ? Then : Else : A['length'] extends 0 ? Else : Equal<A[0], Criteria> extends true ? Then : Strict<Tail<A>, Criteria, Then, Else>;
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=some.d.ts.map
|
package/cjs/array/some.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"some.d.ts","sourceRoot":"","sources":["../../ts/array/some.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAA;AAC9C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACrC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEzD,MAAM,MAAM,IAAI,CACf,CAAC,SAAS,GAAG,EAAE,EACf,QAAQ,EACR,IAAI,SAAS,QAAQ,GAAG,OAAO,GAAG,OAAO,EACzC,IAAI,GAAG,IAAI,EACX,IAAI,GAAG,KAAK,IACT,IAAI,SAAS,QAAQ,GACtB,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,GACpC,MAAM,SAAS,CAAC,CAAC,QAAQ,CAAC,GAC1B,aAAa,CAAC,CAAC,CAAC,SAAS,QAAQ,GAChC,IAAI,GACJ,IAAI,GACL,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACrB,IAAI,GACJ,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GACrB,IAAI,GACJ,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAE/C,yBAAiB,IAAI,CAAC;IACrB,KAAY,MAAM,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,IAAI,MAAM,SAAS,CAAC,CAAC,QAAQ,CAAC,GACnF,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,SAAS,IAAI,GAC7C,IAAI,GACJ,IAAI,GACL,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACrB,IAAI,GACJ,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,SAAS,IAAI,GAClC,IAAI,GACJ,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;CACxC"}
|
package/cjs/array/some.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"some.js","sourceRoot":"","sources":["../../ts/array/some.ts"],"names":[],"mappings":""}
|
package/cjs/math/Abs.d.ts
DELETED
package/cjs/math/Abs.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Abs.d.ts","sourceRoot":"","sources":["../../ts/math/Abs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,GAAG,KAAK,IAAI,MAAM,SAAS,CAAC,GAC/D,IAAI,GACJ,GAAG,CAAC,EAAE,SAAS,IAAI,MAAM,CAAC,EAAE,GAC5B,UAAU,CAAC,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,GAC7C,CAAC,CAAA"}
|
package/cjs/math/Abs.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Abs.js","sourceRoot":"","sources":["../../ts/math/Abs.ts"],"names":[],"mappings":""}
|
package/cjs/math/Add.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { PadLeft } from '../array/index.js';
|
|
2
|
-
import type { IsInteger } from '../number/integer.js';
|
|
3
|
-
import type { IsPositive } from '../number/positive.js';
|
|
4
|
-
import type { And } from '../predicates/index.js';
|
|
5
|
-
import type { Digit, DigitArray } from './Digit.js';
|
|
6
|
-
import type { Max } from './Max.js';
|
|
7
|
-
/**
|
|
8
|
-
* Add two number literals.
|
|
9
|
-
*/
|
|
10
|
-
export type Add<A extends number, B extends number, Fail = never> = And<And<IsPositive<A>, IsInteger<A>>, And<IsPositive<B>, IsInteger<B>>> extends false ? Fail : DigitArray.FromNumber<A> extends infer DA ? DA extends number[] ? DigitArray.FromNumber<B> extends infer DB ? DB extends number[] ? Max<DA['length'], DB['length']> extends infer M ? M extends number ? PadLeft<DA, M, 0> extends infer PDA ? PDA extends number[] ? PadLeft<DB, M, 0> extends infer PDB ? PDB extends number[] ? DigitArray.ToNumber<Add.DigitArray<PDA, PDB>> : Fail : Fail : Fail : Fail : Fail : Fail : Fail : Fail : Fail : Fail;
|
|
11
|
-
export declare namespace Add {
|
|
12
|
-
type DigitArray<A extends number[], B extends number[]> = A extends [any, ...infer ATail] ? ATail extends number[] ? B extends [any, ...infer BTail] ? BTail extends number[] ? [Digit<A[0], B[0]>, ...DigitArray<ATail, BTail>] : [] : [A[0], ...DigitArray<[], ATail>] : [] : B extends [any, ...infer BTail] ? BTail extends number[] ? [B[0], ...DigitArray<[], BTail>] : [] : [];
|
|
13
|
-
type Digit<A extends number, B extends number> = [...Digit.ToTuple[A], ...Digit.ToTuple[B]]['length'];
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Increment `A` by 1.
|
|
17
|
-
*/
|
|
18
|
-
export type Increment<A extends number, Fail = never> = Add<A, 1, Fail>;
|
|
19
|
-
//# sourceMappingURL=Add.d.ts.map
|
package/cjs/math/Add.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Add.d.ts","sourceRoot":"","sources":["../../ts/math/Add.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,wBAAwB,CAAA;AACjD,OAAO,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAA;AAEnC;;GAEG;AACH,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EAAE,IAAI,GAAG,KAAK,IAAI,GAAG,CACtE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,EAChC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAChC,SAAS,KAAK,GACZ,IAAI,GACJ,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,MAAM,EAAE,GACzC,EAAE,SAAS,MAAM,EAAE,GAClB,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,MAAM,EAAE,GACxC,EAAE,SAAS,MAAM,EAAE,GAClB,GAAG,CAAC,EAAE,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,GAC9C,CAAC,SAAS,MAAM,GACf,OAAO,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,SAAS,MAAM,GAAG,GAClC,GAAG,SAAS,MAAM,EAAE,GACnB,OAAO,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,SAAS,MAAM,GAAG,GAClC,GAAG,SAAS,MAAM,EAAE,GACnB,UAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,GAC7C,IAAI,GACL,IAAI,GACL,IAAI,GACL,IAAI,GACL,IAAI,GACL,IAAI,GACL,IAAI,GACL,IAAI,GACL,IAAI,GACL,IAAI,CAAA;AAEP,yBAAiB,GAAG,CAAC;IACpB,KAAY,UAAU,CAAC,CAAC,SAAS,MAAM,EAAE,EAAE,CAAC,SAAS,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,MAAM,KAAK,CAAC,GAC7F,KAAK,SAAS,MAAM,EAAE,GACrB,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,MAAM,KAAK,CAAC,GAC9B,KAAK,SAAS,MAAM,EAAE,GACrB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,UAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,GAChD,EAAE,GACH,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,UAAU,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,GACjC,EAAE,GACH,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,MAAM,KAAK,CAAC,GAC/B,KAAK,SAAS,MAAM,EAAE,GACrB,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,UAAU,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC,GAChC,EAAE,GACH,EAAE,CAAA;IAEL,KAAY,KAAK,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,IAAI,CAAC,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;CAC5G;AACD;;GAEG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,IAAI,GAAG,KAAK,IAAI,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA"}
|
package/cjs/math/Add.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Add.js","sourceRoot":"","sources":["../../ts/math/Add.ts"],"names":[],"mappings":""}
|