@stryke/helpers 0.10.6 → 0.10.7
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/CHANGELOG.md +12 -0
- package/dist/arg-identity.d.cts.map +1 -1
- package/dist/arg-identity.d.mts.map +1 -1
- package/dist/arg-identity.mjs.map +1 -1
- package/dist/convert/src/index.cjs +4 -0
- package/dist/convert/src/index.mjs +6 -0
- package/dist/convert/src/parse-type-definition.cjs +1 -0
- package/dist/convert/src/parse-type-definition.mjs +3 -0
- package/dist/convert/src/string-to-utf8-array.cjs +5 -0
- package/dist/convert/src/string-to-utf8-array.mjs +6 -0
- package/dist/convert/src/string-to-utf8-array.mjs.map +1 -0
- package/dist/convert/src/utf8-array-to-string.cjs +5 -0
- package/dist/convert/src/utf8-array-to-string.mjs +6 -0
- package/dist/convert/src/utf8-array-to-string.mjs.map +1 -0
- package/dist/debounce.cjs +5 -4
- package/dist/debounce.d.cts +4 -6
- package/dist/debounce.d.cts.map +1 -1
- package/dist/debounce.d.mts +4 -6
- package/dist/debounce.d.mts.map +1 -1
- package/dist/debounce.mjs +5 -4
- package/dist/debounce.mjs.map +1 -1
- package/dist/deep-clone.cjs +2 -1
- package/dist/deep-clone.d.cts.map +1 -1
- package/dist/deep-clone.d.mts.map +1 -1
- package/dist/deep-clone.mjs +2 -1
- package/dist/deep-clone.mjs.map +1 -1
- package/dist/delay.cjs +2 -1
- package/dist/delay.d.cts +1 -3
- package/dist/delay.d.cts.map +1 -1
- package/dist/delay.d.mts +1 -3
- package/dist/delay.d.mts.map +1 -1
- package/dist/delay.mjs +2 -1
- package/dist/delay.mjs.map +1 -1
- package/dist/filter-empty.d.cts.map +1 -1
- package/dist/filter-empty.d.mts.map +1 -1
- package/dist/filter-empty.mjs.map +1 -1
- package/dist/flatten-object.cjs +2 -1
- package/dist/flatten-object.d.cts.map +1 -1
- package/dist/flatten-object.d.mts.map +1 -1
- package/dist/flatten-object.mjs +2 -1
- package/dist/flatten-object.mjs.map +1 -1
- package/dist/get-field.cjs +14 -7
- package/dist/get-field.d.cts +123 -125
- package/dist/get-field.d.cts.map +1 -1
- package/dist/get-field.d.mts +123 -125
- package/dist/get-field.d.mts.map +1 -1
- package/dist/get-field.mjs +14 -7
- package/dist/get-field.mjs.map +1 -1
- package/dist/get-ordered-by.d.cts.map +1 -1
- package/dist/get-ordered-by.d.mts.map +1 -1
- package/dist/get-ordered-by.mjs.map +1 -1
- package/dist/identity.d.cts.map +1 -1
- package/dist/identity.d.mts.map +1 -1
- package/dist/identity.mjs.map +1 -1
- package/dist/is-equal.d.cts.map +1 -1
- package/dist/is-equal.d.mts.map +1 -1
- package/dist/is-equal.mjs.map +1 -1
- package/dist/match-sorter.cjs +2 -2
- package/dist/match-sorter.mjs +2 -2
- package/dist/match-sorter.mjs.map +1 -1
- package/dist/noop.d.cts.map +1 -1
- package/dist/noop.d.mts.map +1 -1
- package/dist/noop.mjs.map +1 -1
- package/dist/omit.mjs.map +1 -1
- package/dist/pick.mjs.map +1 -1
- package/dist/remove-accents.cjs +1 -3
- package/dist/remove-accents.d.cts.map +1 -1
- package/dist/remove-accents.d.mts.map +1 -1
- package/dist/remove-accents.mjs +1 -3
- package/dist/remove-accents.mjs.map +1 -1
- package/dist/remove-empty-items.d.cts.map +1 -1
- package/dist/remove-empty-items.d.mts.map +1 -1
- package/dist/remove-empty-items.mjs.map +1 -1
- package/dist/semaphore.cjs +10 -10
- package/dist/semaphore.d.cts +10 -10
- package/dist/semaphore.d.cts.map +1 -1
- package/dist/semaphore.d.mts +10 -10
- package/dist/semaphore.d.mts.map +1 -1
- package/dist/semaphore.mjs +10 -10
- package/dist/semaphore.mjs.map +1 -1
- package/dist/set-field.cjs +1 -1
- package/dist/set-field.d.cts.map +1 -1
- package/dist/set-field.d.mts.map +1 -1
- package/dist/set-field.mjs +1 -1
- package/dist/set-field.mjs.map +1 -1
- package/dist/throttle.d.cts.map +1 -1
- package/dist/throttle.d.mts.map +1 -1
- package/dist/throttle.mjs.map +1 -1
- package/dist/timeout.d.cts.map +1 -1
- package/dist/timeout.d.mts.map +1 -1
- package/dist/timeout.mjs.map +1 -1
- package/dist/to-deep-key.d.cts.map +1 -1
- package/dist/to-deep-key.d.mts.map +1 -1
- package/dist/to-deep-key.mjs.map +1 -1
- package/dist/type-checks/src/index.cjs +21 -0
- package/dist/type-checks/src/index.mjs +23 -0
- package/dist/type-checks/src/is-buffer.cjs +13 -0
- package/dist/type-checks/src/is-buffer.mjs +14 -0
- package/dist/type-checks/src/is-buffer.mjs.map +1 -0
- package/dist/type-checks/src/is-collection.cjs +1 -0
- package/dist/type-checks/src/is-collection.mjs +3 -0
- package/dist/type-checks/src/is-deep-key.cjs +6 -0
- package/dist/type-checks/src/is-deep-key.mjs +6 -0
- package/dist/type-checks/src/is-deep-key.mjs.map +1 -1
- package/dist/type-checks/src/is-function.cjs +3 -1
- package/dist/type-checks/src/is-function.mjs +1 -1
- package/dist/type-checks/src/is-object-index.cjs +6 -0
- package/dist/type-checks/src/is-object-index.mjs +6 -0
- package/dist/type-checks/src/is-object-index.mjs.map +1 -1
- package/dist/type-checks/src/is-plain-object.cjs +3 -2
- package/dist/type-checks/src/is-plain-object.mjs +3 -3
- package/dist/type-checks/src/is-plain-object.mjs.map +1 -1
- package/dist/type-checks/src/is-set-string.cjs +1 -1
- package/dist/type-checks/src/is-set-string.mjs +1 -1
- package/dist/type-checks/src/property-exists.cjs +1 -0
- package/dist/type-checks/src/property-exists.mjs +1 -1
- package/dist/type-checks/src/type-detect.cjs +15 -0
- package/dist/type-checks/src/type-detect.mjs +17 -0
- package/dist/type-checks/src/type-detect.mjs.map +1 -0
- package/dist/types/src/object.d.cts +1 -1
- package/dist/types/src/object.d.mts +1 -1
- package/dist/unflatten-object.cjs +1 -1
- package/dist/unflatten-object.d.cts +1 -1
- package/dist/unflatten-object.d.cts.map +1 -1
- package/dist/unflatten-object.d.mts +1 -1
- package/dist/unflatten-object.d.mts.map +1 -1
- package/dist/unflatten-object.mjs +1 -1
- package/dist/unflatten-object.mjs.map +1 -1
- package/dist/union.d.cts.map +1 -1
- package/dist/union.d.mts.map +1 -1
- package/dist/union.mjs.map +1 -1
- package/dist/with-timeout.d.cts.map +1 -1
- package/dist/with-timeout.d.mts.map +1 -1
- package/dist/with-timeout.mjs.map +1 -1
- package/package.json +2 -2
package/dist/get-field.d.cts
CHANGED
|
@@ -9,244 +9,242 @@ type GetField<T, P> = P extends `${infer Left}.${infer Right}` ? Left extends ke
|
|
|
9
9
|
/**
|
|
10
10
|
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
11
11
|
*
|
|
12
|
-
* @
|
|
13
|
-
* @
|
|
14
|
-
* @template D - The type of the default value.
|
|
12
|
+
* @typeParam T - The type of the object.
|
|
13
|
+
* @typeParam K - The type of the key in the object.
|
|
15
14
|
*
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
18
|
-
* @returns
|
|
15
|
+
* @param object - The object to query.
|
|
16
|
+
* @param path - The path of the property to get.
|
|
17
|
+
* @returns The resolved value.
|
|
19
18
|
*/
|
|
20
19
|
declare function getField<T extends object, K extends keyof T>(object: T, path: K | readonly [K]): T[K];
|
|
21
20
|
/**
|
|
22
21
|
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
23
22
|
*
|
|
24
|
-
* @
|
|
25
|
-
* @
|
|
23
|
+
* @typeParam T - The type of the object.
|
|
24
|
+
* @typeParam K - The type of the key in the object.
|
|
26
25
|
*
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
29
|
-
* @returns
|
|
26
|
+
* @param object - The object to query.
|
|
27
|
+
* @param path - The path of the property to get.
|
|
28
|
+
* @returns The resolved value or undefined.
|
|
30
29
|
*/
|
|
31
30
|
declare function getField<T extends object, K extends keyof T>(object: T | null | undefined, path: K | readonly [K]): T[K] | undefined;
|
|
32
31
|
/**
|
|
33
32
|
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
34
33
|
*
|
|
35
|
-
* @
|
|
36
|
-
* @
|
|
37
|
-
* @
|
|
34
|
+
* @typeParam T - The type of the object.
|
|
35
|
+
* @typeParam K - The type of the key in the object.
|
|
36
|
+
* @typeParam D - The type of the default value.
|
|
38
37
|
*
|
|
39
|
-
* @param
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
42
|
-
* @returns
|
|
38
|
+
* @param object - The object to query.
|
|
39
|
+
* @param path - The path of the property to get.
|
|
40
|
+
* @param defaultValue - The value returned if the resolved value is undefined.
|
|
41
|
+
* @returns The resolved value or default value.
|
|
43
42
|
*/
|
|
44
43
|
declare function getField<T extends object, K extends keyof T, D>(object: T | null | undefined, path: K | readonly [K], defaultValue: D): Exclude<T[K], undefined> | D;
|
|
45
44
|
/**
|
|
46
45
|
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
47
46
|
*
|
|
48
|
-
* @
|
|
49
|
-
* @
|
|
50
|
-
* @
|
|
47
|
+
* @typeParam T - The type of the object.
|
|
48
|
+
* @typeParam K1 - The type of the first key in the object.
|
|
49
|
+
* @typeParam K2 - The type of the second key in the object.
|
|
51
50
|
*
|
|
52
|
-
* @param
|
|
53
|
-
* @param
|
|
54
|
-
* @returns
|
|
51
|
+
* @param object - The object to query.
|
|
52
|
+
* @param path - The path of the property to get.
|
|
53
|
+
* @returns The resolved value.
|
|
55
54
|
*/
|
|
56
55
|
declare function getField<T extends object, K1 extends keyof T, K2 extends keyof T[K1]>(object: T, path: readonly [K1, K2]): T[K1][K2];
|
|
57
56
|
/**
|
|
58
57
|
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
59
58
|
*
|
|
60
|
-
* @
|
|
61
|
-
* @
|
|
62
|
-
* @
|
|
59
|
+
* @typeParam T - The type of the object.
|
|
60
|
+
* @typeParam K1 - The type of the first key in the object.
|
|
61
|
+
* @typeParam K2 - The type of the second key in the object.
|
|
63
62
|
*
|
|
64
|
-
* @param
|
|
65
|
-
* @param
|
|
66
|
-
* @returns
|
|
63
|
+
* @param object - The object to query.
|
|
64
|
+
* @param path - The path of the property to get.
|
|
65
|
+
* @returns The resolved value or undefined.
|
|
67
66
|
*/
|
|
68
67
|
declare function getField<T extends object, K1 extends keyof T, K2 extends keyof T[K1]>(object: T | null | undefined, path: readonly [K1, K2]): T[K1][K2] | undefined;
|
|
69
68
|
/**
|
|
70
69
|
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
71
70
|
*
|
|
72
|
-
* @
|
|
73
|
-
* @
|
|
74
|
-
* @
|
|
75
|
-
* @
|
|
71
|
+
* @typeParam T - The type of the object.
|
|
72
|
+
* @typeParam K1 - The type of the first key in the object.
|
|
73
|
+
* @typeParam K2 - The type of the second key in the object.
|
|
74
|
+
* @typeParam D - The type of the default value.
|
|
76
75
|
*
|
|
77
|
-
* @param
|
|
78
|
-
* @param
|
|
79
|
-
* @param
|
|
80
|
-
* @returns
|
|
76
|
+
* @param object - The object to query.
|
|
77
|
+
* @param path - The path of the property to get.
|
|
78
|
+
* @param defaultValue - The value returned if the resolved value is undefined.
|
|
79
|
+
* @returns The resolved value or default value.
|
|
81
80
|
*/
|
|
82
81
|
declare function getField<T extends object, K1 extends keyof T, K2 extends keyof T[K1], D>(object: T | null | undefined, path: readonly [K1, K2], defaultValue: D): Exclude<T[K1][K2], undefined> | D;
|
|
83
82
|
/**
|
|
84
83
|
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
85
84
|
*
|
|
86
|
-
* @
|
|
87
|
-
* @
|
|
88
|
-
* @
|
|
89
|
-
* @
|
|
85
|
+
* @typeParam T - The type of the object.
|
|
86
|
+
* @typeParam K1 - The type of the first key in the object.
|
|
87
|
+
* @typeParam K2 - The type of the second key in the object.
|
|
88
|
+
* @typeParam K3 - The type of the third key in the object.
|
|
90
89
|
*
|
|
91
|
-
* @param
|
|
92
|
-
* @param
|
|
93
|
-
* @returns
|
|
90
|
+
* @param object - The object to query.
|
|
91
|
+
* @param path - The path of the property to get.
|
|
92
|
+
* @returns The resolved value.
|
|
94
93
|
*/
|
|
95
94
|
declare function getField<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(object: T, path: readonly [K1, K2, K3]): T[K1][K2][K3];
|
|
96
95
|
/**
|
|
97
96
|
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
98
97
|
*
|
|
99
|
-
* @
|
|
100
|
-
* @
|
|
101
|
-
* @
|
|
102
|
-
* @
|
|
98
|
+
* @typeParam T - The type of the object.
|
|
99
|
+
* @typeParam K1 - The type of the first key in the object.
|
|
100
|
+
* @typeParam K2 - The type of the second key in the object.
|
|
101
|
+
* @typeParam K3 - The type of the third key in the object.
|
|
103
102
|
*
|
|
104
|
-
* @param
|
|
105
|
-
* @param
|
|
106
|
-
* @returns
|
|
103
|
+
* @param object - The object to query.
|
|
104
|
+
* @param path - The path of the property to get.
|
|
105
|
+
* @returns The resolved value or undefined.
|
|
107
106
|
*/
|
|
108
107
|
declare function getField<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2]>(object: T | null | undefined, path: readonly [K1, K2, K3]): T[K1][K2][K3] | undefined;
|
|
109
108
|
/**
|
|
110
109
|
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
111
110
|
*
|
|
112
|
-
* @
|
|
113
|
-
* @
|
|
114
|
-
* @
|
|
115
|
-
* @
|
|
116
|
-
* @
|
|
111
|
+
* @typeParam T - The type of the object.
|
|
112
|
+
* @typeParam K1 - The type of the first key in the object.
|
|
113
|
+
* @typeParam K2 - The type of the second key in the object.
|
|
114
|
+
* @typeParam K3 - The type of the third key in the object.
|
|
115
|
+
* @typeParam D - The type of the default value.
|
|
117
116
|
*
|
|
118
|
-
* @param
|
|
119
|
-
* @param
|
|
120
|
-
* @param
|
|
121
|
-
* @returns
|
|
117
|
+
* @param object - The object to query.
|
|
118
|
+
* @param path - The path of the property to get.
|
|
119
|
+
* @param defaultValue - The value returned if the resolved value is undefined.
|
|
120
|
+
* @returns The resolved value or default value.
|
|
122
121
|
*/
|
|
123
122
|
declare function getField<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], D>(object: T | null | undefined, path: readonly [K1, K2, K3], defaultValue: D): Exclude<T[K1][K2][K3], undefined> | D;
|
|
124
123
|
/**
|
|
125
124
|
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
126
125
|
*
|
|
127
|
-
* @
|
|
128
|
-
* @
|
|
129
|
-
* @
|
|
130
|
-
* @
|
|
131
|
-
* @
|
|
126
|
+
* @typeParam T - The type of the object.
|
|
127
|
+
* @typeParam K1 - The type of the first key in the object.
|
|
128
|
+
* @typeParam K2 - The type of the second key in the object.
|
|
129
|
+
* @typeParam K3 - The type of the third key in the object.
|
|
130
|
+
* @typeParam K4 - The type of the fourth key in the object.
|
|
132
131
|
*
|
|
133
|
-
* @param
|
|
134
|
-
* @param
|
|
135
|
-
* @returns
|
|
132
|
+
* @param object - The object to query.
|
|
133
|
+
* @param path - The path of the property to get.
|
|
134
|
+
* @returns The resolved value.
|
|
136
135
|
*/
|
|
137
136
|
declare function getField<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3]>(object: T, path: readonly [K1, K2, K3, K4]): T[K1][K2][K3][K4];
|
|
138
137
|
/**
|
|
139
138
|
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
140
139
|
*
|
|
141
|
-
* @
|
|
142
|
-
* @
|
|
143
|
-
* @
|
|
144
|
-
* @
|
|
145
|
-
* @
|
|
140
|
+
* @typeParam T - The type of the object.
|
|
141
|
+
* @typeParam K1 - The type of the first key in the object.
|
|
142
|
+
* @typeParam K2 - The type of the second key in the object.
|
|
143
|
+
* @typeParam K3 - The type of the third key in the object.
|
|
144
|
+
* @typeParam K4 - The type of the fourth key in the object.
|
|
146
145
|
*
|
|
147
|
-
* @param
|
|
148
|
-
* @param
|
|
149
|
-
* @returns
|
|
146
|
+
* @param object - The object to query.
|
|
147
|
+
* @param path - The path of the property to get.
|
|
148
|
+
* @returns The resolved value or undefined.
|
|
150
149
|
*/
|
|
151
150
|
declare function getField<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3]>(object: T | null | undefined, path: readonly [K1, K2, K3, K4]): T[K1][K2][K3][K4] | undefined;
|
|
152
151
|
/**
|
|
153
152
|
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
154
153
|
*
|
|
155
|
-
* @
|
|
156
|
-
* @
|
|
157
|
-
* @
|
|
158
|
-
* @
|
|
159
|
-
* @
|
|
160
|
-
* @
|
|
154
|
+
* @typeParam T - The type of the object.
|
|
155
|
+
* @typeParam K1 - The type of the first key in the object.
|
|
156
|
+
* @typeParam K2 - The type of the second key in the object.
|
|
157
|
+
* @typeParam K3 - The type of the third key in the object.
|
|
158
|
+
* @typeParam K4 - The type of the fourth key in the object.
|
|
159
|
+
* @typeParam D - The type of the default value.
|
|
161
160
|
*
|
|
162
|
-
* @param
|
|
163
|
-
* @param
|
|
164
|
-
* @param
|
|
165
|
-
* @returns
|
|
161
|
+
* @param object - The object to query.
|
|
162
|
+
* @param path - The path of the property to get.
|
|
163
|
+
* @param defaultValue - The value returned if the resolved value is undefined.
|
|
164
|
+
* @returns The resolved value or default value.
|
|
166
165
|
*/
|
|
167
166
|
declare function getField<T extends object, K1 extends keyof T, K2 extends keyof T[K1], K3 extends keyof T[K1][K2], K4 extends keyof T[K1][K2][K3], D>(object: T | null | undefined, path: readonly [K1, K2, K3, K4], defaultValue: D): Exclude<T[K1][K2][K3][K4], undefined> | D;
|
|
168
167
|
/**
|
|
169
168
|
* Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.
|
|
170
169
|
*
|
|
171
|
-
* @
|
|
170
|
+
* @typeParam T - The type of the value.
|
|
172
171
|
*
|
|
173
|
-
* @param
|
|
174
|
-
* @param
|
|
175
|
-
* @returns
|
|
172
|
+
* @param object - The object to query.
|
|
173
|
+
* @param path - The path of the property to get.
|
|
174
|
+
* @returns The resolved value.
|
|
176
175
|
*/
|
|
177
176
|
declare function getField<T>(object: Record<number, T>, path: number): T;
|
|
178
177
|
/**
|
|
179
178
|
* Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.
|
|
180
179
|
*
|
|
181
|
-
* @
|
|
180
|
+
* @typeParam T - The type of the value.
|
|
182
181
|
*
|
|
183
|
-
* @param
|
|
184
|
-
* @param
|
|
185
|
-
* @returns
|
|
182
|
+
* @param object - The object to query.
|
|
183
|
+
* @param path - The path of the property to get.
|
|
184
|
+
* @returns The resolved value or undefined.
|
|
186
185
|
*/
|
|
187
186
|
declare function getField<T>(object: Record<number, T> | null | undefined, path: number): T | undefined;
|
|
188
187
|
/**
|
|
189
188
|
* Retrieves the value at a given path from an object with numeric keys. If the resolved value is undefined, the defaultValue is returned instead.
|
|
190
189
|
*
|
|
191
|
-
* @
|
|
192
|
-
* @
|
|
190
|
+
* @typeParam T - The type of the value.
|
|
191
|
+
* @typeParam D - The type of the default value.
|
|
193
192
|
*
|
|
194
|
-
* @param
|
|
195
|
-
* @param
|
|
196
|
-
* @param
|
|
197
|
-
* @returns
|
|
193
|
+
* @param object - The object to query.
|
|
194
|
+
* @param path - The path of the property to get.
|
|
195
|
+
* @param defaultValue - The value returned if the resolved value is undefined.
|
|
196
|
+
* @returns The resolved value or default value.
|
|
198
197
|
*/
|
|
199
198
|
declare function getField<T, D>(object: Record<number, T> | null | undefined, path: number, defaultValue: D): T | D;
|
|
200
199
|
/**
|
|
201
200
|
* Retrieves the value at a given path from a null or undefined object, returning the default value.
|
|
202
201
|
*
|
|
203
|
-
* @
|
|
202
|
+
* @typeParam D - The type of the default value.
|
|
204
203
|
*
|
|
205
|
-
* @param
|
|
206
|
-
* @param
|
|
207
|
-
* @param
|
|
208
|
-
* @returns
|
|
204
|
+
* @param object - The object to query.
|
|
205
|
+
* @param path - The path of the property to get.
|
|
206
|
+
* @param defaultValue - The value returned if the resolved value is undefined.
|
|
207
|
+
* @returns The default value.
|
|
209
208
|
*/
|
|
210
209
|
declare function getField<D>(object: null | undefined, path: PropertyKey, defaultValue: D): D;
|
|
211
210
|
/**
|
|
212
211
|
* Retrieves the value at a given path from a null or undefined object, returning undefined.
|
|
213
212
|
*
|
|
214
|
-
* @param
|
|
215
|
-
* @param
|
|
216
|
-
* @returns {undefined} - Returns undefined.
|
|
213
|
+
* @param object - The object to query.
|
|
214
|
+
* @param path - The path of the property to get.
|
|
217
215
|
*/
|
|
218
216
|
declare function getField(object: null | undefined, path: PropertyKey): undefined;
|
|
219
217
|
/**
|
|
220
218
|
* Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
221
219
|
*
|
|
222
|
-
* @
|
|
223
|
-
* @
|
|
220
|
+
* @typeParam T - The type of the object.
|
|
221
|
+
* @typeParam P - The type of the path.
|
|
224
222
|
*
|
|
225
|
-
* @param
|
|
226
|
-
* @param
|
|
227
|
-
* @returns
|
|
223
|
+
* @param data - The object to query.
|
|
224
|
+
* @param path - The path of the property to get.
|
|
225
|
+
* @returns The resolved value, or any if path is a general string.
|
|
228
226
|
*/
|
|
229
227
|
declare function getField<T, P extends string>(data: T, path: P): string extends P ? any : GetField<T, P>;
|
|
230
228
|
/**
|
|
231
229
|
* Retrieves the value at a given path from a string-keyed object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
232
230
|
*
|
|
233
|
-
* @
|
|
234
|
-
* @
|
|
235
|
-
* @
|
|
231
|
+
* @typeParam T - The type of the object.
|
|
232
|
+
* @typeParam P - The type of the path.
|
|
233
|
+
* @typeParam D - The type of the default value.
|
|
236
234
|
*
|
|
237
|
-
* @param
|
|
238
|
-
* @param
|
|
239
|
-
* @param
|
|
240
|
-
* @returns
|
|
235
|
+
* @param data - The object to query.
|
|
236
|
+
* @param path - The path of the property to get.
|
|
237
|
+
* @param defaultValue - The value returned if the resolved value is undefined.
|
|
238
|
+
* @returns The resolved value or default value.
|
|
241
239
|
*/
|
|
242
240
|
declare function getField<T, P extends string, D = GetField<T, P>>(data: T, path: P, defaultValue: D): Exclude<GetField<T, P>, null | undefined> | D;
|
|
243
241
|
/**
|
|
244
242
|
* Retrieves the value at a given path from an object. If the resolved value is undefined, the defaultValue is returned instead.
|
|
245
243
|
*
|
|
246
|
-
* @param
|
|
247
|
-
* @param
|
|
248
|
-
* @param
|
|
249
|
-
* @returns
|
|
244
|
+
* @param object - The object to query.
|
|
245
|
+
* @param path - The path of the property to get.
|
|
246
|
+
* @param defaultValue - The value returned if the resolved value is undefined.
|
|
247
|
+
* @returns The resolved value.
|
|
250
248
|
*/
|
|
251
249
|
declare function getField(object: unknown, path: PropertyKey | readonly PropertyKey[], defaultValue?: unknown): any;
|
|
252
250
|
//#endregion
|
package/dist/get-field.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-field.d.cts","names":[],"sources":["../src/get-field.ts"],"sourcesContent":[],"mappings":";;;;KAyBK,eAAwC,CAAA,CAAA,EAAA,CAAA,CAAA,GAAhB,CAAgB,SAAA,MAAA,CAAA,GACzC,CADyC,CACvC,CADuC,CAAA,GAEzC,CAFyC,SAAA,GAAA,MAAA,EAAA,GAAA,QAAA,SAAA,MAGhB,CAHgB,GAAA,MAAA,SAItB,CAJsB,CAAA,QAAA,CAAA,GAAA,MAAA,SAAA,MAKd,CALc,GAMjC,CANiC,CAAA,MAAA,CAAA,GAAA,SAAA,GAAA,SAAA,GAAA,SAAA,GAAA,SAAA;KAYxC,0BAXD,CAAA,CAAA,EAAA,GAAA,CAAA,GAYA,QAZA,CAYS,OAZT,CAYiB,CAZjB,EAAA,SAAA,CA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