type-plus 7.3.0 → 7.4.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 +131 -156
- 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.find.d.ts +3 -1
- package/cjs/array/array.find.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.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.concat.js → array_plus.concat.js} +1 -1
- package/cjs/array/array_plus.concat.js.map +1 -0
- package/cjs/array/array_plus.d.ts +3 -2
- package/cjs/array/array_plus.d.ts.map +1 -1
- 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.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/head.d.ts +18 -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 +16 -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/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 +19 -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 +18 -10
- package/cjs/mix_types/any_or_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/testing/test_type.d.ts +44 -1
- package/cjs/testing/test_type.d.ts.map +1 -1
- package/cjs/tuple/common_prop_keys.d.ts +29 -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 +72 -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.d.ts +2 -1
- package/cjs/tuple/tuple_plus.d.ts.map +1 -1
- 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.js +0 -15
- package/cjs/tuple/tuple_plus.js.map +1 -1
- package/cjs/tuple/tuple_plus.pad_start.d.ts +8 -3
- package/cjs/tuple/tuple_plus.pad_start.d.ts.map +1 -1
- 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.find.d.ts +3 -1
- package/esm/array/array.find.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.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 +3 -2
- package/esm/array/array_plus.d.ts.map +1 -1
- 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.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/head.d.ts +18 -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 +16 -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/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 +19 -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 +18 -10
- package/esm/mix_types/any_or_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/testing/test_type.d.ts +44 -1
- package/esm/testing/test_type.d.ts.map +1 -1
- package/esm/tuple/common_prop_keys.d.ts +29 -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 +72 -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.d.ts +2 -1
- package/esm/tuple/tuple_plus.d.ts.map +1 -1
- 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.js +1 -1
- package/esm/tuple/tuple_plus.js.map +1 -1
- package/esm/tuple/tuple_plus.pad_start.d.ts +8 -3
- package/esm/tuple/tuple_plus.pad_start.d.ts.map +1 -1
- package/package.json +15 -11
- package/ts/any/any_type.ts +8 -9
- package/ts/any/readme.md +91 -7
- package/ts/array/array.at.ts +3 -1
- package/ts/array/array.find.ts +3 -1
- package/ts/array/array.find_last.ts +3 -1
- package/ts/array/array.some.ts +1 -1
- package/ts/array/{array.concat.ts → array_plus.concat.ts} +3 -0
- package/ts/array/array_plus.filter.ts +5 -0
- package/ts/array/array_plus.pad_start.ts +13 -0
- package/ts/array/array_plus.ts +3 -2
- package/ts/array/array_type.ts +30 -12
- package/ts/array/filter.ts +27 -22
- package/ts/array/head.ts +18 -1
- package/ts/array/intersect_of_props.ts +7 -3
- package/ts/array/last.ts +16 -2
- package/ts/array/literal_array.ts +5 -0
- package/ts/array/pad_start.ts +6 -10
- package/ts/array/readme.md +181 -16
- 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/readme.md +3 -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 +18 -10
- package/ts/mix_types/readme.md +40 -0
- package/ts/nodejs/isNodeError.ts +13 -13
- package/ts/nominal/brand.ts +1 -1
- package/ts/nominal/flavor.ts +1 -1
- package/ts/testing/readme.md +30 -0
- package/ts/testing/test_type.ts +90 -47
- package/ts/tuple/common_prop_keys.ts +55 -0
- package/ts/tuple/create_tuple.ts +9 -9
- package/ts/tuple/drop.ts +124 -0
- package/ts/tuple/readme.md +116 -1
- package/ts/{array → tuple}/tail.ts +1 -1
- package/ts/tuple/tuple_plus.filter.ts +29 -0
- package/ts/tuple/tuple_plus.pad_start.ts +26 -13
- package/ts/tuple/tuple_plus.ts +2 -1
- package/cjs/array/array.concat.d.ts.map +0 -1
- package/cjs/array/array.concat.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/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/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/ts/tuple/drop.ts
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type { IsEqual } from '../equal/equal.js'
|
|
2
|
+
import type { NonNull, NonUndefined } from '../utils/index.js'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Drops the first entry in the tuple `T`.
|
|
6
|
+
*
|
|
7
|
+
* If the type is an array, the same array will be returned.
|
|
8
|
+
*
|
|
9
|
+
* ⚗️ *transform*
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* type R = DropFirst<[1, 2, 3]> // [2, 3]
|
|
14
|
+
* type R = DropFirst<[string]> // []
|
|
15
|
+
* type R = DropFirst<[]> // []
|
|
16
|
+
* type R = DropFirst<string[]> // string[]
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export type DropFirst<T extends unknown[], Cases extends {
|
|
20
|
+
'array'?: unknown,
|
|
21
|
+
'empty_tuple'?: unknown,
|
|
22
|
+
} = {
|
|
23
|
+
'array': T,
|
|
24
|
+
'empty_tuple': [],
|
|
25
|
+
}> = number extends T['length']
|
|
26
|
+
? Cases['array']
|
|
27
|
+
: T['length'] extends 0
|
|
28
|
+
? Cases['empty_tuple']
|
|
29
|
+
: T['length'] extends 1
|
|
30
|
+
? []
|
|
31
|
+
: T extends [any, ...infer Tail]
|
|
32
|
+
? Tail
|
|
33
|
+
: never
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Drops the last entry in the tuple `T`.
|
|
37
|
+
*
|
|
38
|
+
* If the type is an array, the same array will be returned.
|
|
39
|
+
*
|
|
40
|
+
* ⚗️ *transform*
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* type R = DropLast<[1, 2, 3]> // [2, 3]
|
|
45
|
+
* type R = DropLast<[string]> // []
|
|
46
|
+
* type R = DropLast<[]> // []
|
|
47
|
+
* type R = DropLast<string[]> // string[]
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export type DropLast<T extends unknown[], Cases extends {
|
|
51
|
+
'array'?: unknown,
|
|
52
|
+
'empty_tuple'?: unknown,
|
|
53
|
+
} = {
|
|
54
|
+
'array': T,
|
|
55
|
+
'empty_tuple': [],
|
|
56
|
+
}> = number extends T['length']
|
|
57
|
+
? Cases['array']
|
|
58
|
+
: T['length'] extends 0
|
|
59
|
+
? Cases['empty_tuple']
|
|
60
|
+
: T['length'] extends 1
|
|
61
|
+
? []
|
|
62
|
+
: T extends [...infer Heads, any]
|
|
63
|
+
? Heads
|
|
64
|
+
: never
|
|
65
|
+
|
|
66
|
+
type ExcludeUnionOfEmptyTuple<A> = IsEqual<A, []> extends true ? A : Exclude<A, []>
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* drops entries matching `Criteria` in array or tuple `A`.
|
|
70
|
+
*
|
|
71
|
+
* ⚗️ *transform*
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* type R = DropMatch<Array<string | undefined>, undefined> // string[]
|
|
76
|
+
* type R = DropMatch<Array<string>, string> // never[]
|
|
77
|
+
* type R = DropMatch<Array<1 | 2>, number> // never[]
|
|
78
|
+
* ```
|
|
79
|
+
*/
|
|
80
|
+
export type DropMatch<A extends Readonly<Array<unknown>>, Criteria> = number extends A['length']
|
|
81
|
+
? // array
|
|
82
|
+
A[0] extends Criteria
|
|
83
|
+
? // criteria matches: DropAll<string[], string>
|
|
84
|
+
never[]
|
|
85
|
+
: undefined extends Criteria
|
|
86
|
+
? null extends Criteria
|
|
87
|
+
? Array<NonNullable<A[0]>>
|
|
88
|
+
: Array<NonUndefined<A[0]>>
|
|
89
|
+
: null extends Criteria
|
|
90
|
+
? Array<NonNull<A[0]>>
|
|
91
|
+
: Criteria extends A[0]
|
|
92
|
+
? Array<Exclude<A[0], Criteria>>
|
|
93
|
+
: A[0] extends Criteria
|
|
94
|
+
? A
|
|
95
|
+
: Array<Exclude<A[0], Criteria>>
|
|
96
|
+
: DropMatchTuple<A, Criteria>
|
|
97
|
+
|
|
98
|
+
type DropMatchTuple<A extends Readonly<Array<any>>, Criteria> = A['length'] extends 0
|
|
99
|
+
? // empty tuple
|
|
100
|
+
A
|
|
101
|
+
: A extends readonly [infer Head, ...infer Tail]
|
|
102
|
+
? Tail['length'] extends 0
|
|
103
|
+
? // single element tuple
|
|
104
|
+
undefined extends Criteria
|
|
105
|
+
? ExcludeUnionOfEmptyTuple<Head extends Criteria ? [] : [Head]>
|
|
106
|
+
: ExcludeUnionOfEmptyTuple<Head extends Criteria ? [] : [Head]>
|
|
107
|
+
: // multiple elements
|
|
108
|
+
Exclude<Head, Criteria> extends never
|
|
109
|
+
? DropMatch<Tail, Criteria>
|
|
110
|
+
: [Exclude<Head, Criteria>, ...DropMatch<Tail, Criteria>]
|
|
111
|
+
: never[]
|
|
112
|
+
|
|
113
|
+
export type DropNull<A extends Array<any>> = DropMatch<A, null>
|
|
114
|
+
export type DropNullable<A extends Array<any>> = DropMatch<A, null | undefined>
|
|
115
|
+
export type DropUndefined<A extends Array<any>> = DropMatch<A, undefined>
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* drop a particular value from an array.
|
|
119
|
+
*
|
|
120
|
+
* 💀 *deprecated* the type does not sufficiently cover the use cases.
|
|
121
|
+
*/
|
|
122
|
+
export function drop<A extends Readonly<unknown[]>, const C> (array: A, value: C): DropMatch < A, C > {
|
|
123
|
+
return array.filter(v => v !== value) as DropMatch<A, C>
|
|
124
|
+
}
|
package/ts/tuple/readme.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
# Tuple
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
In TypeScript, the type of an JavaScript array can be an [array](../array/readme.md) or a [tuple](#tuple).
|
|
4
|
+
|
|
5
|
+
A *tuple type* is an array with fixed number of entries.
|
|
6
|
+
Each entry in the *tuple* is specified explicitly.
|
|
4
7
|
|
|
5
8
|
## Type Checking
|
|
6
9
|
|
|
@@ -21,6 +24,118 @@ type R = TupleType<number> // never
|
|
|
21
24
|
- [`NotTupleType<T, Then = T, Else = never>`](tuple_type.ts#L50): check if `T` is not *tuple*.
|
|
22
25
|
- [`IsNotTuple<T, Then = true, Else = false>`](tuple_type.ts#L65): is `T` not *tuple*.
|
|
23
26
|
|
|
27
|
+
## [CommonPropKeys](./common_prop_keys.ts)
|
|
28
|
+
|
|
29
|
+
`CommonPropKeys<T extends Record[], Cases = { array, no_common_keys }>`
|
|
30
|
+
|
|
31
|
+
⚗️ *transform*
|
|
32
|
+
|
|
33
|
+
Gets the common property keys of the elements in tuple `T`.
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
import { CommonPropKeys } from 'type-plus'
|
|
37
|
+
|
|
38
|
+
type R = CommonPropKeys<[{ a: number }, { b: number }]> // never
|
|
39
|
+
type R = CommonPropKeys<[{ a: number, c: 1 }, { b: number, c: 2 }]> // 'c'
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Overridable cases:
|
|
43
|
+
|
|
44
|
+
- `array`: if `T` is array, it returns the key of the record type in the array.
|
|
45
|
+
- `no_common_keys`: if there are no common keys, it returns `never`.
|
|
46
|
+
|
|
47
|
+
## [DropFirst](./drop.ts)
|
|
48
|
+
|
|
49
|
+
`DropFirst<T extends unknown[], Cases = { array, empty_tuple }>`
|
|
50
|
+
|
|
51
|
+
Drops the first entry in the tuple `T`.
|
|
52
|
+
|
|
53
|
+
⚗️ *transform*
|
|
54
|
+
|
|
55
|
+
```ts
|
|
56
|
+
import { DropFirst } from 'type-plus'
|
|
57
|
+
|
|
58
|
+
type R = DropFirst<[1, 2, 3]> // [2, 3]
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Overridable cases:
|
|
62
|
+
|
|
63
|
+
- `array`: if `T` is array, it returns `T`.
|
|
64
|
+
- `empty_tuple`: if `T` is `[]`, it returns `[]`.
|
|
65
|
+
|
|
66
|
+
## [DropLast](./drop.ts)
|
|
67
|
+
|
|
68
|
+
`DropLast<T extends unknown[], Cases = { array, empty_tuple }>`
|
|
69
|
+
|
|
70
|
+
Drops the last entry in the tuple `T`.
|
|
71
|
+
|
|
72
|
+
⚗️ *transform*
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import { DropLast } from 'type-plus'
|
|
76
|
+
|
|
77
|
+
type R = DropLast<[1, 2, 3]> // [1, 2]
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Overridable cases:
|
|
81
|
+
|
|
82
|
+
- `array`: if `T` is array, it returns `T`.
|
|
83
|
+
- `empty_tuple`: if `T` is `[]`, it returns `[]`.
|
|
84
|
+
|
|
85
|
+
## [DropMatch](./drop.ts)
|
|
86
|
+
|
|
87
|
+
`DropMatch<A extends Readonly<Array<unknown>>, Criteria>`
|
|
88
|
+
|
|
89
|
+
Drops entries matching `Criteria` in array or tuple `A`.
|
|
90
|
+
|
|
91
|
+
⚗️ *transform*
|
|
92
|
+
|
|
93
|
+
```ts
|
|
94
|
+
type R = DropMatch<Array<string | undefined>, undefined> // string[]
|
|
95
|
+
type R = DropMatch<Array<string>, string> // never[]
|
|
96
|
+
type R = DropMatch<Array<1 | 2>, number> // never[]
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## [TuplePlus](./tuple_plus.ts)
|
|
100
|
+
|
|
101
|
+
`TuplePlus` contains type utilities specific for *tuple*.
|
|
102
|
+
The input type are not checked and assumed to be *tuple*.
|
|
103
|
+
|
|
104
|
+
### [TuplePlus.Filter](./tuple_plus.filter.ts)
|
|
105
|
+
|
|
106
|
+
`TuplePlus.Filter<T, Criteria>`
|
|
107
|
+
|
|
108
|
+
Filter entries matching `Criteria` in tuple `T`.
|
|
109
|
+
|
|
110
|
+
⚗️ *transform*
|
|
111
|
+
|
|
112
|
+
```ts
|
|
113
|
+
import { TuplePlus } from 'type-plus'
|
|
114
|
+
|
|
115
|
+
type R = TuplePlus.Filter<[1, 2, '3'], number> // [1, 2]
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### [TuplePlus.PadStart](./tuple_plus.pad_start.ts)
|
|
119
|
+
|
|
120
|
+
`TuplePlus.PadStart<T, MaxLength, PadWith>`
|
|
121
|
+
|
|
122
|
+
Pad `T` with `PadWith` at the start of the tuple.
|
|
123
|
+
|
|
124
|
+
If the `MaxLength` is less than the length of the tuple,
|
|
125
|
+
the `Tuple` will be returned unchanged.
|
|
126
|
+
|
|
127
|
+
⚗️ *transform*
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
PadStart<[1, 2, 3], 5, 0> // [0, 0, 1, 2, 3]
|
|
131
|
+
|
|
132
|
+
// Ignore if MaxLength is less than the length of the tuple
|
|
133
|
+
PadStart<[1, 2, 3], 2> // [1, 2, 3]
|
|
134
|
+
|
|
135
|
+
// Default to unknown
|
|
136
|
+
PadStart<[1, 2, 3], 5> // [unknown, unknown, 1, 2, 3]
|
|
137
|
+
```
|
|
138
|
+
|
|
24
139
|
## References
|
|
25
140
|
|
|
26
141
|
- [Handbook]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Filter entries matching `Criteria` in tuple `T`.
|
|
3
|
+
*
|
|
4
|
+
* ⚗️ *transform*
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* type R = Filter<[1, 2, '3'], number> // [1, 2]
|
|
9
|
+
* type R = Filter<[1, 2, '3'], true> // []
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export type Filter<T extends unknown[], Criteria> = T['length'] extends 0
|
|
13
|
+
? []
|
|
14
|
+
: (
|
|
15
|
+
T extends [infer Head, ...infer Tail]
|
|
16
|
+
? (
|
|
17
|
+
Tail['length'] extends 0
|
|
18
|
+
? (
|
|
19
|
+
Head extends Criteria
|
|
20
|
+
? [Head]
|
|
21
|
+
: [])
|
|
22
|
+
: (
|
|
23
|
+
Head extends Criteria
|
|
24
|
+
? [Head, ...Filter<Tail, Criteria>]
|
|
25
|
+
: Filter<Tail, Criteria>
|
|
26
|
+
)
|
|
27
|
+
)
|
|
28
|
+
: never
|
|
29
|
+
)
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Pad `T` with `PadWith` at the start of the tuple.
|
|
3
3
|
*
|
|
4
4
|
* If the `MaxLength` is less than the length of the tuple,
|
|
5
5
|
* the `Tuple` will be returned unchanged.
|
|
6
6
|
*
|
|
7
|
+
* ⚗️ *transform*
|
|
8
|
+
*
|
|
7
9
|
* @example
|
|
8
10
|
* ```ts
|
|
9
11
|
* PadStart<[1, 2, 3], 5, 0> // [0, 0, 1, 2, 3]
|
|
10
12
|
*
|
|
11
13
|
* // Ignore if MaxLength is less than the length of the tuple
|
|
12
|
-
* PadStart<[1, 2, 3],
|
|
14
|
+
* PadStart<[1, 2, 3], 2> // [1, 2, 3]
|
|
13
15
|
*
|
|
14
16
|
* // Default to unknown
|
|
15
17
|
* PadStart<[1, 2, 3], 5> // [unknown, unknown, 1, 2, 3]
|
|
@@ -27,16 +29,27 @@ type PadStartDevice<
|
|
|
27
29
|
MaxLength extends number,
|
|
28
30
|
PadWith,
|
|
29
31
|
Result extends unknown[]
|
|
30
|
-
> =
|
|
31
|
-
|
|
32
|
+
> =
|
|
33
|
+
Result['length'] extends MaxLength
|
|
34
|
+
? (
|
|
35
|
+
Source extends []
|
|
32
36
|
? Result
|
|
33
|
-
:
|
|
34
|
-
|
|
35
|
-
?
|
|
37
|
+
: (
|
|
38
|
+
Source extends [...infer Head, infer Tail]
|
|
39
|
+
? (
|
|
40
|
+
[Tail, ...Result] extends infer R extends unknown[]
|
|
41
|
+
? PadStartDevice<Head, R['length'], PadWith, R>
|
|
42
|
+
: never
|
|
43
|
+
)
|
|
36
44
|
: never
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
: (
|
|
48
|
+
Source extends []
|
|
49
|
+
? PadStartDevice<Source, MaxLength, PadWith, [PadWith, ...Result]>
|
|
50
|
+
: (
|
|
51
|
+
Source extends [...infer Head, infer Tail]
|
|
52
|
+
? PadStartDevice<Head, MaxLength, PadWith, [Tail, ...Result]>
|
|
53
|
+
: Source
|
|
54
|
+
)
|
|
55
|
+
)
|
package/ts/tuple/tuple_plus.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type { Filter } from './tuple_plus.filter.js'
|
|
2
|
+
export type { PadStart } from './tuple_plus.pad_start.js'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array.concat.d.ts","sourceRoot":"","sources":["../../ts/array/array.concat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,SAAS,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array.concat.js","sourceRoot":"","sources":["../../ts/array/array.concat.ts"],"names":[],"mappings":""}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Tail } from './tail.js';
|
|
2
|
-
/**
|
|
3
|
-
* Gets the common property keys of the elements in `A`.
|
|
4
|
-
*/
|
|
5
|
-
export type CommonPropKeys<A extends Record<string, unknown>[]> = A['length'] extends 0 ? never : A['length'] extends 1 ? keyof A[0] : A['length'] extends 2 ? keyof A[0] & keyof A[1] : keyof A[0] & keyof A[1] & CommonPropKeys<Tail<Tail<A>>>;
|
|
6
|
-
/**
|
|
7
|
-
* Gets the common property keys of the elements in `A`.
|
|
8
|
-
* @deprecated Please use CommonPropKeys instead.
|
|
9
|
-
*/
|
|
10
|
-
export type CommonKeys<A extends Record<string, any>[]> = CommonPropKeys<A>;
|
|
11
|
-
//# sourceMappingURL=common_prop_keys.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common_prop_keys.d.ts","sourceRoot":"","sources":["../../ts/array/common_prop_keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAErC;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACpF,KAAK,GACL,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACrB,MAAM,CAAC,CAAC,CAAC,CAAC,GACV,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACrB,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,GACvB,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAE1D;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,IAAI,cAAc,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common_prop_keys.js","sourceRoot":"","sources":["../../ts/array/common_prop_keys.ts"],"names":[],"mappings":""}
|
package/cjs/array/drop.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { IsEqual } from '../equal/equal.js';
|
|
2
|
-
import type { NonNull, NonUndefined } from '../utils/index.js';
|
|
3
|
-
export type DropFirst<A extends any[]> = number extends A['length'] ? A : A['length'] extends 0 ? never[] : A['length'] extends 1 ? never[] : A extends [any, ...infer Tail] ? Tail : never;
|
|
4
|
-
export type DropLast<A extends any[]> = number extends A['length'] ? A : A['length'] extends 0 ? never[] : A['length'] extends 1 ? never[] : A extends [...infer Heads, any] ? Heads : never;
|
|
5
|
-
type ExcludeUnionOfEmptyTuple<A> = IsEqual<A, []> extends true ? A : Exclude<A, []>;
|
|
6
|
-
/**
|
|
7
|
-
* drops entries matching `Criteria` in array or tuple `A`.
|
|
8
|
-
*/
|
|
9
|
-
export type DropMatch<A extends Readonly<Array<any>>, Criteria> = number extends A['length'] ? 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>> : DropMatchTuple<A, Criteria>;
|
|
10
|
-
type DropMatchTuple<A extends Readonly<Array<any>>, Criteria> = A['length'] extends 0 ? A : A extends readonly [infer Head, ...infer Tail] ? Tail['length'] extends 0 ? undefined extends Criteria ? ExcludeUnionOfEmptyTuple<Head extends Criteria ? [] : [Head]> : ExcludeUnionOfEmptyTuple<Head extends Criteria ? [] : [Head]> : Exclude<Head, Criteria> extends never ? DropMatch<Tail, Criteria> : [Exclude<Head, Criteria>, ...DropMatch<Tail, Criteria>] : never[];
|
|
11
|
-
export type DropNull<A extends Array<any>> = DropMatch<A, null>;
|
|
12
|
-
export type DropNullable<A extends Array<any>> = DropMatch<A, null | undefined>;
|
|
13
|
-
export type DropUndefined<A extends Array<any>> = DropMatch<A, undefined>;
|
|
14
|
-
/**
|
|
15
|
-
* drop a particular value from an array
|
|
16
|
-
*/
|
|
17
|
-
export declare function drop<A extends Readonly<Array<any>>, C>(array: A, value: C): DropMatch<A, C>;
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=drop.d.ts.map
|
package/cjs/array/drop.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"drop.d.ts","sourceRoot":"","sources":["../../ts/array/drop.ts"],"names":[],"mappings":"AAAA,OAAO,KAA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AAC,CAAC,EAAE,IAAI,CAAC,CAAA;AAC/D,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC,CAAA;AAC/E,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,KAAK,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,CAAA;AAEzE;;GAEG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAE3F"}
|
package/cjs/array/drop.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"drop.js","sourceRoot":"","sources":["../../ts/array/drop.ts"],"names":[],"mappings":";;;AAiEA;;GAEG;AACH,SAAgB,IAAI,CAAoC,KAAQ,EAAE,KAAQ;IACzE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,CAAoB,CAAA;AACzD,CAAC;AAFD,oBAEC"}
|
package/cjs/array/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export * from './common_prop_keys.js';
|
|
2
|
-
export * from './drop.js';
|
|
3
|
-
export * from './filter.js';
|
|
4
|
-
export * from './array.find.js';
|
|
5
|
-
export * from './array.find_last.js';
|
|
6
|
-
export * from './head.js';
|
|
7
|
-
export * from './intersect_of_props.js';
|
|
8
|
-
export * from './last.js';
|
|
9
|
-
export * from './literal_array.js';
|
|
10
|
-
export * from './pad_start.js';
|
|
11
|
-
export * from './reduce_while.js';
|
|
12
|
-
export * from './reverse.js';
|
|
13
|
-
export * from './array.some.js';
|
|
14
|
-
export * from './tail.js';
|
|
15
|
-
export * from './union_of_props.js';
|
|
16
|
-
export * from './union_of_values.js';
|
|
17
|
-
//# sourceMappingURL=index.d.ts.map
|
package/cjs/array/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../ts/array/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,sBAAsB,CAAA;AACpC,cAAc,WAAW,CAAA;AACzB,cAAc,yBAAyB,CAAA;AACvC,cAAc,WAAW,CAAA;AACzB,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA"}
|
package/cjs/array/index.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./common_prop_keys.js"), exports);
|
|
18
|
-
__exportStar(require("./drop.js"), exports);
|
|
19
|
-
__exportStar(require("./filter.js"), exports);
|
|
20
|
-
__exportStar(require("./array.find.js"), exports);
|
|
21
|
-
__exportStar(require("./array.find_last.js"), exports);
|
|
22
|
-
__exportStar(require("./head.js"), exports);
|
|
23
|
-
__exportStar(require("./intersect_of_props.js"), exports);
|
|
24
|
-
__exportStar(require("./last.js"), exports);
|
|
25
|
-
__exportStar(require("./literal_array.js"), exports);
|
|
26
|
-
__exportStar(require("./pad_start.js"), exports);
|
|
27
|
-
__exportStar(require("./reduce_while.js"), exports);
|
|
28
|
-
__exportStar(require("./reverse.js"), exports);
|
|
29
|
-
__exportStar(require("./array.some.js"), exports);
|
|
30
|
-
__exportStar(require("./tail.js"), exports);
|
|
31
|
-
__exportStar(require("./union_of_props.js"), exports);
|
|
32
|
-
__exportStar(require("./union_of_values.js"), exports);
|
|
33
|
-
//# sourceMappingURL=index.js.map
|
package/cjs/array/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/array/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,wDAAqC;AACrC,4CAAyB;AACzB,8CAA2B;AAC3B,kDAA+B;AAC/B,uDAAoC;AACpC,4CAAyB;AACzB,0DAAuC;AACvC,4CAAyB;AACzB,qDAAkC;AAClC,iDAA8B;AAC9B,oDAAiC;AACjC,+CAA4B;AAC5B,kDAA+B;AAC/B,4CAAyB;AACzB,sDAAmC;AACnC,uDAAoC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array.concat.d.ts","sourceRoot":"","sources":["../../ts/array/array.concat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,OAAO,EAAE,EAAE,CAAC,SAAS,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array.concat.js","sourceRoot":"","sources":["../../ts/array/array.concat.ts"],"names":[],"mappings":""}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Tail } from './tail.js';
|
|
2
|
-
/**
|
|
3
|
-
* Gets the common property keys of the elements in `A`.
|
|
4
|
-
*/
|
|
5
|
-
export type CommonPropKeys<A extends Record<string, unknown>[]> = A['length'] extends 0 ? never : A['length'] extends 1 ? keyof A[0] : A['length'] extends 2 ? keyof A[0] & keyof A[1] : keyof A[0] & keyof A[1] & CommonPropKeys<Tail<Tail<A>>>;
|
|
6
|
-
/**
|
|
7
|
-
* Gets the common property keys of the elements in `A`.
|
|
8
|
-
* @deprecated Please use CommonPropKeys instead.
|
|
9
|
-
*/
|
|
10
|
-
export type CommonKeys<A extends Record<string, any>[]> = CommonPropKeys<A>;
|
|
11
|
-
//# sourceMappingURL=common_prop_keys.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common_prop_keys.d.ts","sourceRoot":"","sources":["../../ts/array/common_prop_keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAErC;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACpF,KAAK,GACL,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACrB,MAAM,CAAC,CAAC,CAAC,CAAC,GACV,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACrB,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,GACvB,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAE1D;;;GAGG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,IAAI,cAAc,CAAC,CAAC,CAAC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common_prop_keys.js","sourceRoot":"","sources":["../../ts/array/common_prop_keys.ts"],"names":[],"mappings":""}
|
package/esm/array/drop.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { IsEqual } from '../equal/equal.js';
|
|
2
|
-
import type { NonNull, NonUndefined } from '../utils/index.js';
|
|
3
|
-
export type DropFirst<A extends any[]> = number extends A['length'] ? A : A['length'] extends 0 ? never[] : A['length'] extends 1 ? never[] : A extends [any, ...infer Tail] ? Tail : never;
|
|
4
|
-
export type DropLast<A extends any[]> = number extends A['length'] ? A : A['length'] extends 0 ? never[] : A['length'] extends 1 ? never[] : A extends [...infer Heads, any] ? Heads : never;
|
|
5
|
-
type ExcludeUnionOfEmptyTuple<A> = IsEqual<A, []> extends true ? A : Exclude<A, []>;
|
|
6
|
-
/**
|
|
7
|
-
* drops entries matching `Criteria` in array or tuple `A`.
|
|
8
|
-
*/
|
|
9
|
-
export type DropMatch<A extends Readonly<Array<any>>, Criteria> = number extends A['length'] ? 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>> : DropMatchTuple<A, Criteria>;
|
|
10
|
-
type DropMatchTuple<A extends Readonly<Array<any>>, Criteria> = A['length'] extends 0 ? A : A extends readonly [infer Head, ...infer Tail] ? Tail['length'] extends 0 ? undefined extends Criteria ? ExcludeUnionOfEmptyTuple<Head extends Criteria ? [] : [Head]> : ExcludeUnionOfEmptyTuple<Head extends Criteria ? [] : [Head]> : Exclude<Head, Criteria> extends never ? DropMatch<Tail, Criteria> : [Exclude<Head, Criteria>, ...DropMatch<Tail, Criteria>] : never[];
|
|
11
|
-
export type DropNull<A extends Array<any>> = DropMatch<A, null>;
|
|
12
|
-
export type DropNullable<A extends Array<any>> = DropMatch<A, null | undefined>;
|
|
13
|
-
export type DropUndefined<A extends Array<any>> = DropMatch<A, undefined>;
|
|
14
|
-
/**
|
|
15
|
-
* drop a particular value from an array
|
|
16
|
-
*/
|
|
17
|
-
export declare function drop<A extends Readonly<Array<any>>, C>(array: A, value: C): DropMatch<A, C>;
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=drop.d.ts.map
|
package/esm/array/drop.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"drop.d.ts","sourceRoot":"","sources":["../../ts/array/drop.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAE9D,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,GAAG,EAAE,IAAI,MAAM,SAAS,CAAC,CAAC,QAAQ,CAAC,GAChE,CAAC,GACD,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACrB,KAAK,EAAE,GACP,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACrB,KAAK,EAAE,GACP,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,MAAM,IAAI,CAAC,GAC9B,IAAI,GACJ,KAAK,CAAA;AAER,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,GAAG,EAAE,IAAI,MAAM,SAAS,CAAC,CAAC,QAAQ,CAAC,GAC/D,CAAC,GACD,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,GACrB,KAAK,EA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../../ts/array/drop.ts"],"names":[],"mappings":"AAiEA;;GAEG;AACH,MAAM,UAAU,IAAI,CAAoC,KAAQ,EAAE,KAAQ;IACzE,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,KAAK,CAAoB,CAAA;AACzD,CAAC"}
|
package/esm/array/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export * from './common_prop_keys.js';
|
|
2
|
-
export * from './drop.js';
|
|
3
|
-
export * from './filter.js';
|
|
4
|
-
export * from './array.find.js';
|
|
5
|
-
export * from './array.find_last.js';
|
|
6
|
-
export * from './head.js';
|
|
7
|
-
export * from './intersect_of_props.js';
|
|
8
|
-
export * from './last.js';
|
|
9
|
-
export * from './literal_array.js';
|
|
10
|
-
export * from './pad_start.js';
|
|
11
|
-
export * from './reduce_while.js';
|
|
12
|
-
export * from './reverse.js';
|
|
13
|
-
export * from './array.some.js';
|
|
14
|
-
export * from './tail.js';
|
|
15
|
-
export * from './union_of_props.js';
|
|
16
|
-
export * from './union_of_values.js';
|
|
17
|
-
//# sourceMappingURL=index.d.ts.map
|
package/esm/array/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../ts/array/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,sBAAsB,CAAA;AACpC,cAAc,WAAW,CAAA;AACzB,cAAc,yBAAyB,CAAA;AACvC,cAAc,WAAW,CAAA;AACzB,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA"}
|
package/esm/array/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export * from './common_prop_keys.js';
|
|
2
|
-
export * from './drop.js';
|
|
3
|
-
export * from './filter.js';
|
|
4
|
-
export * from './array.find.js';
|
|
5
|
-
export * from './array.find_last.js';
|
|
6
|
-
export * from './head.js';
|
|
7
|
-
export * from './intersect_of_props.js';
|
|
8
|
-
export * from './last.js';
|
|
9
|
-
export * from './literal_array.js';
|
|
10
|
-
export * from './pad_start.js';
|
|
11
|
-
export * from './reduce_while.js';
|
|
12
|
-
export * from './reverse.js';
|
|
13
|
-
export * from './array.some.js';
|
|
14
|
-
export * from './tail.js';
|
|
15
|
-
export * from './union_of_props.js';
|
|
16
|
-
export * from './union_of_values.js';
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
package/esm/array/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../ts/array/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAA;AACrC,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,sBAAsB,CAAA;AACpC,cAAc,WAAW,CAAA;AACzB,cAAc,yBAAyB,CAAA;AACvC,cAAc,WAAW,CAAA;AACzB,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,WAAW,CAAA;AACzB,cAAc,qBAAqB,CAAA;AACnC,cAAc,sBAAsB,CAAA"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Tail } from './tail.js'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Gets the common property keys of the elements in `A`.
|
|
5
|
-
*/
|
|
6
|
-
export type CommonPropKeys<A extends Record<string, unknown>[]> = A['length'] extends 0
|
|
7
|
-
? never
|
|
8
|
-
: A['length'] extends 1
|
|
9
|
-
? keyof A[0]
|
|
10
|
-
: A['length'] extends 2
|
|
11
|
-
? keyof A[0] & keyof A[1]
|
|
12
|
-
: keyof A[0] & keyof A[1] & CommonPropKeys<Tail<Tail<A>>>
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Gets the common property keys of the elements in `A`.
|
|
16
|
-
* @deprecated Please use CommonPropKeys instead.
|
|
17
|
-
*/
|
|
18
|
-
export type CommonKeys<A extends Record<string, any>[]> = CommonPropKeys<A>
|