type-plus 6.8.1 → 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 +1054 -355
- 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/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/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 +1 -1
- 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/test_type.ts +131 -88
- package/ts/tuple/create_tuple.ts +42 -0
- 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
|
@@ -2,8 +2,43 @@ import type { NotExtendable } from './Extends.js';
|
|
|
2
2
|
import type { IsEmptyObject } from './IsEmptyObject.js';
|
|
3
3
|
/**
|
|
4
4
|
* Can `A` assign to `B`
|
|
5
|
+
*
|
|
6
|
+
* Note that when union is involved, the assignability is measured distributively.
|
|
7
|
+
* Meaning the result can be `Then | Else` (i.e. `boolean` by default),
|
|
8
|
+
* instead of distinctive `Then` (`true`) or `Else` (`false`).
|
|
9
|
+
*
|
|
10
|
+
* This is the correct behavior.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* CanAssign<number | string, number> // boolean
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* We are checking can `A` assign to `B`.
|
|
18
|
+
* Since `A` is `number | string`,
|
|
19
|
+
* `A` can assign to `B` when `A` is number` (true), and
|
|
20
|
+
* `A` cannot assign to `B` when `A` is string` (false).
|
|
21
|
+
* So the result is `true | false = boolean`.
|
|
22
|
+
*
|
|
23
|
+
* If you want to make sure all branches are assignable,
|
|
24
|
+
* use `StrictCanAssign<A, B>`.
|
|
5
25
|
*/
|
|
6
26
|
export type CanAssign<A, B, Then = true, Else = false> = IsEmptyObject<A> extends true ? Record<string, unknown> extends B ? Then : Else : boolean extends A ? boolean extends B ? Then : Else : A extends B ? Then : Else;
|
|
27
|
+
/**
|
|
28
|
+
* Can `A` strictly assign to `B`.
|
|
29
|
+
*
|
|
30
|
+
* All branches in an union `A` are assignable to `B`.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* StrictCanAssign<number | string, number> // false
|
|
35
|
+
* StrictCanAssign<number | string, number | string> // true
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export type StrictCanAssign<A, B, Then = true, Else = false> = IsEmptyObject<A> extends true ? Record<string, unknown> extends B ? Then : Else : boolean extends A ? boolean extends B ? Then : Else : [A] extends [B] ? Then : Else;
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated use `CanAssign` instead
|
|
41
|
+
*/
|
|
7
42
|
export type IsAssign<A, B, Then = true, Else = false> = CanAssign<A, B, Then, Else>;
|
|
8
43
|
export declare function canAssign<T>(canAssign: false): <S>(subject: NotExtendable<S, T>) => true;
|
|
9
44
|
export declare function canAssign<T>(): <S extends T>(subject: S) => CanAssign<S, T>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CanAssign.d.ts","sourceRoot":"","sources":["../../ts/predicates/CanAssign.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD
|
|
1
|
+
{"version":3,"file":"CanAssign.d.ts","sourceRoot":"","sources":["../../ts/predicates/CanAssign.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAEvD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,aAAa,CAAC,CAAC,CAAC,SAAS,IAAI,GACnF,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,GAChC,IAAI,GACJ,IAAI,GACL,OAAO,SAAS,CAAC,GACjB,OAAO,SAAS,CAAC,GAChB,IAAI,GACJ,IAAI,GACL,CAAC,SAAS,CAAC,GACX,IAAI,GACJ,IAAI,CAAA;AAEP;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,aAAa,CAAC,CAAC,CAAC,SAAS,IAAI,GACzF,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,GAChC,IAAI,GACJ,IAAI,GACL,OAAO,SAAS,CAAC,GACjB,OAAO,SAAS,CAAC,GAChB,IAAI,GACJ,IAAI,GACL,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GACf,IAAI,GACJ,IAAI,CAAA;AAEP;;GAEG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAEnF,wBAAgB,SAAS,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,aAAa,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,IAAI,CAAA;AACzF,wBAAgB,SAAS,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC,KAAK,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CanAssign.js","sourceRoot":"","sources":["../../ts/predicates/CanAssign.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"CanAssign.js","sourceRoot":"","sources":["../../ts/predicates/CanAssign.ts"],"names":[],"mappings":";;;AAoEA,SAAgB,SAAS;IACxB,OAAO,GAAG,EAAE,CAAC,IAAI,CAAA;AAClB,CAAC;AAFD,8BAEC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export type Extendable<A, B> = A extends B ?
|
|
2
|
-
export type NotExtendable<A, B> = A extends B ?
|
|
1
|
+
export type Extendable<A, B, Then = A, Else = never> = A extends B ? Then : Else;
|
|
2
|
+
export type NotExtendable<A, B, Then = A, Else = never> = A extends B ? Else : Then;
|
|
3
3
|
export type IsExtend<A, B, Then = true, Else = false> = A extends B ? Then : Else;
|
|
4
4
|
export type IsNotExtend<A, B, Then = true, Else = false> = A extends B ? Else : Then;
|
|
5
5
|
//# sourceMappingURL=Extends.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Extends.d.ts","sourceRoot":"","sources":["../../ts/predicates/Extends.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,
|
|
1
|
+
{"version":3,"file":"Extends.d.ts","sourceRoot":"","sources":["../../ts/predicates/Extends.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA;AAChF,MAAM,MAAM,aAAa,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA;AACnF,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA;AACjF,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,CAAC,SAAS,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA"}
|
|
@@ -2,7 +2,6 @@ export * from './CanAssign.js';
|
|
|
2
2
|
export type { Extendable, IsExtend, IsNotExtend, NotExtendable } from './Extends.js';
|
|
3
3
|
export type { If } from './If.js';
|
|
4
4
|
export type { IsEmptyObject } from './IsEmptyObject.js';
|
|
5
|
-
export * from './isType.js';
|
|
6
5
|
export type { And, Not, Or, Xor } from './logical.js';
|
|
7
6
|
export type IsLiteral<T extends number | string, Then = true, Else = false> = number extends T ? Else : string extends T ? Else : Then;
|
|
8
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../ts/predicates/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACpF,YAAY,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AACjC,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../ts/predicates/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,YAAY,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AACpF,YAAY,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AACjC,YAAY,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AACvD,YAAY,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAErD,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,MAAM,SAAS,CAAC,GAC3F,IAAI,GACJ,MAAM,SAAS,CAAC,GAChB,IAAI,GACJ,IAAI,CAAA"}
|
package/cjs/predicates/index.js
CHANGED
|
@@ -15,5 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./CanAssign.js"), exports);
|
|
18
|
-
__exportStar(require("./isType.js"), exports);
|
|
19
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/predicates/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/predicates/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA8B"}
|
|
@@ -1,41 +1,77 @@
|
|
|
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
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
interface TestType {
|
|
26
|
+
/**
|
|
27
|
+
* Check if type `A` is equal to type `B` and `C`.
|
|
28
|
+
*
|
|
29
|
+
* @return `expected` as `A` for type inspection.
|
|
30
|
+
*/
|
|
31
|
+
equal<A, B, C>(expected: IsEqual<A, B> & IsEqual<A, C>): A;
|
|
32
|
+
/**
|
|
33
|
+
* Check if type `A` is equal to type `B`.
|
|
34
|
+
*
|
|
35
|
+
* @return `expected` as `A` for type inspection.
|
|
36
|
+
*/
|
|
37
|
+
equal<A, B>(expected: IsEqual<A, B>): A;
|
|
38
|
+
/**
|
|
39
|
+
* Check if `A` can assign to `B`.
|
|
40
|
+
*
|
|
41
|
+
* If `A` is a union,
|
|
42
|
+
* the check is distributive.
|
|
43
|
+
*
|
|
44
|
+
* Meaning the result can be `boolean`,
|
|
45
|
+
* meaning both `true` and `false` will pass.
|
|
46
|
+
*
|
|
47
|
+
* If you want to avoid the distributivity,
|
|
48
|
+
* use `testType.strictCanAssign()` instead.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* testType.canAssign<123, number> // true
|
|
53
|
+
*
|
|
54
|
+
* testType.canAssign<number | string, number> // boolean
|
|
55
|
+
* ```
|
|
56
|
+
*
|
|
57
|
+
* @return `expected` as `A` for type inspection.
|
|
58
|
+
*/
|
|
59
|
+
canAssign<A, B>(expected: CanAssign<A, B>): A;
|
|
60
|
+
/**
|
|
61
|
+
* Check if `A` can fully assign to `B`.
|
|
62
|
+
*
|
|
63
|
+
* This checks all branches in an union `A` are assignable to `B`.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* ```ts
|
|
67
|
+
* testType.strictCanAssign<number | string, number | string> // true
|
|
68
|
+
*
|
|
69
|
+
* testType.strictCanAssign<number | string, number> // false
|
|
70
|
+
* ```
|
|
71
|
+
*
|
|
72
|
+
* @return `expected` as `A` for type inspection.
|
|
73
|
+
*/
|
|
74
|
+
strictCanAssign<A, B>(expected: StrictCanAssign<A, B>): A;
|
|
39
75
|
/**
|
|
40
76
|
* Check if type `T` is exactly `any`.
|
|
41
77
|
*
|
|
@@ -43,102 +79,141 @@ export declare const testType: {
|
|
|
43
79
|
*/
|
|
44
80
|
any<T>(expected: IsAny<T>): T;
|
|
45
81
|
/**
|
|
46
|
-
* Check if type `T` is exactly `
|
|
82
|
+
* Check if type `T` is exactly `array`.
|
|
47
83
|
*
|
|
48
84
|
* @return `expected` as `T` for type inspection.
|
|
49
85
|
*/
|
|
50
|
-
|
|
86
|
+
array<T>(expected: IsArray<T>): T;
|
|
51
87
|
/**
|
|
52
|
-
* Check if type `T` is exactly `
|
|
88
|
+
* Check if type `T` is exactly `bigint`.
|
|
53
89
|
*
|
|
54
90
|
* @return `expected` as `T` for type inspection.
|
|
55
91
|
*/
|
|
56
|
-
|
|
92
|
+
strictBigint<T>(expected: IsStrictBigint<T>): T;
|
|
57
93
|
/**
|
|
58
|
-
* Check if type `T` is
|
|
94
|
+
* Check if type `T` is `bigint` or bigint literals.
|
|
59
95
|
*
|
|
60
96
|
* @return `expected` as `T` for type inspection.
|
|
61
97
|
*/
|
|
62
|
-
|
|
63
|
-
equal: typeof equal;
|
|
98
|
+
bigint<T>(expected: IsBigint<T>): T;
|
|
64
99
|
/**
|
|
65
|
-
* Check if `
|
|
100
|
+
* Check if type `T` is exactly `boolean`.
|
|
66
101
|
*
|
|
67
|
-
* @return `expected` as `
|
|
102
|
+
* @return `expected` as `T` for type inspection.
|
|
68
103
|
*/
|
|
69
|
-
|
|
104
|
+
strictBoolean<T>(expected: IsStrictBoolean<T>): T;
|
|
105
|
+
/**
|
|
106
|
+
* Check if type `T` is `boolean` and boolean literals.
|
|
107
|
+
*
|
|
108
|
+
* @return `expected` as `T` for type inspection.
|
|
109
|
+
*/
|
|
110
|
+
boolean<T>(expected: IsBoolean<T>): T;
|
|
111
|
+
/**
|
|
112
|
+
* Check if type `T` is exactly `true`.
|
|
113
|
+
*
|
|
114
|
+
* @return `expected` as `T` for type inspection.
|
|
115
|
+
*/
|
|
116
|
+
true<T>(expected: IsTrue<T>): T;
|
|
117
|
+
/**
|
|
118
|
+
* Check if type `T` is exactly `false`.
|
|
119
|
+
*
|
|
120
|
+
* @return `expected` as `T` for type inspection.
|
|
121
|
+
*/
|
|
122
|
+
false<T>(expected: IsFalse<T>): T;
|
|
70
123
|
/**
|
|
71
124
|
* Check if type `T` is exactly `boolean`.
|
|
72
125
|
*
|
|
73
126
|
* @return `expected` as `T` for type inspection.
|
|
74
127
|
*/
|
|
75
|
-
|
|
128
|
+
strictFunction<T>(expected: IsStrictFunction<T>): T;
|
|
76
129
|
/**
|
|
77
130
|
* Check if type `T` is `boolean` and boolean literals.
|
|
78
131
|
*
|
|
79
132
|
* @return `expected` as `T` for type inspection.
|
|
80
133
|
*/
|
|
81
|
-
|
|
134
|
+
function<T>(expected: IsFunction<T>): T;
|
|
82
135
|
/**
|
|
83
|
-
* Check if type `T` is exactly `
|
|
136
|
+
* Check if type `T` is exactly `never`.
|
|
84
137
|
*
|
|
85
138
|
* @return `expected` as `T` for type inspection.
|
|
86
139
|
*/
|
|
87
|
-
|
|
140
|
+
never<T>(expected: IsNever<T>): T;
|
|
88
141
|
/**
|
|
89
|
-
* Check if type `T` is exactly `
|
|
142
|
+
* Check if type `T` is exactly `null`.
|
|
90
143
|
*
|
|
91
144
|
* @return `expected` as `T` for type inspection.
|
|
92
145
|
*/
|
|
93
|
-
|
|
146
|
+
null<T>(expected: IsNull<T>): T;
|
|
94
147
|
/**
|
|
95
148
|
* Check if type `T` is exactly `number`.
|
|
96
149
|
*
|
|
97
150
|
* @return `expected` as `T` for type inspection.
|
|
98
151
|
*/
|
|
99
|
-
strictNumber<
|
|
152
|
+
strictNumber<T>(expected: IsStrictNumber<T>): T;
|
|
100
153
|
/**
|
|
101
154
|
* Check if type `T` is `number` or number literals.
|
|
102
155
|
*
|
|
103
156
|
* @return `expected` as `T` for type inspection.
|
|
104
157
|
*/
|
|
105
|
-
number<
|
|
158
|
+
number<T>(expected: IsNumber<T>): T;
|
|
159
|
+
/**
|
|
160
|
+
* Check if type `T` is `object`.
|
|
161
|
+
*
|
|
162
|
+
* Note that `Function`, `Array`, and *tuple* are also `object`.
|
|
163
|
+
*
|
|
164
|
+
* @return `expected` as `T` for type inspection.
|
|
165
|
+
*/
|
|
166
|
+
object<T>(expected: IsObject<T>): T;
|
|
106
167
|
/**
|
|
107
168
|
* Check if type `T` is exactly `string`.
|
|
108
169
|
*
|
|
109
170
|
* @return `expected` as `T` for type inspection.
|
|
110
171
|
*/
|
|
111
|
-
strictString<
|
|
172
|
+
strictString<T>(expected: IsStrictString<T>): T;
|
|
112
173
|
/**
|
|
113
174
|
* Check if type `T` is `string` or string literals.
|
|
114
175
|
*
|
|
115
176
|
* @return `expected` as `T` for type inspection.
|
|
116
177
|
*/
|
|
117
|
-
string<
|
|
178
|
+
string<T>(expected: IsString<T>): T;
|
|
118
179
|
/**
|
|
119
|
-
* Check if type `T` is
|
|
180
|
+
* Check if type `T` is a `symbol`.
|
|
120
181
|
*
|
|
121
182
|
* @return `expected` as `T` for type inspection.
|
|
122
183
|
*/
|
|
123
|
-
|
|
184
|
+
symbol<T>(expected: IsSymbol<T>): T;
|
|
124
185
|
/**
|
|
125
|
-
* Check if type `T` is
|
|
186
|
+
* Check if type `T` is a *tuple*.
|
|
126
187
|
*
|
|
127
188
|
* @return `expected` as `T` for type inspection.
|
|
128
189
|
*/
|
|
129
|
-
|
|
190
|
+
tuple<T>(expected: IsTuple<T>): T;
|
|
130
191
|
/**
|
|
131
192
|
* Check if type `T` is exactly `undefined`.
|
|
132
193
|
*
|
|
133
194
|
* @return `expected` as `T` for type inspection.
|
|
134
195
|
*/
|
|
135
|
-
undefined<
|
|
196
|
+
undefined<T>(expected: IsUndefined<T>): T;
|
|
136
197
|
/**
|
|
137
|
-
* Check if type `T` is exactly `
|
|
198
|
+
* Check if type `T` is exactly `unknown`.
|
|
199
|
+
*
|
|
200
|
+
* @return `expected` as `T` for type inspection.
|
|
201
|
+
*/
|
|
202
|
+
unknown<T>(expected: IsUnknown<T>): T;
|
|
203
|
+
/**
|
|
204
|
+
* Check if type `T` is exactly `void`.
|
|
138
205
|
*
|
|
139
206
|
* @return `expected` as `T` for type inspection.
|
|
140
207
|
*/
|
|
141
|
-
|
|
142
|
-
}
|
|
208
|
+
void<T>(expected: IsVoid<T>): T;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Test utilities for types.
|
|
212
|
+
*
|
|
213
|
+
* This is designed specifically for testing.
|
|
214
|
+
* The return value is the input `expected` parameter asserted as the first type parameter,
|
|
215
|
+
* so that the type can be further inspected.
|
|
216
|
+
*/
|
|
217
|
+
export declare const testType: TestType;
|
|
143
218
|
export {};
|
|
144
219
|
//# sourceMappingURL=test_type.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_type.d.ts","sourceRoot":"","sources":["../../ts/testing/test_type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAo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AE,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;IAC/C;;;;OAIG;IACH,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;IACnC;;;;;;OAMG;IACH,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;IACnC;;;;OAIG;IACH,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;IAC/C;;;;OAIG;IACH,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;IACnC;;;;OAIG;IACH,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;IACnC;;;;OAIG;IACH,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;IACjC;;;;OAIG;IACH,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;IAEzC;;;;OAIG;IACH,OAAO,CAAC,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;IACrC;;;;OAIG;IACH,IAAI,CAAC,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAA;CAC/B;AAED;;;;;;GAMG;AACH,eAAO,MAAM,QAAQ,UAInB,CAAA"}
|
package/cjs/testing/test_type.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.testType = void 0;
|
|
4
|
-
function equal(expected) {
|
|
5
|
-
return expected;
|
|
6
|
-
}
|
|
7
4
|
/**
|
|
8
5
|
* Test utilities for types.
|
|
9
6
|
*
|
|
@@ -11,143 +8,9 @@ function equal(expected) {
|
|
|
11
8
|
* The return value is the input `expected` parameter asserted as the first type parameter,
|
|
12
9
|
* so that the type can be further inspected.
|
|
13
10
|
*/
|
|
14
|
-
exports.testType = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*
|
|
18
|
-
* @return `expected` as `T` for type inspection.
|
|
19
|
-
*/
|
|
20
|
-
any(expected) {
|
|
21
|
-
return expected;
|
|
22
|
-
},
|
|
23
|
-
/**
|
|
24
|
-
* Check if type `T` is exactly `unknown`.
|
|
25
|
-
*
|
|
26
|
-
* @return `expected` as `T` for type inspection.
|
|
27
|
-
*/
|
|
28
|
-
unknown(expected) {
|
|
29
|
-
return expected;
|
|
30
|
-
},
|
|
31
|
-
/**
|
|
32
|
-
* Check if type `T` is exactly `never`.
|
|
33
|
-
*
|
|
34
|
-
* @return `expected` as `T` for type inspection.
|
|
35
|
-
*/
|
|
36
|
-
never(expected) {
|
|
37
|
-
return expected;
|
|
38
|
-
},
|
|
39
|
-
/**
|
|
40
|
-
* Check if type `T` is exactly `void`.
|
|
41
|
-
*
|
|
42
|
-
* @return `expected` as `T` for type inspection.
|
|
43
|
-
*/
|
|
44
|
-
void(expected) {
|
|
45
|
-
return expected;
|
|
46
|
-
},
|
|
47
|
-
equal,
|
|
48
|
-
/**
|
|
49
|
-
* Check if `A` can assign to `B`.
|
|
50
|
-
*
|
|
51
|
-
* @return `expected` as `A` for type inspection.
|
|
52
|
-
*/
|
|
53
|
-
canAssign(expected) {
|
|
54
|
-
return expected;
|
|
55
|
-
},
|
|
56
|
-
/**
|
|
57
|
-
* Check if type `T` is exactly `boolean`.
|
|
58
|
-
*
|
|
59
|
-
* @return `expected` as `T` for type inspection.
|
|
60
|
-
*/
|
|
61
|
-
strictBoolean(expected) {
|
|
62
|
-
return expected;
|
|
63
|
-
},
|
|
64
|
-
/**
|
|
65
|
-
* Check if type `T` is `boolean` and boolean literals.
|
|
66
|
-
*
|
|
67
|
-
* @return `expected` as `T` for type inspection.
|
|
68
|
-
*/
|
|
69
|
-
boolean(expected) {
|
|
70
|
-
return expected;
|
|
71
|
-
},
|
|
72
|
-
/**
|
|
73
|
-
* Check if type `T` is exactly `true`.
|
|
74
|
-
*
|
|
75
|
-
* @return `expected` as `T` for type inspection.
|
|
76
|
-
*/
|
|
77
|
-
true(expected) {
|
|
78
|
-
return expected;
|
|
79
|
-
},
|
|
80
|
-
/**
|
|
81
|
-
* Check if type `T` is exactly `false`.
|
|
82
|
-
*
|
|
83
|
-
* @return `expected` as `T` for type inspection.
|
|
84
|
-
*/
|
|
85
|
-
false(expected) {
|
|
86
|
-
return expected;
|
|
87
|
-
},
|
|
88
|
-
/**
|
|
89
|
-
* Check if type `T` is exactly `number`.
|
|
90
|
-
*
|
|
91
|
-
* @return `expected` as `T` for type inspection.
|
|
92
|
-
*/
|
|
93
|
-
strictNumber(expected) {
|
|
94
|
-
return expected;
|
|
95
|
-
},
|
|
96
|
-
/**
|
|
97
|
-
* Check if type `T` is `number` or number literals.
|
|
98
|
-
*
|
|
99
|
-
* @return `expected` as `T` for type inspection.
|
|
100
|
-
*/
|
|
101
|
-
number(expected) {
|
|
102
|
-
return expected;
|
|
103
|
-
},
|
|
104
|
-
/**
|
|
105
|
-
* Check if type `T` is exactly `string`.
|
|
106
|
-
*
|
|
107
|
-
* @return `expected` as `T` for type inspection.
|
|
108
|
-
*/
|
|
109
|
-
strictString(expected) {
|
|
110
|
-
return expected;
|
|
111
|
-
},
|
|
112
|
-
/**
|
|
113
|
-
* Check if type `T` is `string` or string literals.
|
|
114
|
-
*
|
|
115
|
-
* @return `expected` as `T` for type inspection.
|
|
116
|
-
*/
|
|
117
|
-
string(expected) {
|
|
118
|
-
return expected;
|
|
119
|
-
},
|
|
120
|
-
/**
|
|
121
|
-
* Check if type `T` is exactly `bigint`.
|
|
122
|
-
*
|
|
123
|
-
* @return `expected` as `T` for type inspection.
|
|
124
|
-
*/
|
|
125
|
-
strictBigint(expected) {
|
|
126
|
-
return expected;
|
|
127
|
-
},
|
|
128
|
-
/**
|
|
129
|
-
* Check if type `T` is `bigint` or bigint literals.
|
|
130
|
-
*
|
|
131
|
-
* @return `expected` as `T` for type inspection.
|
|
132
|
-
*/
|
|
133
|
-
bigint(expected) {
|
|
134
|
-
return expected;
|
|
135
|
-
},
|
|
136
|
-
/**
|
|
137
|
-
* Check if type `T` is exactly `undefined`.
|
|
138
|
-
*
|
|
139
|
-
* @return `expected` as `T` for type inspection.
|
|
140
|
-
*/
|
|
141
|
-
undefined(expected) {
|
|
142
|
-
return expected;
|
|
143
|
-
},
|
|
144
|
-
/**
|
|
145
|
-
* Check if type `T` is exactly `null`.
|
|
146
|
-
*
|
|
147
|
-
* @return `expected` as `T` for type inspection.
|
|
148
|
-
*/
|
|
149
|
-
null(expected) {
|
|
150
|
-
return expected;
|
|
11
|
+
exports.testType = new Proxy({}, {
|
|
12
|
+
get(_target, _prop, _receiver) {
|
|
13
|
+
return (expected) => expected;
|
|
151
14
|
}
|
|
152
|
-
};
|
|
15
|
+
});
|
|
153
16
|
//# sourceMappingURL=test_type.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test_type.js","sourceRoot":"","sources":["../../ts/testing/test_type.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"test_type.js","sourceRoot":"","sources":["../../ts/testing/test_type.ts"],"names":[],"mappings":";;;AAoNA;;;;;;GAMG;AACU,QAAA,QAAQ,GAAG,IAAI,KAAK,CAAC,EAAc,EAAE;IACjD,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS;QAC5B,OAAO,CAAC,QAAiB,EAAE,EAAE,CAAC,QAAQ,CAAA;IACvC,CAAC;CACD,CAAC,CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
* 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 ? ToTuple<[], DigitArray.FromString<`${L}`>, T> : Fail : Fail;
|
|
11
|
+
export type ToTuple<R extends any[], S extends number[], X = any> = S['length'] extends 0 ? R : S['length'] extends 1 ? [...R, ...DigitToTuple<X>[S[0]]] : S extends [any, ...infer T] ? T extends any[] ? ToTuple<Multi10<[...R, ...DigitToTuple<X>[S[0]]]>, T> : never : never;
|
|
12
|
+
type DigitToTuple<T = 1> = {
|
|
13
|
+
[k in number]: any[];
|
|
14
|
+
} & {
|
|
15
|
+
0: [];
|
|
16
|
+
1: [T];
|
|
17
|
+
2: [T, T];
|
|
18
|
+
3: [T, T, T];
|
|
19
|
+
4: [T, T, T, T];
|
|
20
|
+
5: [T, T, T, T, T];
|
|
21
|
+
6: [T, T, T, T, T, T];
|
|
22
|
+
7: [T, T, T, T, T, T, T];
|
|
23
|
+
8: [T, T, T, T, T, T, T, T];
|
|
24
|
+
9: [T, T, T, T, T, T, T, T, T];
|
|
25
|
+
};
|
|
26
|
+
type Multi10<C extends any[]> = [...C, ...C, ...C, ...C, ...C, ...C, ...C, ...C, ...C, ...C];
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=create_tuple.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create_tuple.d.ts","sourceRoot":"","sources":["../../ts/tuple/create_tuple.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2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,CAAA;IACN,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACT,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IACZ,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IACf,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAClB,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IACrB,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IACxB,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAC3B,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;CAC9B,CAAA;AACD,KAAK,OAAO,CAAC,CAAC,SAAS,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create_tuple.js","sourceRoot":"","sources":["../../ts/
|
|
1
|
+
{"version":3,"file":"create_tuple.js","sourceRoot":"","sources":["../../ts/tuple/create_tuple.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tuple_plus.d.ts","sourceRoot":"","sources":["../../ts/tuple/tuple_plus.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./tuple_plus.pad_start.js"), exports);
|
|
18
|
+
//# sourceMappingURL=tuple_plus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tuple_plus.js","sourceRoot":"","sources":["../../ts/tuple/tuple_plus.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAAyC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
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<Tuple, MaxLength, PadWith, [
|
|
19
|
+
]>;
|
|
20
|
+
type PadStartDevice<Source extends unknown[], MaxLength extends number, PadWith, Result extends unknown[]> = Result['length'] extends MaxLength ? Source extends [] ? Result : Source extends [...infer Head, infer Tail] ? [Tail, ...Result] extends infer R extends unknown[] ? PadStartDevice<Head, R['length'], PadWith, R> : never : never : Source extends [] ? PadStartDevice<Source, MaxLength, PadWith, [PadWith, ...Result]> : Source extends [...infer Head, infer Tail] ? PadStartDevice<Head, MaxLength, PadWith, [Tail, ...Result]> : Source;
|
|
21
|
+
export {};
|
|
22
|
+
//# sourceMappingURL=tuple_plus.pad_start.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tuple_plus.pad_start.d.ts","sourceRoot":"","sources":["../../ts/tuple/tuple_plus.pad_start.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,QAAQ,CAAC,KAAK,SAAS,OAAO,EAAE,EAAE,SAAS,SAAS,MAAM,EAAE,OAAO,GAAG,OAAO,IAAI,cAAc,CAC1G,KAAK,EACL,SAAS,EACT,OAAO,EACP;CAAE,CACF,CAAA;AAED,KAAK,cAAc,CAClB,MAAM,SAAS,OAAO,EAAE,EACxB,SAAS,SAAS,MAAM,EACxB,OAAO,EACP,MAAM,SAAS,OAAO,EAAE,IACrB,MAAM,CAAC,QAAQ,CAAC,SAAS,SAAS,GACnC,MAAM,SAAS,EAAE,GAChB,MAAM,GACN,MAAM,SAAS,CAAC,GAAG,MAAM,IAAI,EAAE,MAAM,IAAI,CAAC,GAC1C,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC,SAAS,MAAM,CAAC,SAAS,OAAO,EAAE,GAClD,cAAc,CAAC,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,GAC7C,KAAK,GACN,KAAK,GACN,MAAM,SAAS,EAAE,GACjB,cAAc,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC,GAChE,MAAM,SAAS,CAAC,GAAG,MAAM,IAAI,EAAE,MAAM,IAAI,CAAC,GAC1C,cAAc,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC,CAAC,GAC3D,MAAM,CAAA"}
|