type-plus 7.3.1 → 7.5.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 +146 -183
- package/cjs/any/any_type.d.ts +8 -8
- package/cjs/any/any_type.d.ts.map +1 -1
- package/cjs/array/array.at.d.ts +3 -1
- package/cjs/array/array.at.d.ts.map +1 -1
- package/cjs/array/array.entries.d.ts +4 -3
- package/cjs/array/array.entries.d.ts.map +1 -1
- package/cjs/array/array.find_last.d.ts +3 -1
- package/cjs/array/array.find_last.d.ts.map +1 -1
- package/cjs/array/array.some.d.ts +1 -1
- package/cjs/array/array.some.d.ts.map +1 -1
- package/cjs/array/array_plus.common_prop_keys.d.ts +27 -0
- package/cjs/array/array_plus.common_prop_keys.d.ts.map +1 -0
- package/cjs/array/array_plus.common_prop_keys.js +3 -0
- package/cjs/array/array_plus.common_prop_keys.js.map +1 -0
- package/cjs/array/{array.concat.d.ts → array_plus.concat.d.ts} +4 -1
- package/cjs/array/array_plus.concat.d.ts.map +1 -0
- package/cjs/array/array_plus.concat.js +3 -0
- package/cjs/array/array_plus.concat.js.map +1 -0
- package/cjs/array/array_plus.d.ts +7 -3
- package/cjs/array/array_plus.d.ts.map +1 -1
- package/cjs/array/array_plus.drop_match.d.ts +4 -0
- package/cjs/array/array_plus.drop_match.d.ts.map +1 -0
- package/cjs/array/array_plus.drop_match.js +3 -0
- package/cjs/array/array_plus.drop_match.js.map +1 -0
- package/cjs/array/array_plus.element_match.d.ts +44 -0
- package/cjs/array/array_plus.element_match.d.ts.map +1 -0
- package/cjs/array/array_plus.element_match.js +3 -0
- package/cjs/array/array_plus.element_match.js.map +1 -0
- package/cjs/array/array_plus.filter.d.ts +2 -0
- package/cjs/array/array_plus.filter.d.ts.map +1 -0
- package/cjs/array/array_plus.filter.js +3 -0
- package/cjs/array/array_plus.filter.js.map +1 -0
- package/cjs/array/array_plus.find.d.ts +57 -0
- package/cjs/array/array_plus.find.d.ts.map +1 -0
- package/cjs/array/array_plus.find.js +3 -0
- package/cjs/array/array_plus.find.js.map +1 -0
- package/cjs/array/array_plus.pad_start.d.ts +5 -0
- package/cjs/array/array_plus.pad_start.d.ts.map +1 -0
- package/cjs/array/array_plus.pad_start.js +3 -0
- package/cjs/array/array_plus.pad_start.js.map +1 -0
- package/cjs/array/array_type.d.ts +30 -12
- package/cjs/array/array_type.d.ts.map +1 -1
- package/cjs/array/filter.d.ts +24 -4
- package/cjs/array/filter.d.ts.map +1 -1
- package/cjs/array/find_first.d.ts +62 -0
- package/cjs/array/find_first.d.ts.map +1 -0
- package/cjs/array/{array.find.js → find_first.js} +1 -1
- package/cjs/array/find_first.js.map +1 -0
- package/cjs/array/head.d.ts +30 -1
- package/cjs/array/head.d.ts.map +1 -1
- package/cjs/array/intersect_of_props.d.ts +5 -3
- package/cjs/array/intersect_of_props.d.ts.map +1 -1
- package/cjs/array/last.d.ts +27 -2
- package/cjs/array/last.d.ts.map +1 -1
- package/cjs/array/literal_array.d.ts +5 -0
- package/cjs/array/literal_array.d.ts.map +1 -1
- package/cjs/array/literal_array.js +5 -0
- package/cjs/array/literal_array.js.map +1 -1
- package/cjs/array/pad_start.d.ts +5 -5
- package/cjs/array/pad_start.d.ts.map +1 -1
- package/cjs/array/reduce_while.d.ts +6 -0
- package/cjs/array/reduce_while.d.ts.map +1 -1
- package/cjs/array/reduce_while.js +6 -0
- package/cjs/array/reduce_while.js.map +1 -1
- package/cjs/array/reverse.d.ts +5 -0
- package/cjs/array/reverse.d.ts.map +1 -1
- package/cjs/array/union_of_props.d.ts +1 -1
- package/cjs/array/union_of_props.d.ts.map +1 -1
- package/cjs/assertion/assert_type.d.ts +4 -1
- package/cjs/assertion/assert_type.d.ts.map +1 -1
- package/cjs/assertion/assert_type.js.map +1 -1
- package/cjs/functional/compose.d.ts +2 -1
- package/cjs/functional/compose.d.ts.map +1 -1
- package/cjs/functional/compose.js.map +1 -1
- package/cjs/functional/context.d.ts.map +1 -1
- package/cjs/index.d.ts +22 -3
- package/cjs/index.d.ts.map +1 -1
- package/cjs/index.js +9 -3
- package/cjs/index.js.map +1 -1
- package/cjs/math/numeric_struct.d.ts +1 -1
- package/cjs/math/numeric_struct.d.ts.map +1 -1
- package/cjs/mix_types/any_or_never_type.d.ts +1 -1
- package/cjs/never/never_type.d.ts +11 -0
- package/cjs/never/never_type.d.ts.map +1 -1
- package/cjs/nodejs/isNodeError.d.ts.map +1 -1
- package/cjs/nominal/brand.d.ts.map +1 -1
- package/cjs/nominal/flavor.d.ts.map +1 -1
- package/cjs/object/index.d.ts +0 -1
- package/cjs/object/index.d.ts.map +1 -1
- package/cjs/object/index.js.map +1 -1
- package/cjs/testing/test_type.d.ts +277 -233
- package/cjs/testing/test_type.d.ts.map +1 -1
- package/cjs/testing/test_type.js.map +1 -1
- package/cjs/tuple/common_prop_keys.d.ts +34 -0
- package/cjs/tuple/common_prop_keys.d.ts.map +1 -0
- package/cjs/tuple/common_prop_keys.js.map +1 -0
- package/cjs/tuple/create_tuple.d.ts.map +1 -1
- package/cjs/tuple/drop.d.ts +91 -0
- package/cjs/tuple/drop.d.ts.map +1 -0
- package/cjs/{array → tuple}/drop.js +3 -1
- package/cjs/tuple/drop.js.map +1 -0
- package/{esm/array → cjs/tuple}/tail.d.ts +1 -1
- package/cjs/{array → tuple}/tail.d.ts.map +1 -1
- package/cjs/{array → tuple}/tail.js.map +1 -1
- package/cjs/tuple/tuple_plus.common_prop_keys.d.ts +28 -0
- package/cjs/tuple/tuple_plus.common_prop_keys.d.ts.map +1 -0
- package/cjs/tuple/tuple_plus.common_prop_keys.js +3 -0
- package/cjs/tuple/tuple_plus.common_prop_keys.js.map +1 -0
- package/cjs/tuple/tuple_plus.d.ts +5 -1
- package/cjs/tuple/tuple_plus.d.ts.map +1 -1
- package/cjs/tuple/tuple_plus.drop_match.d.ts +6 -0
- package/cjs/tuple/tuple_plus.drop_match.d.ts.map +1 -0
- package/cjs/tuple/tuple_plus.drop_match.js +3 -0
- package/cjs/tuple/tuple_plus.drop_match.js.map +1 -0
- package/cjs/tuple/tuple_plus.filter.d.ts +13 -0
- package/cjs/tuple/tuple_plus.filter.d.ts.map +1 -0
- package/cjs/tuple/tuple_plus.filter.js +3 -0
- package/cjs/tuple/tuple_plus.filter.js.map +1 -0
- package/cjs/tuple/tuple_plus.find.d.ts +64 -0
- package/cjs/tuple/tuple_plus.find.d.ts.map +1 -0
- package/cjs/tuple/tuple_plus.find.js +3 -0
- package/cjs/tuple/tuple_plus.find.js.map +1 -0
- package/cjs/tuple/tuple_plus.js +0 -15
- package/cjs/tuple/tuple_plus.js.map +1 -1
- package/cjs/tuple/tuple_plus.pad_start.d.ts +11 -5
- package/cjs/tuple/tuple_plus.pad_start.d.ts.map +1 -1
- package/cjs/tuple/tuple_type.d.ts +41 -23
- package/cjs/tuple/tuple_type.d.ts.map +1 -1
- package/cjs/union/union.d.ts +33 -0
- package/cjs/union/union.d.ts.map +1 -0
- package/cjs/{array/array.concat.js → union/union.js} +1 -1
- package/cjs/union/union.js.map +1 -0
- package/cjs/unknown/unknown_type.d.ts +12 -0
- package/cjs/unknown/unknown_type.d.ts.map +1 -1
- package/cjs/utils/options.d.ts +10 -0
- package/cjs/utils/options.d.ts.map +1 -0
- package/cjs/utils/options.js +3 -0
- package/cjs/utils/options.js.map +1 -0
- package/esm/any/any_type.d.ts +8 -8
- package/esm/any/any_type.d.ts.map +1 -1
- package/esm/array/array.at.d.ts +3 -1
- package/esm/array/array.at.d.ts.map +1 -1
- package/esm/array/array.entries.d.ts +4 -3
- package/esm/array/array.entries.d.ts.map +1 -1
- package/esm/array/array.find_last.d.ts +3 -1
- package/esm/array/array.find_last.d.ts.map +1 -1
- package/esm/array/array.some.d.ts +1 -1
- package/esm/array/array.some.d.ts.map +1 -1
- package/esm/array/array_plus.common_prop_keys.d.ts +27 -0
- package/esm/array/array_plus.common_prop_keys.d.ts.map +1 -0
- package/esm/array/array_plus.common_prop_keys.js +2 -0
- package/esm/array/array_plus.common_prop_keys.js.map +1 -0
- package/esm/array/{array.concat.d.ts → array_plus.concat.d.ts} +4 -1
- package/esm/array/array_plus.concat.d.ts.map +1 -0
- package/esm/array/array_plus.concat.js +2 -0
- package/esm/array/array_plus.concat.js.map +1 -0
- package/esm/array/array_plus.d.ts +7 -3
- package/esm/array/array_plus.d.ts.map +1 -1
- package/esm/array/array_plus.drop_match.d.ts +4 -0
- package/esm/array/array_plus.drop_match.d.ts.map +1 -0
- package/esm/array/array_plus.drop_match.js +2 -0
- package/esm/array/array_plus.drop_match.js.map +1 -0
- package/esm/array/array_plus.element_match.d.ts +44 -0
- package/esm/array/array_plus.element_match.d.ts.map +1 -0
- package/esm/array/array_plus.element_match.js +2 -0
- package/esm/array/array_plus.element_match.js.map +1 -0
- package/esm/array/array_plus.filter.d.ts +2 -0
- package/esm/array/array_plus.filter.d.ts.map +1 -0
- package/esm/array/array_plus.filter.js +2 -0
- package/esm/array/array_plus.filter.js.map +1 -0
- package/esm/array/array_plus.find.d.ts +57 -0
- package/esm/array/array_plus.find.d.ts.map +1 -0
- package/esm/array/array_plus.find.js +2 -0
- package/esm/array/array_plus.find.js.map +1 -0
- package/esm/array/array_plus.pad_start.d.ts +5 -0
- package/esm/array/array_plus.pad_start.d.ts.map +1 -0
- package/esm/array/array_plus.pad_start.js +2 -0
- package/esm/array/array_plus.pad_start.js.map +1 -0
- package/esm/array/array_type.d.ts +30 -12
- package/esm/array/array_type.d.ts.map +1 -1
- package/esm/array/filter.d.ts +24 -4
- package/esm/array/filter.d.ts.map +1 -1
- package/esm/array/find_first.d.ts +62 -0
- package/esm/array/find_first.d.ts.map +1 -0
- package/esm/array/find_first.js +2 -0
- package/esm/array/find_first.js.map +1 -0
- package/esm/array/head.d.ts +30 -1
- package/esm/array/head.d.ts.map +1 -1
- package/esm/array/intersect_of_props.d.ts +5 -3
- package/esm/array/intersect_of_props.d.ts.map +1 -1
- package/esm/array/last.d.ts +27 -2
- package/esm/array/last.d.ts.map +1 -1
- package/esm/array/literal_array.d.ts +5 -0
- package/esm/array/literal_array.d.ts.map +1 -1
- package/esm/array/literal_array.js +5 -0
- package/esm/array/literal_array.js.map +1 -1
- package/esm/array/pad_start.d.ts +5 -5
- package/esm/array/pad_start.d.ts.map +1 -1
- package/esm/array/reduce_while.d.ts +6 -0
- package/esm/array/reduce_while.d.ts.map +1 -1
- package/esm/array/reduce_while.js +6 -0
- package/esm/array/reduce_while.js.map +1 -1
- package/esm/array/reverse.d.ts +5 -0
- package/esm/array/reverse.d.ts.map +1 -1
- package/esm/array/union_of_props.d.ts +1 -1
- package/esm/array/union_of_props.d.ts.map +1 -1
- package/esm/assertion/assert_type.d.ts +4 -1
- package/esm/assertion/assert_type.d.ts.map +1 -1
- package/esm/assertion/assert_type.js.map +1 -1
- package/esm/functional/compose.d.ts +2 -1
- package/esm/functional/compose.d.ts.map +1 -1
- package/esm/functional/compose.js.map +1 -1
- package/esm/functional/context.d.ts.map +1 -1
- package/esm/index.d.ts +22 -3
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +4 -2
- package/esm/index.js.map +1 -1
- package/esm/math/numeric_struct.d.ts +1 -1
- package/esm/math/numeric_struct.d.ts.map +1 -1
- package/esm/mix_types/any_or_never_type.d.ts +1 -1
- package/esm/never/never_type.d.ts +11 -0
- package/esm/never/never_type.d.ts.map +1 -1
- package/esm/nodejs/isNodeError.d.ts.map +1 -1
- package/esm/nominal/brand.d.ts.map +1 -1
- package/esm/nominal/flavor.d.ts.map +1 -1
- package/esm/object/index.d.ts +0 -1
- package/esm/object/index.d.ts.map +1 -1
- package/esm/object/index.js.map +1 -1
- package/esm/testing/test_type.d.ts +277 -233
- package/esm/testing/test_type.d.ts.map +1 -1
- package/esm/testing/test_type.js.map +1 -1
- package/esm/tuple/common_prop_keys.d.ts +34 -0
- package/esm/tuple/common_prop_keys.d.ts.map +1 -0
- package/esm/tuple/common_prop_keys.js.map +1 -0
- package/esm/tuple/create_tuple.d.ts.map +1 -1
- package/esm/tuple/drop.d.ts +91 -0
- package/esm/tuple/drop.d.ts.map +1 -0
- package/esm/tuple/drop.js +9 -0
- package/esm/tuple/drop.js.map +1 -0
- package/{cjs/array → esm/tuple}/tail.d.ts +1 -1
- package/esm/{array → tuple}/tail.d.ts.map +1 -1
- package/esm/{array → tuple}/tail.js.map +1 -1
- package/esm/tuple/tuple_plus.common_prop_keys.d.ts +28 -0
- package/esm/tuple/tuple_plus.common_prop_keys.d.ts.map +1 -0
- package/esm/tuple/tuple_plus.common_prop_keys.js +2 -0
- package/esm/tuple/tuple_plus.common_prop_keys.js.map +1 -0
- package/esm/tuple/tuple_plus.d.ts +5 -1
- package/esm/tuple/tuple_plus.d.ts.map +1 -1
- package/esm/tuple/tuple_plus.drop_match.d.ts +6 -0
- package/esm/tuple/tuple_plus.drop_match.d.ts.map +1 -0
- package/esm/tuple/tuple_plus.drop_match.js +2 -0
- package/esm/tuple/tuple_plus.drop_match.js.map +1 -0
- package/esm/tuple/tuple_plus.filter.d.ts +13 -0
- package/esm/tuple/tuple_plus.filter.d.ts.map +1 -0
- package/esm/tuple/tuple_plus.filter.js +2 -0
- package/esm/tuple/tuple_plus.filter.js.map +1 -0
- package/esm/tuple/tuple_plus.find.d.ts +64 -0
- package/esm/tuple/tuple_plus.find.d.ts.map +1 -0
- package/esm/tuple/tuple_plus.find.js +2 -0
- package/esm/tuple/tuple_plus.find.js.map +1 -0
- package/esm/tuple/tuple_plus.js +1 -1
- package/esm/tuple/tuple_plus.js.map +1 -1
- package/esm/tuple/tuple_plus.pad_start.d.ts +11 -5
- package/esm/tuple/tuple_plus.pad_start.d.ts.map +1 -1
- package/esm/tuple/tuple_type.d.ts +41 -23
- package/esm/tuple/tuple_type.d.ts.map +1 -1
- package/esm/union/union.d.ts +33 -0
- package/esm/union/union.d.ts.map +1 -0
- package/esm/union/union.js +2 -0
- package/esm/union/union.js.map +1 -0
- package/esm/unknown/unknown_type.d.ts +12 -0
- package/esm/unknown/unknown_type.d.ts.map +1 -1
- package/esm/utils/options.d.ts +10 -0
- package/esm/utils/options.d.ts.map +1 -0
- package/esm/utils/options.js +2 -0
- package/esm/utils/options.js.map +1 -0
- package/package.json +12 -9
- package/ts/any/any_type.ts +8 -9
- package/ts/any/readme.md +71 -4
- package/ts/array/array.at.ts +3 -1
- package/ts/array/array.entries.ts +4 -2
- package/ts/array/array.find_last.ts +3 -1
- package/ts/array/array.some.ts +1 -1
- package/ts/array/array_plus.common_prop_keys.ts +35 -0
- package/ts/array/{array.concat.ts → array_plus.concat.ts} +3 -0
- package/ts/array/array_plus.drop_match.ts +16 -0
- package/ts/array/array_plus.element_match.ts +61 -0
- package/ts/array/array_plus.filter.ts +5 -0
- package/ts/array/array_plus.find.ts +71 -0
- package/ts/array/array_plus.pad_start.ts +13 -0
- package/ts/array/array_plus.ts +7 -3
- package/ts/array/array_type.ts +30 -12
- package/ts/array/filter.ts +27 -22
- package/ts/array/find_first.ts +71 -0
- package/ts/array/head.ts +40 -1
- package/ts/array/intersect_of_props.ts +7 -3
- package/ts/array/last.ts +36 -2
- package/ts/array/literal_array.ts +5 -0
- package/ts/array/pad_start.ts +6 -10
- package/ts/array/readme.md +297 -32
- package/ts/array/reduce_while.ts +6 -0
- package/ts/array/reverse.ts +5 -0
- package/ts/array/union_of_props.ts +1 -1
- package/ts/assertion/assert_type.ts +4 -1
- package/ts/assertion/readme.md +4 -3
- package/ts/functional/compose.ts +2 -1
- package/ts/functional/context.ts +1 -1
- package/ts/index.ts +22 -3
- package/ts/math/numeric_struct.ts +9 -9
- package/ts/mix_types/any_or_never_type.ts +1 -1
- package/ts/mix_types/readme.md +7 -1
- package/ts/never/never_type.ts +13 -0
- package/ts/nodejs/isNodeError.ts +13 -13
- package/ts/nominal/brand.ts +1 -1
- package/ts/nominal/flavor.ts +1 -1
- package/ts/object/index.ts +0 -1
- package/ts/testing/readme.md +30 -0
- package/ts/testing/test_type.ts +279 -234
- package/ts/tuple/common_prop_keys.ts +41 -0
- package/ts/tuple/create_tuple.ts +9 -9
- package/ts/tuple/drop.ts +125 -0
- package/ts/tuple/readme.md +263 -9
- package/ts/{array → tuple}/tail.ts +1 -1
- package/ts/tuple/tuple_plus.common_prop_keys.ts +47 -0
- package/ts/tuple/tuple_plus.drop_match.ts +20 -0
- package/ts/tuple/tuple_plus.filter.ts +29 -0
- package/ts/tuple/tuple_plus.find.ts +88 -0
- package/ts/tuple/tuple_plus.pad_start.ts +37 -21
- package/ts/tuple/tuple_plus.ts +5 -1
- package/ts/tuple/tuple_type.ts +67 -25
- package/ts/union/readme.md +81 -0
- package/ts/union/union.ts +37 -0
- package/ts/unknown/unknown_type.ts +13 -0
- package/ts/utils/options.ts +10 -0
- package/cjs/array/array.concat.d.ts.map +0 -1
- package/cjs/array/array.concat.js.map +0 -1
- package/cjs/array/array.find.d.ts +0 -21
- package/cjs/array/array.find.d.ts.map +0 -1
- package/cjs/array/array.find.js.map +0 -1
- package/cjs/array/common_prop_keys.d.ts +0 -11
- package/cjs/array/common_prop_keys.d.ts.map +0 -1
- package/cjs/array/common_prop_keys.js.map +0 -1
- package/cjs/array/drop.d.ts +0 -19
- package/cjs/array/drop.d.ts.map +0 -1
- package/cjs/array/drop.js.map +0 -1
- package/cjs/array/index.d.ts +0 -17
- package/cjs/array/index.d.ts.map +0 -1
- package/cjs/array/index.js +0 -33
- package/cjs/array/index.js.map +0 -1
- package/esm/array/array.concat.d.ts.map +0 -1
- package/esm/array/array.concat.js +0 -2
- package/esm/array/array.concat.js.map +0 -1
- package/esm/array/array.find.d.ts +0 -21
- package/esm/array/array.find.d.ts.map +0 -1
- package/esm/array/array.find.js +0 -2
- package/esm/array/array.find.js.map +0 -1
- package/esm/array/common_prop_keys.d.ts +0 -11
- package/esm/array/common_prop_keys.d.ts.map +0 -1
- package/esm/array/common_prop_keys.js.map +0 -1
- package/esm/array/drop.d.ts +0 -19
- package/esm/array/drop.d.ts.map +0 -1
- package/esm/array/drop.js +0 -7
- package/esm/array/drop.js.map +0 -1
- package/esm/array/index.d.ts +0 -17
- package/esm/array/index.d.ts.map +0 -1
- package/esm/array/index.js +0 -17
- package/esm/array/index.js.map +0 -1
- package/ts/array/array.find.ts +0 -32
- package/ts/array/common_prop_keys.ts +0 -18
- package/ts/array/drop.ts +0 -71
- package/ts/array/index.ts +0 -16
- /package/cjs/{array → tuple}/common_prop_keys.js +0 -0
- /package/cjs/{array → tuple}/tail.js +0 -0
- /package/esm/{array → tuple}/common_prop_keys.js +0 -0
- /package/esm/{array → tuple}/tail.js +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { IsNever } from '../never/never_type.js';
|
|
2
|
+
import type { IsUnion } from '../union/union.js';
|
|
3
|
+
import type { MergeOptions } from '../utils/options.js';
|
|
4
|
+
/**
|
|
5
|
+
* 🦴 *utilities*
|
|
6
|
+
* 🔢 *customizable*
|
|
7
|
+
*
|
|
8
|
+
* Filter the element `T` in an array or tuple to match `Criteria`.
|
|
9
|
+
*
|
|
10
|
+
* @typeParam Options['widen'] Allow using narrow type to match widen type.
|
|
11
|
+
* e.g. `number, 1` -> `1 | undefined`.
|
|
12
|
+
* Default to `true`.
|
|
13
|
+
*
|
|
14
|
+
* @typeParam Options['caseNotMatch'] Return value when `T` does not match `Criteria`.
|
|
15
|
+
* Default to `never`.
|
|
16
|
+
*
|
|
17
|
+
* @typeParam Options['caseWiden'] Return value when `widen` is true.
|
|
18
|
+
* Default to `Criteria | undefined`.
|
|
19
|
+
*
|
|
20
|
+
* @typeParam Options['caseUnionNotMatch'] Return value when a branch of the union `T` does not match `Criteria`.
|
|
21
|
+
* Default to `never`.
|
|
22
|
+
*
|
|
23
|
+
* If you want the type to behave more like JavaScript,
|
|
24
|
+
* you can override it to return `undefined`.
|
|
25
|
+
*
|
|
26
|
+
* Since it is a union, the result will be joined to the matched branch as union.
|
|
27
|
+
* e.g. `ElementMatch<1 | 2, 1>` -> `1 | undefined`
|
|
28
|
+
*/
|
|
29
|
+
export type ElementMatch<T, Criteria, Options extends ElementMatch.Options = ElementMatch.DefaultOptions<Criteria>> = [T] extends [Criteria] ? T : (MergeOptions<Options, ElementMatch.DefaultOptions<Criteria>> extends infer C extends Record<keyof ElementMatch.Options, unknown> ? ((T extends Criteria ? T : (C['widen'] extends true ? (Criteria extends T ? C['caseWiden'] : C['caseNotMatch']) : C['caseNotMatch'])) extends infer R ? IsUnion<T, IsNever<R, R, R | C['caseUnionNotMatch']>, R> : C['caseNotMatch']) : never);
|
|
30
|
+
export declare namespace ElementMatch {
|
|
31
|
+
interface Options {
|
|
32
|
+
widen?: boolean | undefined;
|
|
33
|
+
caseNotMatch?: unknown;
|
|
34
|
+
caseWiden?: unknown;
|
|
35
|
+
caseUnionNotMatch?: unknown;
|
|
36
|
+
}
|
|
37
|
+
interface DefaultOptions<Criteria> {
|
|
38
|
+
widen: true;
|
|
39
|
+
caseNotMatch: never;
|
|
40
|
+
caseWiden: Criteria | undefined;
|
|
41
|
+
caseUnionNotMatch: never;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=array_plus.element_match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_plus.element_match.d.ts","sourceRoot":"","sources":["../../ts/array/array_plus.element_match.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,MAAM,YAAY,CACvB,CAAC,EACD,QAAQ,EACR,OAAO,SAAS,YAAY,CAAC,OAAO,GAAG,YAAY,CAAC,cAAc,CAAC,QAAQ,CAAC,IACzE,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,GACvB,CAAC,GACD,CAAC,YAAY,CAAC,OAAO,EAAE,YAAY,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,SAAS,MAAM,CAAC,MAAM,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,GAChI,CAAC,CAAC,CAAC,SAAS,QAAQ,GACnB,CAAC,GACD,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,IAAI,GACvB,CAAC,QAAQ,SAAS,CAAC,GAClB,CAAC,CAAC,WAAW,CAAC,GACd,CAAC,CAAC,cAAc,CAAC,CAAC,GACnB,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,GACpC,OAAO,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,GACxD,CAAC,CAAC,cAAc,CAAC,CAAC,GACnB,KAAK,CAAC,CAAA;AAEV,yBAAiB,YAAY,CAAC;IAC7B,UAAiB,OAAO;QACvB,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;QAC5B,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,iBAAiB,CAAC,EAAE,OAAO,CAAA;KAC3B;IACD,UAAiB,cAAc,CAAC,QAAQ;QACvC,KAAK,EAAE,IAAI,CAAC;QACZ,YAAY,EAAE,KAAK,CAAC;QACpB,SAAS,EAAE,QAAQ,GAAG,SAAS,CAAC;QAChC,iBAAiB,EAAE,KAAK,CAAA;KACxB;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_plus.element_match.js","sourceRoot":"","sources":["../../ts/array/array_plus.element_match.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_plus.filter.d.ts","sourceRoot":"","sources":["../../ts/array/array_plus.filter.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GACtE,CAAC,GACD,QAAQ,SAAS,CAAC,CAAC,CAAC,CAAC,GACrB,KAAK,CAAC,QAAQ,CAAC,GACf,KAAK,EAAE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_plus.filter.js","sourceRoot":"","sources":["../../ts/array/array_plus.filter.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { NeverType } from '../never/never_type.js';
|
|
2
|
+
import type { TupleType } from '../tuple/tuple_type.js';
|
|
3
|
+
import type { MergeOptions } from '../utils/options.js';
|
|
4
|
+
import type { ElementMatch } from './array_plus.element_match.js';
|
|
5
|
+
/**
|
|
6
|
+
* 🦴 *utilities*
|
|
7
|
+
* 🔢 *customizable*
|
|
8
|
+
*
|
|
9
|
+
* Finds the type in array `A` that matches `Criteria`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* type R = ArrayPlus.Find<Array<string>, string> // string
|
|
14
|
+
* type R = ArrayPlus.Find<Array<1 | 2 | 'x'>, number> // 1 | 2 | undefined
|
|
15
|
+
* type R = ArrayPlus.Find<Array<string | number>, number | string> // string | number
|
|
16
|
+
* type R = ArrayPlus.Find<Array<number>, 1> // widen: 1 | undefined
|
|
17
|
+
* type R = ArrayPlus.Find<Array<string | number>, number> // unionMiss: number | undefined
|
|
18
|
+
*
|
|
19
|
+
* type R = ArrayPlus.Find<string[], number> // never
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @typeParam Options['widen'] performs widen match.
|
|
23
|
+
* Default to `true`.
|
|
24
|
+
* With widen match, a narrowed type will match its widen type.
|
|
25
|
+
* e.g. matching `1` against `number` yields `1 | undefined`
|
|
26
|
+
*
|
|
27
|
+
* The widen behavior can be customized by `Options['caseWiden']`
|
|
28
|
+
*
|
|
29
|
+
* @typeParam Options['caseNever'] return type when `A` is `never`. Default to `never`.
|
|
30
|
+
*
|
|
31
|
+
* @typeParam Options['caseNotMatch'] Return value when `T` does not match `Criteria`.
|
|
32
|
+
* Default to `never`.
|
|
33
|
+
*
|
|
34
|
+
* @typeParam Options['caseTuple'] return type when `A` is a tuple. Default to `not supported` message.
|
|
35
|
+
*
|
|
36
|
+
* @typeParam Options['caseWiden'] return type when `T` in `A` is a widen type of `Criteria`.
|
|
37
|
+
* Default to `Criteria | undefined`.
|
|
38
|
+
* Set it to `never` for a more type-centric behavior
|
|
39
|
+
*
|
|
40
|
+
* @typeParam Options['caseUnionNotMatch'] Return value when a branch of the union `T` does not match `Criteria`.
|
|
41
|
+
* Default to `never`.
|
|
42
|
+
*
|
|
43
|
+
* If you want the type to behave more like JavaScript,
|
|
44
|
+
* you can override it to return `undefined`.
|
|
45
|
+
*
|
|
46
|
+
* Since it is a union, the result will be joined to the matched branch as union.
|
|
47
|
+
*/
|
|
48
|
+
export type Find<A extends unknown[], Criteria, Options extends Find.Options = Find.DefaultOptions<Criteria>> = MergeOptions<Options, Find.DefaultOptions<Criteria>> extends infer O extends Find.Options ? TupleType<A, O['caseTuple'], A extends Array<infer T> ? ElementMatch<T, Criteria, O> : never, O> : never;
|
|
49
|
+
export declare namespace Find {
|
|
50
|
+
interface Options extends ElementMatch.Options, NeverType.Options {
|
|
51
|
+
caseTuple?: unknown;
|
|
52
|
+
}
|
|
53
|
+
interface DefaultOptions<Criteria> extends ElementMatch.DefaultOptions<Criteria>, NeverType.DefaultOptions {
|
|
54
|
+
caseTuple: 'does not support tuple. Please use `FindFirst` or `TuplePlus.Find` instead.';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=array_plus.find.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_plus.find.d.ts","sourceRoot":"","sources":["../../ts/array/array_plus.find.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AAEjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AACH,MAAM,MAAM,IAAI,CACf,CAAC,SAAS,OAAO,EAAE,EACnB,QAAQ,EACR,OAAO,SAAS,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,IAE5D,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,SAAS,MAAM,CAAC,SAAS,IAAI,CAAC,OAAO,GACvF,SAAS,CACV,CAAC,EACD,CAAC,CAAC,WAAW,CAAC,EACd,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,GAAG,KAAK,EAC/D,CAAC,CACD,GACC,KAAK,CAAA;AAER,yBAAiB,IAAI,CAAC;IACrB,UAAiB,OAAQ,SAAQ,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO;QACvE,SAAS,CAAC,EAAE,OAAO,CAAC;KACpB;IAED,UAAiB,cAAc,CAAC,QAAQ,CAAE,SAAQ,YAAY,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,cAAc;QAChH,SAAS,EAAE,6EAA6E,CAAC;KACzF;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_plus.find.js","sourceRoot":"","sources":["../../ts/array/array_plus.find.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { CanAssign } from '../index.js';
|
|
2
|
+
import type { CreateTuple } from '../tuple/create_tuple.js';
|
|
3
|
+
import type { UnionOfValues } from './union_of_values.js';
|
|
4
|
+
export type PadStart<A extends unknown[], MaxLength extends number, PadWith = unknown> = MaxLength extends 0 ? A : CanAssign<PadWith, UnionOfValues<A>> extends true ? A : PadStart<[...CreateTuple<MaxLength, PadWith>, ...A], MaxLength, PadWith>;
|
|
5
|
+
//# sourceMappingURL=array_plus.pad_start.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_plus.pad_start.d.ts","sourceRoot":"","sources":["../../ts/array/array_plus.pad_start.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAC3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEzD,MAAM,MAAM,QAAQ,CACnB,CAAC,SAAS,OAAO,EAAE,EACnB,SAAS,SAAS,MAAM,EACxB,OAAO,GAAG,OAAO,IACd,SAAS,SAAS,CAAC,GACpB,CAAC,GACD,SAAS,CAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,SAAS,IAAI,GACjD,CAAC,GACD,QAAQ,CAAC,CAAC,GAAG,WAAW,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_plus.pad_start.js","sourceRoot":"","sources":["../../ts/array/array_plus.pad_start.ts"],"names":[],"mappings":""}
|
|
@@ -1,42 +1,60 @@
|
|
|
1
1
|
import type { IsNever } from '../never/never_type.js';
|
|
2
2
|
import type { StrictNumberType } from '../number/strict_number_type.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* 🌪️ *filter*
|
|
5
5
|
*
|
|
6
|
+
* Filter `T` to ensure it is an array, excluding tuple.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
6
9
|
* ```ts
|
|
7
10
|
* type R = ArrayType<number[]> // number[]
|
|
8
11
|
*
|
|
9
12
|
* type R = ArrayType<[1]> // never
|
|
13
|
+
* type R = ArrayType<number[] | 1> // never
|
|
14
|
+
* type R = ArrayType<number[] & { a: 1 }> // never
|
|
10
15
|
* ```
|
|
11
16
|
*/
|
|
12
17
|
export type ArrayType<T, Then = T, Else = never> = IsNever<T, Else, [
|
|
13
18
|
any[]
|
|
14
19
|
] extends [T] ? ([T] extends [any[]] ? StrictNumberType<T['length'], Then, Else> : Else) : Else>;
|
|
15
20
|
/**
|
|
16
|
-
*
|
|
21
|
+
* 🎭 *validate*
|
|
22
|
+
*
|
|
23
|
+
* Validate that `T` is an array, excluding tuple.
|
|
17
24
|
*
|
|
25
|
+
* @example
|
|
18
26
|
* ```ts
|
|
19
|
-
* type R =
|
|
27
|
+
* type R = IsArray<number[]> // true
|
|
20
28
|
*
|
|
21
|
-
* type R =
|
|
22
|
-
* type R =
|
|
29
|
+
* type R = IsArray<number> // false
|
|
30
|
+
* type R = IsArray<[1]> // false
|
|
23
31
|
* ```
|
|
24
32
|
*/
|
|
25
|
-
export type
|
|
33
|
+
export type IsArray<T, Then = true, Else = false> = ArrayType<T, Then, Else>;
|
|
26
34
|
/**
|
|
27
|
-
*
|
|
35
|
+
* 🌪️ *filter*
|
|
36
|
+
*
|
|
37
|
+
* Filter `T` to ensure it is not an array, excluding tuple.
|
|
28
38
|
*
|
|
39
|
+
* i.e. *tuple* will pass through this filter.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
29
42
|
* ```ts
|
|
30
|
-
* type R =
|
|
43
|
+
* type R = NotArrayType<number[]> // never
|
|
31
44
|
*
|
|
32
|
-
* type R =
|
|
33
|
-
* type R =
|
|
45
|
+
* type R = NotArrayType<number> // number
|
|
46
|
+
* type R = NotArrayType<[1]> // [1]
|
|
34
47
|
* ```
|
|
35
48
|
*/
|
|
36
|
-
export type
|
|
49
|
+
export type NotArrayType<T, Then = T, Else = never> = ArrayType<T, Else, Then>;
|
|
37
50
|
/**
|
|
38
|
-
*
|
|
51
|
+
* 🎭 *validate*
|
|
52
|
+
*
|
|
53
|
+
* Validate that `T` is not an array, excluding tuple.
|
|
54
|
+
*
|
|
55
|
+
* i.e. *tuple* will pass through this filter.
|
|
39
56
|
*
|
|
57
|
+
* @example
|
|
40
58
|
* ```ts
|
|
41
59
|
* type R = IsNotArray<number[]> // false
|
|
42
60
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array_type.d.ts","sourceRoot":"","sources":["../../ts/array/array_type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAEvE
|
|
1
|
+
{"version":3,"file":"array_type.d.ts","sourceRoot":"","sources":["../../ts/array/array_type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAA;AAEvE;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,IAAI,OAAO,CACzD,CAAC,EACD,IAAI,EACJ;IAAC,GAAG,EAAE;CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,EAAE,CAAC,GAAG,gBAAgB,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CACrG,CAAA;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAE5E;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,IAAI,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAE9E;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA"}
|
package/cjs/array/filter.d.ts
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
|
+
import type { Filter as FilterTuple } from '../tuple/tuple_plus.filter.js';
|
|
2
|
+
import type { Filter as FilterArray } from './array_plus.filter.js';
|
|
1
3
|
/**
|
|
2
|
-
*
|
|
4
|
+
* ⚗️ *transform*
|
|
5
|
+
*
|
|
6
|
+
* Filter the array or tuple `A`, keeping entries satisfying `Criteria`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* type R = Filter<[1, 2, '3'], number> // [1, 2]
|
|
11
|
+
* type R = Filter<Array<string | undefined>, string> // string[]
|
|
12
|
+
* ```
|
|
3
13
|
*/
|
|
4
|
-
export type Filter<A extends
|
|
14
|
+
export type Filter<A extends unknown[], Criteria> = number extends A['length'] ? FilterArray<A, Criteria> : FilterTuple<A, Criteria>;
|
|
5
15
|
/**
|
|
6
|
-
*
|
|
16
|
+
* ⚗️ *transform*
|
|
17
|
+
* 👽 *alias*
|
|
18
|
+
*
|
|
19
|
+
* Keeps entries satisfying `Criteria` in array or tuple `A`.
|
|
20
|
+
*
|
|
21
|
+
* @alias of [Filter](./filter.ts)
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* type R = KeepMatch<[1, 2, 3], number> // [1, 2]
|
|
25
|
+
* type R = KeepMatch<Array<string|undefined>, string> // string[]
|
|
26
|
+
* ```
|
|
7
27
|
*/
|
|
8
|
-
export type KeepMatch<A extends
|
|
28
|
+
export type KeepMatch<A extends unknown[], Criteria> = Filter<A, Criteria>;
|
|
9
29
|
//# sourceMappingURL=filter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../ts/array/filter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"filter.d.ts","sourceRoot":"","sources":["../../ts/array/filter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,+BAA+B,CAAA;AAC1E,OAAO,KAAK,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEnE;;;;;;;;;;GAUG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,QAAQ,IAAI,MAAM,SAAS,CAAC,CAAC,QAAQ,CAAC,GAC3E,WAAW,CAAC,CAAC,EAAE,QAAQ,CAAC,GACxB,WAAW,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAA;AAE3B;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,QAAQ,IAAI,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAA"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { TupleType } from '../tuple/tuple_type.js';
|
|
2
|
+
import type { Find as TupleFind } from '../tuple/tuple_plus.find.js';
|
|
3
|
+
import type { Find as ArrayFind } from './array_plus.find.js';
|
|
4
|
+
/**
|
|
5
|
+
* 🦴 *utilities*
|
|
6
|
+
* 🔢 *customizable*
|
|
7
|
+
*
|
|
8
|
+
* Find the first type in the array or tuple `A` that matches `Criteria`.
|
|
9
|
+
*
|
|
10
|
+
* If the `Criteria` is not met, it will return `never'.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* type R = FindFirst<[true, 1, 'x', 3], string> // 'x'
|
|
15
|
+
* type R = FindFirst<[true, 1, 'x', 3], number> // 1
|
|
16
|
+
* type R = FindFirst<[string, number, 1], 1> // widen: 1 | undefined
|
|
17
|
+
* type R = FindFirst<[true, number | string], string> // unionMiss: string | undefined
|
|
18
|
+
* type R = FindFirst<Array<string>, string> // string
|
|
19
|
+
* type R = FindFirst<Array<1 | 2 | 'x'>, number> // 1 | 2 | undefined
|
|
20
|
+
* type R = FindFirst<Array<string | number>, number | string> // string | number
|
|
21
|
+
* type R = FindFirst<Array<number>, 1> // widen: 1 | undefined
|
|
22
|
+
* type R = FindFirst<Array<string | number>, number> // unionMiss: number | undefined
|
|
23
|
+
*
|
|
24
|
+
* type R = FindFirst<[true, 1, 'x'], 2> // never
|
|
25
|
+
* type R = FindFirst<string[], number> // never
|
|
26
|
+
* ```
|
|
27
|
+
*
|
|
28
|
+
* @typeParam Options['widen'] performs widen match.
|
|
29
|
+
* Default to `true`.
|
|
30
|
+
* With widen match, a narrowed type will match its widen type.
|
|
31
|
+
* e.g. matching `1` against `number` yields `1 | undefined`
|
|
32
|
+
*
|
|
33
|
+
* The widen behavior can be customized by `Options['caseWiden']`
|
|
34
|
+
*
|
|
35
|
+
* @typeParam Options['caseEmptyTuple'] return type when `A` is an empty tuple.
|
|
36
|
+
* Default to `never`.
|
|
37
|
+
*
|
|
38
|
+
* @typeParam Options['caseNever'] return type when `A` is `never`. Default to `never`.
|
|
39
|
+
*
|
|
40
|
+
* @typeParam Options['caseNoMatch'] Return value when `T` does not match `Criteria`.
|
|
41
|
+
* Default to `never`.
|
|
42
|
+
*
|
|
43
|
+
* @typeParam Options['caseWiden'] return type when `T` in `A` is a widen type of `Criteria`.
|
|
44
|
+
* Default to `Criteria | undefined`.
|
|
45
|
+
* Set it to `never` for a more type-centric behavior
|
|
46
|
+
*
|
|
47
|
+
* @typeParam Options['caseUnionMiss'] Return value when a branch of the union `T` does not match `Criteria`.
|
|
48
|
+
* Default to `undefined`.
|
|
49
|
+
* Since it is a union, the result will be join to the matched branch as union.
|
|
50
|
+
*/
|
|
51
|
+
export type FindFirst<A extends unknown[], Criteria, Options extends FindFirst.Options = FindFirst.DefaultOptions<Criteria>> = TupleType<A, TupleFind<A, Criteria, Options>, ArrayFind<A, Criteria, Options>>;
|
|
52
|
+
export declare namespace FindFirst {
|
|
53
|
+
interface Options extends ArrayFind.Options, TupleFind.Options {
|
|
54
|
+
}
|
|
55
|
+
interface DefaultOptions<Criteria> extends ArrayFind.DefaultOptions<Criteria>, TupleFind.DefaultOptions<Criteria> {
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated use FindFirst
|
|
60
|
+
*/
|
|
61
|
+
export type First<A extends any[], Criteria> = FindFirst<A, Criteria>;
|
|
62
|
+
//# sourceMappingURL=find_first.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find_first.d.ts","sourceRoot":"","sources":["../../ts/array/find_first.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,KAAK,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAA;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,MAAM,MAAM,SAAS,CACpB,CAAC,SAAS,OAAO,EAAE,EACnB,QAAQ,EAAE,OAAO,SAAS,SAAS,CAAC,OAAO,GAAG,SAAS,CAAC,cAAc,CAAC,QAAQ,CAAC,IAC7E,SAAS,CACZ,CAAC,EACD,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,EAC/B,SAAS,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,CAC/B,CAAA;AAED,yBAAiB,SAAS,CAAC;IAC1B,UAAiB,OAAQ,SAAQ,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,OAAO;KAAI;IACzE,UAAiB,cAAc,CAAC,QAAQ,CACvC,SAAQ,SAAS,CAAC,cAAc,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAC,cAAc,CAAC,QAAQ,CAAC;KAAI;CACnF;AAGD;;GAEG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,QAAQ,IAAI,SAAS,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find_first.js","sourceRoot":"","sources":["../../ts/array/find_first.ts"],"names":[],"mappings":""}
|
package/cjs/array/head.d.ts
CHANGED
|
@@ -1,2 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
import type { NeverType } from '../never/never_type.js';
|
|
2
|
+
/**
|
|
3
|
+
* 🦴 *utilities*
|
|
4
|
+
* 🔢 *customizable*
|
|
5
|
+
*
|
|
6
|
+
* Gets the first entry in the tuple or the type of array `T`.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* type R = Head<[1, 2, 3]> // 1
|
|
11
|
+
* type R = Head<string[]> // string
|
|
12
|
+
*
|
|
13
|
+
* type R = Head<[]> // never
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* @typeParam Options['caseNever'] Return type when `T` is `never`.
|
|
17
|
+
* Default to `never`.
|
|
18
|
+
*
|
|
19
|
+
* @typeParam Options['caseEmptyTuple'] Return type when `T` is `[]`.
|
|
20
|
+
* Default to `never`.
|
|
21
|
+
*/
|
|
22
|
+
export type Head<T extends unknown[], Options extends Head.Options = Head.DefaultOptions> = NeverType<T, Options['caseNever'], T['length'] extends 0 ? Options['caseEmptyTuple'] : T[0]>;
|
|
23
|
+
export declare namespace Head {
|
|
24
|
+
interface Options extends NeverType.Options {
|
|
25
|
+
caseEmptyTuple?: unknown;
|
|
26
|
+
}
|
|
27
|
+
interface DefaultOptions extends NeverType.DefaultOptions {
|
|
28
|
+
caseEmptyTuple: never;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
2
31
|
//# sourceMappingURL=head.d.ts.map
|
package/cjs/array/head.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"head.d.ts","sourceRoot":"","sources":["../../ts/array/head.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,
|
|
1
|
+
{"version":3,"file":"head.d.ts","sourceRoot":"","sources":["../../ts/array/head.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAEvD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,IAAI,CACf,CAAC,SAAS,OAAO,EAAE,EACnB,OAAO,SAAS,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,cAAc,IAC/C,SAAS,CACZ,CAAC,EACD,OAAO,CAAC,WAAW,CAAC,EACpB,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CACxD,CAAA;AAED,yBAAiB,IAAI,CAAC;IACrB,UAAiB,OAAQ,SAAQ,SAAS,CAAC,OAAO;QACjD,cAAc,CAAC,EAAE,OAAO,CAAA;KACxB;IAED,UAAiB,cAAe,SAAQ,SAAS,CAAC,cAAc;QAC/D,cAAc,EAAE,KAAK,CAAA;KACrB;CACD"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { KeyTypes } from '../object/index.js';
|
|
2
|
-
import type { Tail } from '
|
|
2
|
+
import type { Tail } from '../tuple/tail.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* 🦴 *utilities*
|
|
5
|
+
*
|
|
6
|
+
* Gets the intersect of properties of the elements in `A`.
|
|
5
7
|
*/
|
|
6
|
-
export type IntersectOfProps<A extends Record<any, unknown>[], P extends KeyTypes> = A['length'] extends 0 ? never : A['length'] extends 1 ? A[0][P] : A[0][P] & IntersectOfProps<Tail<A>, P>;
|
|
8
|
+
export type IntersectOfProps<A extends Record<any, unknown>[], P extends KeyTypes> = number extends A['length'] ? A[0][P] : A['length'] extends 0 ? never : A['length'] extends 1 ? A[0][P] : A[0][P] & IntersectOfProps<Tail<A>, P>;
|
|
7
9
|
/**
|
|
8
10
|
* Gets the intersect of properties of the elements in `A`
|
|
9
11
|
* This will be deprecated in 4.0. Please use IntersectOfProps instead.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intersect_of_props.d.ts","sourceRoot":"","sources":["../../ts/array/intersect_of_props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"intersect_of_props.d.ts","sourceRoot":"","sources":["../../ts/array/intersect_of_props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAE5C;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC,SAAS,QAAQ,IAAI,MAAM,SAAS,CAAC,CAAC,QAAQ,CAAC,GAC5G,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACP,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACrB,KAAK,GACL,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACrB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACP,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAEzC;;;GAGG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,SAAS,QAAQ,IAAI,gBAAgB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA"}
|
package/cjs/array/last.d.ts
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
|
+
import type { NeverType } from '../never/never_type.js';
|
|
1
2
|
/**
|
|
2
|
-
*
|
|
3
|
+
* 🦴 *utilities*
|
|
4
|
+
*
|
|
5
|
+
* Gets the last entry in the tuple or the type of array `T`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* type R = Last<[1, 2, 3]> // 3
|
|
10
|
+
* type R = Last<string[]> // string
|
|
11
|
+
*
|
|
12
|
+
* type R = Last<[]> // never
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @typeParam Options['caseNever'] Return type when `T` is `never`.
|
|
16
|
+
* Default to `never`.
|
|
17
|
+
*
|
|
18
|
+
* @typeParam Options['caseEmptyTuple'] Return type when `T` is `[]`.
|
|
19
|
+
* Default to `never`.
|
|
3
20
|
*/
|
|
4
|
-
export type Last<T extends
|
|
21
|
+
export type Last<T extends unknown[], Options extends Last.Options = Last.DefaultOptions> = NeverType<T, Options['caseNever'], T['length'] extends 0 ? Options['caseEmptyTuple'] : T extends [...unknown[], infer R] ? R : T[0]>;
|
|
22
|
+
export declare namespace Last {
|
|
23
|
+
interface Options extends NeverType.Options {
|
|
24
|
+
caseEmptyTuple?: unknown;
|
|
25
|
+
}
|
|
26
|
+
interface DefaultOptions extends NeverType.DefaultOptions {
|
|
27
|
+
caseEmptyTuple: never;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
5
30
|
//# sourceMappingURL=last.d.ts.map
|
package/cjs/array/last.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"last.d.ts","sourceRoot":"","sources":["../../ts/array/last.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"last.d.ts","sourceRoot":"","sources":["../../ts/array/last.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAEvD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,IAAI,CACf,CAAC,SAAS,OAAO,EAAE,EACnB,OAAO,SAAS,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,cAAc,IAC/C,SAAS,CAAC,CAAC,EACd,OAAO,CAAC,WAAW,CAAC,EACpB,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAChG,CAAA;AAED,yBAAiB,IAAI,CAAC;IACrB,UAAiB,OAAQ,SAAQ,SAAS,CAAC,OAAO;QACjD,cAAc,CAAC,EAAE,OAAO,CAAA;KACxB;IAED,UAAiB,cAAe,SAAQ,SAAS,CAAC,cAAc;QAC/D,cAAc,EAAE,KAAK,CAAA;KACrB;CACD"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import type { KeyTypes } from '../object/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* 🦴 *utilities*
|
|
4
|
+
*
|
|
5
|
+
* return an array whose items are restricted to the provided literals.
|
|
6
|
+
*/
|
|
2
7
|
export declare function literalArray<T extends KeyTypes>(...entries: T[]): T[];
|
|
3
8
|
//# sourceMappingURL=literal_array.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"literal_array.d.ts","sourceRoot":"","sources":["../../ts/array/literal_array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAElD,wBAAgB,YAAY,CAAC,CAAC,SAAS,QAAQ,EAAE,GAAG,OAAO,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAErE"}
|
|
1
|
+
{"version":3,"file":"literal_array.d.ts","sourceRoot":"","sources":["../../ts/array/literal_array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAElD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,QAAQ,EAAE,GAAG,OAAO,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAErE"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.literalArray = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 🦴 *utilities*
|
|
6
|
+
*
|
|
7
|
+
* return an array whose items are restricted to the provided literals.
|
|
8
|
+
*/
|
|
4
9
|
function literalArray(...entries) {
|
|
5
10
|
return entries;
|
|
6
11
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"literal_array.js","sourceRoot":"","sources":["../../ts/array/literal_array.ts"],"names":[],"mappings":";;;AAEA,SAAgB,YAAY,CAAqB,GAAG,OAAY;IAC/D,OAAO,OAAO,CAAA;AACf,CAAC;AAFD,oCAEC"}
|
|
1
|
+
{"version":3,"file":"literal_array.js","sourceRoot":"","sources":["../../ts/array/literal_array.ts"],"names":[],"mappings":";;;AAEA;;;;GAIG;AACH,SAAgB,YAAY,CAAqB,GAAG,OAAY;IAC/D,OAAO,OAAO,CAAA;AACf,CAAC;AAFD,oCAEC"}
|
package/cjs/array/pad_start.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type { PadStart as TuplePadStart } from '../tuple/tuple_plus.pad_start.js';
|
|
4
|
-
import type { UnionOfValues } from './union_of_values.js';
|
|
1
|
+
import type { PadStart as PadStartTuple } from '../tuple/tuple_plus.pad_start.js';
|
|
2
|
+
import type { PadStart as PadStartArray } from './array_plus.pad_start.js';
|
|
5
3
|
/**
|
|
6
4
|
* Pads the start of an array or tuple with `PadWith`.
|
|
7
5
|
*
|
|
6
|
+
* ⚗️ *transform*
|
|
7
|
+
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```ts
|
|
10
10
|
* // Padding array
|
|
@@ -24,7 +24,7 @@ import type { UnionOfValues } from './union_of_values.js';
|
|
|
24
24
|
* PadStart<[1, 2, 3], 5> // [unknown, unknown, 1, 2, 3]
|
|
25
25
|
* ```
|
|
26
26
|
*/
|
|
27
|
-
export type PadStart<A extends unknown[], MaxLength extends number, PadWith = unknown> = number extends A['length'] ?
|
|
27
|
+
export type PadStart<A extends unknown[], MaxLength extends number, PadWith = unknown> = number extends A['length'] ? PadStartArray<A, MaxLength, PadWith> : PadStartTuple<A, MaxLength, PadWith>;
|
|
28
28
|
/**
|
|
29
29
|
* @deprecated use PadStart instead
|
|
30
30
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pad_start.d.ts","sourceRoot":"","sources":["../../ts/array/pad_start.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"pad_start.d.ts","sourceRoot":"","sources":["../../ts/array/pad_start.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,kCAAkC,CAAA;AACjF,OAAO,KAAK,EAAE,QAAQ,IAAI,aAAa,EAAE,MAAM,2BAA2B,CAAA;AAE1E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,MAAM,QAAQ,CACnB,CAAC,SAAS,OAAO,EAAE,EACnB,SAAS,SAAS,MAAM,EACxB,OAAO,GAAG,OAAO,IACd,MAAM,SAAS,CAAC,CAAC,QAAQ,CAAC,GAC3B,aAAa,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,GACpC,aAAa,CAAC,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,CAAA;AAEvC;;GAEG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,KAAK,SAAS,MAAM,EAAE,OAAO,GAAG,GAAG,IAAI,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAA"}
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 🦴 *utilities*
|
|
3
|
+
*
|
|
4
|
+
* `reduce()` with predicate for early termination.
|
|
5
|
+
* A simple version of the same function in the `ramda` package.
|
|
6
|
+
*/
|
|
1
7
|
export declare function reduceWhile<T, R>(predicate: (acc: R, currentValue: T) => boolean, callbackfn: (previousValue: R, currentValue: T, currentIndex: number, array: T[]) => R, initialValue: R, array: T[]): R;
|
|
2
8
|
//# sourceMappingURL=reduce_while.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reduce_while.d.ts","sourceRoot":"","sources":["../../ts/array/reduce_while.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAC/B,SAAS,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,KAAK,OAAO,EAC/C,UAAU,EAAE,CAAC,aAAa,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,EACtF,YAAY,EAAE,CAAC,EACf,KAAK,EAAE,CAAC,EAAE,KASV"}
|
|
1
|
+
{"version":3,"file":"reduce_while.d.ts","sourceRoot":"","sources":["../../ts/array/reduce_while.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAC/B,SAAS,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,KAAK,OAAO,EAC/C,UAAU,EAAE,CAAC,aAAa,EAAE,CAAC,EAAE,YAAY,EAAE,CAAC,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,EACtF,YAAY,EAAE,CAAC,EACf,KAAK,EAAE,CAAC,EAAE,KASV"}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.reduceWhile = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* 🦴 *utilities*
|
|
6
|
+
*
|
|
7
|
+
* `reduce()` with predicate for early termination.
|
|
8
|
+
* A simple version of the same function in the `ramda` package.
|
|
9
|
+
*/
|
|
4
10
|
function reduceWhile(predicate, callbackfn, initialValue, array) {
|
|
5
11
|
let acc = initialValue;
|
|
6
12
|
for (let i = 0; i < array.length; i++) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reduce_while.js","sourceRoot":"","sources":["../../ts/array/reduce_while.ts"],"names":[],"mappings":";;;AAAA,SAAgB,WAAW,CAC1B,SAA+C,EAC/C,UAAsF,EACtF,YAAe,EACf,KAAU;IAEV,IAAI,GAAG,GAAG,YAAY,CAAA;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAE,CAAA;QACvB,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC;YAAE,OAAO,GAAG,CAAA;QACtC,GAAG,GAAG,UAAU,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,CAAA;KACtC;IACD,OAAO,GAAG,CAAA;AACX,CAAC;AAbD,kCAaC"}
|
|
1
|
+
{"version":3,"file":"reduce_while.js","sourceRoot":"","sources":["../../ts/array/reduce_while.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,SAAgB,WAAW,CAC1B,SAA+C,EAC/C,UAAsF,EACtF,YAAe,EACf,KAAU;IAEV,IAAI,GAAG,GAAG,YAAY,CAAA;IACtB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACtC,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,CAAE,CAAA;QACvB,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,KAAK,CAAC;YAAE,OAAO,GAAG,CAAA;QACtC,GAAG,GAAG,UAAU,CAAC,GAAG,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,CAAC,CAAA;KACtC;IACD,OAAO,GAAG,CAAA;AACX,CAAC;AAbD,kCAaC"}
|
package/cjs/array/reverse.d.ts
CHANGED
|
@@ -1,2 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ⚗️ *transform*
|
|
3
|
+
*
|
|
4
|
+
* reverses the order of `A`.
|
|
5
|
+
*/
|
|
1
6
|
export type Reverse<A extends unknown[]> = number extends A['length'] ? A : A['length'] extends 0 ? A : A['length'] extends 1 ? A : A extends [any, ...infer T] ? T extends any[] ? [...Reverse<T>, A[0]] : never : never;
|
|
2
7
|
//# sourceMappingURL=reverse.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reverse.d.ts","sourceRoot":"","sources":["../../ts/array/reverse.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,OAAO,EAAE,IAAI,MAAM,SAAS,CAAC,CAAC,QAAQ,CAAC,GAClE,CAAC,GACD,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACrB,CAAC,GACD,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACrB,CAAC,GACD,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,CAAC,GAC3B,CAAC,SAAS,GAAG,EAAE,GACd,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GACrB,KAAK,GACN,KAAK,CAAA"}
|
|
1
|
+
{"version":3,"file":"reverse.d.ts","sourceRoot":"","sources":["../../ts/array/reverse.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,OAAO,EAAE,IAAI,MAAM,SAAS,CAAC,CAAC,QAAQ,CAAC,GAClE,CAAC,GACD,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACrB,CAAC,GACD,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACrB,CAAC,GACD,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,MAAM,CAAC,CAAC,GAC3B,CAAC,SAAS,GAAG,EAAE,GACd,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,GACrB,KAAK,GACN,KAAK,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"union_of_props.d.ts","sourceRoot":"","sources":["../../ts/array/union_of_props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"union_of_props.d.ts","sourceRoot":"","sources":["../../ts/array/union_of_props.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAClD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAE5C;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,SAAS,QAAQ,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GAC/F,KAAK,GACL,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACrB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACP,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;AAErC;;;GAGG;AACH,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,SAAS,QAAQ,IAAI,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA"}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { type AnyConstructor } from '../class/index.js';
|
|
2
2
|
import { type AnyFunction } from '../function/any_function.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* 💥 *immediate*
|
|
5
|
+
* 🚦 *assertion*
|
|
6
|
+
*
|
|
7
|
+
* Assert the subject satisfies the specified type T
|
|
5
8
|
* @type T the type to check against.
|
|
6
9
|
*/
|
|
7
10
|
export declare function assertType<T>(subject: T): asserts subject is T;
|