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
package/esm/any/any_type.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 🌪️ *filter*
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Filter `T` to ensure it is exactly `any`.
|
|
5
5
|
*
|
|
6
6
|
* @example
|
|
7
7
|
* ```ts
|
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
*/
|
|
15
15
|
export type AnyType<T, Then = T, Else = never> = 0 extends 1 & T ? Then : Else;
|
|
16
16
|
/**
|
|
17
|
-
* Validate if `T` is exactly `any`.
|
|
18
|
-
*
|
|
19
17
|
* 🎭 *validate*
|
|
20
18
|
*
|
|
19
|
+
* Validate if `T` is exactly `any`.
|
|
20
|
+
*
|
|
21
21
|
* @example
|
|
22
22
|
* ```ts
|
|
23
23
|
* type R = IsAny<any> // true
|
|
@@ -29,9 +29,9 @@ export type AnyType<T, Then = T, Else = never> = 0 extends 1 & T ? Then : Else;
|
|
|
29
29
|
*/
|
|
30
30
|
export type IsAny<T, Then = true, Else = false> = AnyType<T, Then, Else>;
|
|
31
31
|
/**
|
|
32
|
-
*
|
|
32
|
+
* 🌪️ *filter*
|
|
33
33
|
*
|
|
34
|
-
*
|
|
34
|
+
* Filter `T` to ensure it is not exactly `any`.
|
|
35
35
|
*
|
|
36
36
|
* @example
|
|
37
37
|
* ```ts
|
|
@@ -44,10 +44,10 @@ export type IsAny<T, Then = true, Else = false> = AnyType<T, Then, Else>;
|
|
|
44
44
|
*/
|
|
45
45
|
export type NotAnyType<T, Then = T, Else = never> = AnyType<T, Else, Then>;
|
|
46
46
|
/**
|
|
47
|
-
* Validate if `T` is not exactly `any`.
|
|
48
|
-
*
|
|
49
47
|
* 🎭 *validate*
|
|
50
48
|
*
|
|
49
|
+
* Validate if `T` is not exactly `any`.
|
|
50
|
+
*
|
|
51
51
|
* @example
|
|
52
52
|
* ```ts
|
|
53
53
|
* import type { IsNotAny } from 'type-plus'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"any_type.d.ts","sourceRoot":"","sources":["../../ts/any/any_type.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"any_type.d.ts","sourceRoot":"","sources":["../../ts/any/any_type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA;AAE9E;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAExE;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,KAAK,IAAI,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAE1E;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,GAAG,KAAK,IAAI,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA"}
|
package/esm/array/array.at.d.ts
CHANGED
|
@@ -2,7 +2,9 @@ import type { IsStrictNumber } from '../number/strict_number_type.js';
|
|
|
2
2
|
import type { TupleType } from '../tuple/tuple_type.js';
|
|
3
3
|
import type { IndexAt } from './array_index.js';
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* 🦴 *utilities*
|
|
6
|
+
*
|
|
7
|
+
* Gets the type of the array or tuple at positive or negative index `N`.
|
|
6
8
|
*
|
|
7
9
|
* Like `Array.at()`, this type supports negative numbers.
|
|
8
10
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.at.d.ts","sourceRoot":"","sources":["../../ts/array/array.at.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE/C
|
|
1
|
+
{"version":3,"file":"array.at.d.ts","sourceRoot":"","sources":["../../ts/array/array.at.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAA;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE/C;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,EAAE,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,SAAS,MAAM,EAAE,IAAI,GAAG,KAAK,IAAI,OAAO,CAC5E,CAAC,EACD,CAAC,EACD,IAAI,EACJ,IAAI,EACJ,IAAI,CACJ,SAAS,MAAM,CAAC,GACd,CAAC,SAAS,MAAM,GACf,SAAS,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,GACzE,IAAI,GACL,KAAK,CAAA"}
|
|
@@ -11,7 +11,8 @@ import type { IsTuple } from '../tuple/tuple_type.js';
|
|
|
11
11
|
* ArrayPlus.Entries<[1, 2, 3]> // [[0, 1], [1, 2], [2, 3]]
|
|
12
12
|
* ```
|
|
13
13
|
*/
|
|
14
|
-
export type Entries<A extends unknown[]> = IsTuple<A, Device<A, []>, A extends Array<infer T> ? Array<[number, T]> : never>;
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
export type Entries<A extends unknown[]> = IsTuple<A, Entries.Device<A, []>, A extends Array<infer T> ? Array<[number, T]> : never>;
|
|
15
|
+
export declare namespace Entries {
|
|
16
|
+
type Device<A extends unknown[], R extends unknown[]> = A['length'] extends 0 ? R : A extends [...infer F, infer N] ? Device<F, [[F['length'], N], ...R]> : never;
|
|
17
|
+
}
|
|
17
18
|
//# sourceMappingURL=array.entries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.entries.d.ts","sourceRoot":"","sources":["../../ts/array/array.entries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,OAAO,EAAE,IAAI,OAAO,CACjD,CAAC,EACD,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"array.entries.d.ts","sourceRoot":"","sources":["../../ts/array/array.entries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AACrD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,OAAO,EAAE,IAAI,OAAO,CACjD,CAAC,EACD,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,CAAC,EACrB,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,CACrD,CAAA;AAED,yBAAiB,OAAO,CAAC;IACxB,KAAY,MAAM,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,SAAS,OAAO,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GAClF,CAAC,GACD,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAC/B,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC,GACnC,KAAK,CAAA;CACP"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { TupleType } from '../tuple/tuple_type.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* 🦴 *utilities*
|
|
4
|
+
*
|
|
5
|
+
* Gets the last type in the array or tuple that matches the `Criteria`.
|
|
4
6
|
*
|
|
5
7
|
* If the `Criteria` is not met, it will return `never'.
|
|
6
8
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.find_last.d.ts","sourceRoot":"","sources":["../../ts/array/array.find_last.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAEvD
|
|
1
|
+
{"version":3,"file":"array.find_last.d.ts","sourceRoot":"","sources":["../../ts/array/array.find_last.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AAEvD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,EAAE,QAAQ,IAAI,SAAS,CAC/D,CAAC,EACD,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GAClB,KAAK,GACL,CAAC,SAAS,CAAC,GAAG,MAAM,KAAK,EAAE,MAAM,IAAI,CAAC,GACtC,IAAI,SAAS,QAAQ,GACpB,IAAI,GACJ,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,GAC1B,KAAK,EACR,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,QAAQ,GAAG,CAAC,GAAG,SAAS,GAAG,KAAK,CAAC,GAAG,KAAK,CAC/E,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IsEqual } from '../equal/equal.js';
|
|
2
2
|
import type { CanAssign } from '../index.js';
|
|
3
|
-
import type { Tail } from '
|
|
3
|
+
import type { Tail } from '../tuple/tail.js';
|
|
4
4
|
import type { UnionOfValues } from './union_of_values.js';
|
|
5
5
|
/**
|
|
6
6
|
* Determines whether the array type `A` contains any elements that satisfies the specified `Criteria` type.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.some.d.ts","sourceRoot":"","sources":["../../ts/array/array.some.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"array.some.d.ts","sourceRoot":"","sources":["../../ts/array/array.some.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC5C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AAEzD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,IAAI,CACf,CAAC,SAAS,GAAG,EAAE,EACf,QAAQ,EACR,IAAI,SAAS,QAAQ,GAAG,OAAO,GAAG,OAAO,EACzC,IAAI,GAAG,IAAI,EACX,IAAI,GAAG,KAAK,IACT,IAAI,SAAS,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AAEtG,yBAAiB,IAAI,CAAC;IACrB,KAAY,MAAM,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,IAAI,MAAM,SAAS,CAAC,CAAC,QAAQ,CAAC,GACvF,WAAW,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,GACpC,WAAW,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IAEvC,KAAY,WAAW,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,IAAI,OAAO,CAC3E,aAAa,CAAC,CAAC,CAAC,EAChB,QAAQ,EACR,IAAI,EACJ,IAAI,CACJ,CAAA;IAED,KAAY,WAAW,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACvF,IAAI,GACJ,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,SAAS,IAAI,GACpC,IAAI,GACJ,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IAE7C,KAAY,KAAK,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,IAAI,MAAM,SAAS,CAAC,CAAC,QAAQ,CAAC,GACtF,UAAU,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,GACnC,UAAU,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IAEtC,KAAY,UAAU,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,IAAI,SAAS,CAC5E,aAAa,CAAC,CAAC,CAAC,EAChB,QAAQ,EACR,IAAI,EACJ,IAAI,CACJ,CAAA;IAED,KAAY,UAAU,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACtF,IAAI,GACJ,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GACrB,IAAI,GACJ,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;CAC5C"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { NeverType } from '../never/never_type.js';
|
|
2
|
+
import type { KeyTypes } from '../object/KeyTypes.js';
|
|
3
|
+
/**
|
|
4
|
+
* ⚗️ *transform*
|
|
5
|
+
* 🔢 *customization*
|
|
6
|
+
*
|
|
7
|
+
* Gets the common keys of the record types in the array `A`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { type ArrayPlus } from 'type-plus'
|
|
12
|
+
*
|
|
13
|
+
* type R = ArrayPlus.CommonPropKeys<Array<{ a: 1 }>> // 'a'
|
|
14
|
+
* type R = ArrayPlus.CommonPropKeys<Array<{ a: 1, b: 1 } | { a: 1, c: 1 }>> // 'a'
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* @typeParam Options['caseNever'] Return type when `T` is `never`.
|
|
18
|
+
* Default to `never`.
|
|
19
|
+
*/
|
|
20
|
+
export type CommonPropKeys<A extends Record<KeyTypes, unknown>[], Options extends CommonPropKeys.Options = CommonPropKeys.DefaultOptions> = NeverType<A, Options['caseNever'], A extends Array<infer R extends Record<KeyTypes, unknown>> ? keyof R : never>;
|
|
21
|
+
export declare namespace CommonPropKeys {
|
|
22
|
+
interface Options extends NeverType.Options {
|
|
23
|
+
}
|
|
24
|
+
interface DefaultOptions extends NeverType.DefaultOptions {
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=array_plus.common_prop_keys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_plus.common_prop_keys.d.ts","sourceRoot":"","sources":["../../ts/array/array_plus.common_prop_keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAErD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,cAAc,CACzB,CAAC,SAAS,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,EACrC,OAAO,SAAS,cAAc,CAAC,OAAO,GAAG,cAAc,CAAC,cAAc,IACnE,SAAS,CAAC,CAAC,EACd,OAAO,CAAC,WAAW,CAAC,EACpB,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,SAAS,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,KAAK,CAC5E,CAAA;AAED,yBAAiB,cAAc,CAAC;IAC/B,UAAiB,OAAQ,SAAQ,SAAS,CAAC,OAAO;KACjD;IAED,UAAiB,cAAe,SAAQ,SAAS,CAAC,cAAc;KAC/D;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_plus.common_prop_keys.js","sourceRoot":"","sources":["../../ts/array/array_plus.common_prop_keys.ts"],"names":[],"mappings":""}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
+
* 🦴 *utilities
|
|
3
|
+
* 💀 *deprecated* Will be available only as `ArrayPlus.Concat` in the next version
|
|
4
|
+
*
|
|
2
5
|
* Concats two arrays or tuples.
|
|
3
6
|
*
|
|
4
7
|
* alias of: `[...A, ...B]`
|
|
@@ -10,4 +13,4 @@
|
|
|
10
13
|
* ```
|
|
11
14
|
*/
|
|
12
15
|
export type Concat<A extends unknown[], B extends unknown[]> = [...A, ...B];
|
|
13
|
-
//# sourceMappingURL=
|
|
16
|
+
//# sourceMappingURL=array_plus.concat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_plus.concat.d.ts","sourceRoot":"","sources":["../../ts/array/array_plus.concat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,SAAS,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_plus.concat.js","sourceRoot":"","sources":["../../ts/array/array_plus.concat.ts"],"names":[],"mappings":""}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
export type { At } from './array.at.js';
|
|
2
|
-
export type { Concat } from './array.concat.js';
|
|
3
2
|
export type { Entries } from './array.entries.js';
|
|
4
|
-
export type { FindFirst as Find } from './array.find.js';
|
|
5
3
|
export type { FindLast } from './array.find_last.js';
|
|
6
4
|
export type { Reverse } from './array.reverse.js';
|
|
7
5
|
export type { Some } from './array.some.js';
|
|
8
6
|
export type { IndexAt, IsIndexOutOfBound } from './array_index.js';
|
|
7
|
+
export type { CommonPropKeys } from './array_plus.common_prop_keys.js';
|
|
8
|
+
export type { Concat } from './array_plus.concat.js';
|
|
9
|
+
export type { DropMatch } from './array_plus.drop_match.js';
|
|
10
|
+
export type { ElementMatch } from './array_plus.element_match.js';
|
|
11
|
+
export type { Filter } from './array_plus.filter.js';
|
|
12
|
+
export type { Find } from './array_plus.find.js';
|
|
13
|
+
export type { PadStart } from './array_plus.pad_start.js';
|
|
9
14
|
export type { SplitAt } from './array_plus.split_at.js';
|
|
10
|
-
export type { PadStart } from './pad_start.js';
|
|
11
15
|
//# sourceMappingURL=array_plus.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array_plus.d.ts","sourceRoot":"","sources":["../../ts/array/array_plus.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AACvC,YAAY,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"array_plus.d.ts","sourceRoot":"","sources":["../../ts/array/array_plus.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,EAAE,EAAE,MAAM,eAAe,CAAA;AACvC,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACjD,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AACpD,YAAY,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AACjD,YAAY,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAC3C,YAAY,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AAClE,YAAY,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACtE,YAAY,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACpD,YAAY,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AAC3D,YAAY,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAA;AACjE,YAAY,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AACpD,YAAY,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAChD,YAAY,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAA;AACzD,YAAY,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAA"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { NonNull } from '../utils/NonNull.js';
|
|
2
|
+
import type { NonUndefined } from '../utils/NonUndefined.js';
|
|
3
|
+
export type DropMatch<A extends Readonly<Array<unknown>>, Criteria> = A[0] extends Criteria ? never[] : (undefined extends Criteria ? (null extends Criteria ? Array<NonNullable<A[0]>> : Array<NonUndefined<A[0]>>) : (null extends Criteria ? Array<NonNull<A[0]>> : (Criteria extends A[0] ? Array<Exclude<A[0], Criteria>> : (A[0] extends Criteria ? A : Array<Exclude<A[0], Criteria>>))));
|
|
4
|
+
//# sourceMappingURL=array_plus.drop_match.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_plus.drop_match.d.ts","sourceRoot":"","sources":["../../ts/array/array_plus.drop_match.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAE5D,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,EAAE,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GACxF,KAAK,EAAE,GACP,CAAC,SAAS,SAAS,QAAQ,GAC1B,CAAC,IAAI,SAAS,QAAQ,GACrB,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACxB,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAC3B,CAAC,IAAI,SAAS,QAAQ,GACrB,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACpB,CAAC,QAAQ,SAAS,CAAC,CAAC,CAAC,CAAC,GACrB,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,GAC9B,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,QAAQ,GACrB,CAAC,GACD,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array_plus.drop_match.js","sourceRoot":"","sources":["../../ts/array/array_plus.drop_match.ts"],"names":[],"mappings":""}
|
|
@@ -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/esm/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":""}
|