@oscarpalmer/atoms 0.74.1 → 0.76.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.
Files changed (282) hide show
  1. package/dist/js/array/chunk.cjs +18 -0
  2. package/dist/js/array/{chunk.mjs → chunk.js} +2 -2
  3. package/dist/js/array/compact.cjs +6 -0
  4. package/dist/js/array/{compact.mjs → compact.js} +0 -1
  5. package/dist/js/array/count.cjs +14 -0
  6. package/dist/js/array/count.js +14 -0
  7. package/dist/js/array/exists.cjs +14 -0
  8. package/dist/js/array/exists.js +14 -0
  9. package/dist/js/array/filter.cjs +14 -0
  10. package/dist/js/array/filter.js +14 -0
  11. package/dist/js/array/find.cjs +14 -0
  12. package/dist/js/array/find.js +14 -0
  13. package/dist/js/array/group-by.cjs +35 -0
  14. package/dist/js/array/group-by.js +35 -0
  15. package/dist/js/array/index-of.cjs +14 -0
  16. package/dist/js/array/index-of.js +14 -0
  17. package/dist/js/array/index.cjs +40 -0
  18. package/dist/js/array/index.js +34 -381
  19. package/dist/js/array/insert.cjs +31 -0
  20. package/dist/js/array/insert.js +31 -0
  21. package/dist/js/array/models.cjs +1 -0
  22. package/dist/js/array/models.js +1 -0
  23. package/dist/js/array/shuffle.cjs +13 -0
  24. package/dist/js/array/{shuffle.mjs → shuffle.js} +2 -3
  25. package/dist/js/array/sort.cjs +53 -0
  26. package/dist/js/array/{sort.mjs → sort.js} +13 -9
  27. package/dist/js/array/splice.cjs +14 -0
  28. package/dist/js/array/splice.js +14 -0
  29. package/dist/js/array/to-map.cjs +27 -0
  30. package/dist/js/array/to-map.js +27 -0
  31. package/dist/js/array/to-record.cjs +12 -0
  32. package/dist/js/array/to-record.js +12 -0
  33. package/dist/js/array/unique.cjs +7 -0
  34. package/dist/js/array/unique.js +7 -0
  35. package/dist/js/colour/base.cjs +18 -0
  36. package/dist/js/colour/{base.mjs → base.js} +4 -3
  37. package/dist/js/colour/functions.cjs +96 -0
  38. package/dist/js/colour/{functions.mjs → functions.js} +18 -19
  39. package/dist/js/colour/hex.cjs +56 -0
  40. package/dist/js/colour/{hex.mjs → hex.js} +34 -15
  41. package/dist/js/colour/hsl.cjs +85 -0
  42. package/dist/js/colour/{hsl.mjs → hsl.js} +40 -12
  43. package/dist/js/colour/index.cjs +29 -0
  44. package/dist/js/colour/index.js +14 -272
  45. package/dist/js/colour/is.cjs +27 -0
  46. package/dist/js/colour/{is.mjs → is.js} +7 -6
  47. package/dist/js/colour/rgb.cjs +87 -0
  48. package/dist/js/colour/{rgb.mjs → rgb.js} +43 -12
  49. package/dist/js/{emitter.mjs → emitter.cjs} +88 -56
  50. package/dist/js/emitter.js +85 -56
  51. package/dist/js/{function.mjs → function.cjs} +66 -46
  52. package/dist/js/function.js +61 -48
  53. package/dist/js/index.cjs +136 -0
  54. package/dist/js/index.js +133 -1724
  55. package/dist/js/internal/array/callbacks.cjs +23 -0
  56. package/dist/js/internal/array/callbacks.js +23 -0
  57. package/dist/js/internal/array/find.cjs +51 -0
  58. package/dist/js/internal/array/find.js +51 -0
  59. package/dist/js/internal/value/handle.cjs +21 -0
  60. package/dist/js/internal/{value-handle.mjs → value/handle.js} +0 -1
  61. package/dist/js/{is.mjs → is.cjs} +17 -18
  62. package/dist/js/is.js +15 -27
  63. package/dist/js/logger.cjs +108 -0
  64. package/dist/js/logger.js +44 -8
  65. package/dist/js/{math.mjs → math.cjs} +7 -8
  66. package/dist/js/math.js +4 -5
  67. package/dist/js/models.cjs +1 -0
  68. package/dist/js/models.js +1 -0
  69. package/dist/js/{number.mjs → number.cjs} +8 -8
  70. package/dist/js/number.js +5 -5
  71. package/dist/js/{query.mjs → query.cjs} +18 -18
  72. package/dist/js/query.js +17 -86
  73. package/dist/js/{queue.mjs → queue.cjs} +12 -13
  74. package/dist/js/queue.js +9 -10
  75. package/dist/js/{random.mjs → random.cjs} +14 -21
  76. package/dist/js/random.js +9 -26
  77. package/dist/js/{sized.mjs → sized.cjs} +68 -33
  78. package/dist/js/sized.js +66 -38
  79. package/dist/js/string/case.cjs +41 -0
  80. package/dist/js/string/{case.mjs → case.js} +13 -9
  81. package/dist/js/string/index.cjs +59 -0
  82. package/dist/js/string/index.js +30 -100
  83. package/dist/js/string/template.cjs +21 -0
  84. package/dist/js/string/{template.mjs → template.js} +4 -5
  85. package/dist/js/{touch.mjs → touch.cjs} +4 -7
  86. package/dist/js/touch.js +3 -5
  87. package/dist/js/value/clone.cjs +76 -0
  88. package/dist/js/value/{clone.mjs → clone.js} +5 -6
  89. package/dist/js/value/compare.cjs +59 -0
  90. package/dist/js/value/{compare.mjs → compare.js} +4 -6
  91. package/dist/js/value/diff.cjs +75 -0
  92. package/dist/js/value/{diff.mjs → diff.js} +13 -11
  93. package/dist/js/value/equal.cjs +106 -0
  94. package/dist/js/value/{equal.mjs → equal.js} +13 -8
  95. package/dist/js/value/get.cjs +21 -0
  96. package/dist/js/value/{get.mjs → get.js} +9 -4
  97. package/dist/js/value/index.cjs +30 -0
  98. package/dist/js/value/index.js +19 -510
  99. package/dist/js/value/merge.cjs +35 -0
  100. package/dist/js/value/{merge.mjs → merge.js} +7 -6
  101. package/dist/js/value/set.cjs +25 -0
  102. package/dist/js/value/{set.mjs → set.js} +3 -4
  103. package/dist/js/value/smush.cjs +26 -0
  104. package/dist/js/value/{smush.mjs → smush.js} +3 -4
  105. package/dist/js/value/unsmush.cjs +39 -0
  106. package/dist/js/value/{unsmush.mjs → unsmush.js} +10 -7
  107. package/package.json +50 -47
  108. package/src/js/array/chunk.ts +6 -5
  109. package/src/js/array/compact.ts +8 -10
  110. package/src/js/array/count.ts +39 -19
  111. package/src/js/array/exists.ts +39 -15
  112. package/src/js/array/filter.ts +42 -20
  113. package/src/js/array/find.ts +45 -20
  114. package/src/js/array/group-by.ts +158 -27
  115. package/src/js/array/index-of.ts +40 -18
  116. package/src/js/array/index.ts +10 -9
  117. package/src/js/array/insert.ts +28 -14
  118. package/src/js/array/models.ts +18 -15
  119. package/src/js/array/shuffle.ts +3 -3
  120. package/src/js/array/sort.ts +32 -34
  121. package/src/js/array/splice.ts +22 -26
  122. package/src/js/array/to-map.ts +133 -45
  123. package/src/js/array/to-record.ts +137 -39
  124. package/src/js/array/unique.ts +20 -15
  125. package/src/js/colour/base.ts +3 -3
  126. package/src/js/colour/functions.ts +4 -6
  127. package/src/js/colour/hex.ts +5 -5
  128. package/src/js/colour/hsl.ts +18 -12
  129. package/src/js/colour/index.ts +1 -1
  130. package/src/js/colour/is.ts +3 -3
  131. package/src/js/colour/rgb.ts +17 -11
  132. package/src/js/emitter.ts +12 -9
  133. package/src/js/function.ts +17 -17
  134. package/src/js/index.ts +16 -16
  135. package/src/js/internal/array/callbacks.ts +33 -0
  136. package/src/js/internal/{array-find.ts → array/find.ts} +23 -24
  137. package/src/js/internal/{value-handle.ts → value/handle.ts} +1 -1
  138. package/src/js/is.ts +2 -2
  139. package/src/js/logger.ts +14 -14
  140. package/src/js/math.ts +1 -1
  141. package/src/js/models.ts +5 -5
  142. package/src/js/number.ts +2 -2
  143. package/src/js/query.ts +6 -10
  144. package/src/js/queue.ts +1 -1
  145. package/src/js/random.ts +9 -19
  146. package/src/js/sized.ts +145 -145
  147. package/src/js/string/case.ts +1 -1
  148. package/src/js/string/index.ts +13 -7
  149. package/src/js/string/template.ts +6 -3
  150. package/src/js/value/clone.ts +3 -7
  151. package/src/js/value/compare.ts +3 -5
  152. package/src/js/value/diff.ts +4 -4
  153. package/src/js/value/equal.ts +2 -2
  154. package/src/js/value/get.ts +3 -3
  155. package/src/js/value/index.ts +2 -2
  156. package/src/js/value/merge.ts +3 -3
  157. package/src/js/value/set.ts +3 -4
  158. package/src/js/value/smush.ts +4 -4
  159. package/src/js/value/unsmush.ts +4 -4
  160. package/types/array/chunk.d.cts +8 -0
  161. package/types/array/chunk.d.ts +2 -2
  162. package/types/array/compact.d.cts +12 -0
  163. package/types/array/compact.d.ts +4 -4
  164. package/types/array/count.d.cts +24 -0
  165. package/types/array/count.d.ts +13 -7
  166. package/types/array/exists.d.cts +26 -0
  167. package/types/array/exists.d.ts +11 -3
  168. package/types/array/filter.d.cts +26 -0
  169. package/types/array/filter.d.ts +14 -6
  170. package/types/array/find.d.cts +26 -0
  171. package/types/array/find.d.ts +14 -6
  172. package/types/array/group-by.d.cts +58 -0
  173. package/types/array/group-by.d.ts +49 -5
  174. package/types/array/index-of.d.cts +26 -0
  175. package/types/array/index-of.d.ts +14 -6
  176. package/types/array/index.d.cts +239 -95
  177. package/types/array/index.d.ts +7 -6
  178. package/types/array/insert.d.cts +16 -0
  179. package/types/array/insert.d.ts +10 -5
  180. package/types/array/models.d.cts +14 -11
  181. package/types/array/models.d.ts +14 -12
  182. package/types/array/shuffle.d.cts +8 -0
  183. package/types/array/shuffle.d.ts +2 -2
  184. package/types/array/sort.d.cts +24 -0
  185. package/types/array/sort.d.ts +10 -10
  186. package/types/array/splice.d.cts +22 -0
  187. package/types/array/splice.d.ts +4 -4
  188. package/types/array/to-map.d.cts +61 -0
  189. package/types/array/to-map.d.ts +42 -20
  190. package/types/array/to-record.d.cts +61 -0
  191. package/types/array/to-record.d.ts +42 -20
  192. package/types/array/unique.d.cts +21 -0
  193. package/types/array/unique.d.ts +10 -6
  194. package/types/colour/base.d.cts +153 -0
  195. package/types/colour/base.d.ts +2 -2
  196. package/types/colour/functions.d.cts +173 -0
  197. package/types/colour/functions.d.ts +3 -3
  198. package/types/colour/hex.d.cts +157 -0
  199. package/types/colour/hex.d.ts +4 -4
  200. package/types/colour/hsl.d.cts +157 -0
  201. package/types/colour/hsl.d.ts +16 -10
  202. package/types/colour/index.d.cts +28 -16
  203. package/types/colour/index.d.ts +1 -1
  204. package/types/colour/is.d.cts +170 -0
  205. package/types/colour/is.d.ts +3 -3
  206. package/types/colour/rgb.d.cts +157 -0
  207. package/types/colour/rgb.d.ts +15 -9
  208. package/types/emitter.d.cts +11 -8
  209. package/types/emitter.d.ts +11 -8
  210. package/types/function.d.cts +10 -10
  211. package/types/function.d.ts +11 -11
  212. package/types/index.d.cts +1120 -736
  213. package/types/index.d.ts +16 -16
  214. package/types/internal/array/callbacks.d.cts +11 -0
  215. package/types/internal/array/callbacks.d.ts +2 -0
  216. package/types/internal/array/find.d.cts +7 -0
  217. package/types/internal/array/find.d.ts +3 -0
  218. package/types/internal/value/handle.d.cts +37 -0
  219. package/types/internal/{value-handle.d.ts → value/handle.d.ts} +1 -1
  220. package/types/is.d.ts +1 -1
  221. package/types/logger.d.cts +13 -21
  222. package/types/logger.d.ts +13 -21
  223. package/types/math.d.cts +1 -1
  224. package/types/math.d.ts +1 -1
  225. package/types/models.d.cts +4 -4
  226. package/types/models.d.ts +1 -4
  227. package/types/number.d.cts +2 -2
  228. package/types/number.d.ts +2 -2
  229. package/types/query.d.cts +2 -2
  230. package/types/query.d.ts +3 -3
  231. package/types/queue.d.cts +1 -1
  232. package/types/queue.d.ts +1 -1
  233. package/types/random.d.cts +8 -12
  234. package/types/random.d.ts +8 -12
  235. package/types/sized.d.cts +6 -6
  236. package/types/sized.d.ts +6 -6
  237. package/types/string/case.d.cts +28 -0
  238. package/types/string/index.d.cts +30 -27
  239. package/types/string/index.d.ts +3 -3
  240. package/types/string/template.d.cts +50 -0
  241. package/types/string/template.d.ts +4 -1
  242. package/types/value/clone.d.cts +8 -0
  243. package/types/value/clone.d.ts +4 -2
  244. package/types/value/compare.d.cts +8 -0
  245. package/types/value/diff.d.cts +25 -0
  246. package/types/value/equal.d.cts +12 -0
  247. package/types/value/get.d.cts +1319 -0
  248. package/types/value/get.d.ts +1 -1
  249. package/types/value/index.d.cts +8 -6
  250. package/types/value/index.d.ts +2 -2
  251. package/types/value/merge.d.cts +72 -0
  252. package/types/value/merge.d.ts +2 -2
  253. package/types/value/set.d.cts +1011 -0
  254. package/types/value/set.d.ts +1 -1
  255. package/types/value/smush.d.cts +1368 -0
  256. package/types/value/smush.d.ts +2 -2
  257. package/types/value/unsmush.d.cts +141 -0
  258. package/types/value/unsmush.d.ts +2 -2
  259. package/dist/js/array/count.mjs +0 -8
  260. package/dist/js/array/exists.mjs +0 -8
  261. package/dist/js/array/filter.mjs +0 -8
  262. package/dist/js/array/find.mjs +0 -8
  263. package/dist/js/array/group-by.mjs +0 -33
  264. package/dist/js/array/index-of.mjs +0 -8
  265. package/dist/js/array/index.mjs +0 -34
  266. package/dist/js/array/insert.mjs +0 -22
  267. package/dist/js/array/models.mjs +0 -0
  268. package/dist/js/array/splice.mjs +0 -9
  269. package/dist/js/array/to-map.mjs +0 -27
  270. package/dist/js/array/to-record.mjs +0 -8
  271. package/dist/js/array/unique.mjs +0 -8
  272. package/dist/js/colour/index.mjs +0 -30
  273. package/dist/js/index.mjs +0 -17
  274. package/dist/js/internal/array-callbacks.mjs +0 -19
  275. package/dist/js/internal/array-find.mjs +0 -51
  276. package/dist/js/logger.mjs +0 -69
  277. package/dist/js/models.mjs +0 -0
  278. package/dist/js/string/index.mjs +0 -44
  279. package/dist/js/value/index.mjs +0 -23
  280. package/src/js/internal/array-callbacks.ts +0 -28
  281. package/types/internal/array-callbacks.d.ts +0 -2
  282. package/types/internal/array-find.d.ts +0 -4
@@ -0,0 +1,1011 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ /**
4
+ Matches any [primitive value](https://developer.mozilla.org/en-US/docs/Glossary/Primitive).
5
+
6
+ @category Type
7
+ */
8
+ export type Primitive =
9
+ | null
10
+ | undefined
11
+ | string
12
+ | number
13
+ | boolean
14
+ | symbol
15
+ | bigint;
16
+ declare const emptyObjectSymbol: unique symbol;
17
+ /**
18
+ Represents a strictly empty plain object, the `{}` value.
19
+
20
+ When you annotate something as the type `{}`, it can be anything except `null` and `undefined`. This means that you cannot use `{}` to represent an empty plain object ([read more](https://stackoverflow.com/questions/47339869/typescript-empty-object-and-any-difference/52193484#52193484)).
21
+
22
+ @example
23
+ ```
24
+ import type {EmptyObject} from 'type-fest';
25
+
26
+ // The following illustrates the problem with `{}`.
27
+ const foo1: {} = {}; // Pass
28
+ const foo2: {} = []; // Pass
29
+ const foo3: {} = 42; // Pass
30
+ const foo4: {} = {a: 1}; // Pass
31
+
32
+ // With `EmptyObject` only the first case is valid.
33
+ const bar1: EmptyObject = {}; // Pass
34
+ const bar2: EmptyObject = 42; // Fail
35
+ const bar3: EmptyObject = []; // Fail
36
+ const bar4: EmptyObject = {a: 1}; // Fail
37
+ ```
38
+
39
+ Unfortunately, `Record<string, never>`, `Record<keyof any, never>` and `Record<never, never>` do not work. See {@link https://github.com/sindresorhus/type-fest/issues/395 #395}.
40
+
41
+ @category Object
42
+ */
43
+ export type EmptyObject = {
44
+ [emptyObjectSymbol]?: never;
45
+ };
46
+ /**
47
+ Returns a boolean for whether the two given types are equal.
48
+
49
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
50
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
51
+
52
+ Use-cases:
53
+ - If you want to make a conditional branch based on the result of a comparison of two types.
54
+
55
+ @example
56
+ ```
57
+ import type {IsEqual} from 'type-fest';
58
+
59
+ // This type returns a boolean for whether the given array includes the given item.
60
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
61
+ type Includes<Value extends readonly any[], Item> =
62
+ Value extends readonly [Value[0], ...infer rest]
63
+ ? IsEqual<Value[0], Item> extends true
64
+ ? true
65
+ : Includes<rest, Item>
66
+ : false;
67
+ ```
68
+
69
+ @category Type Guard
70
+ @category Utilities
71
+ */
72
+ export type IsEqual<A, B> = (<G>() => G extends A ? 1 : 2) extends <
73
+ G,
74
+ >() => G extends B ? 1 : 2
75
+ ? true
76
+ : false;
77
+ /**
78
+ Represents an object with `unknown` value. You probably want this instead of `{}`.
79
+
80
+ Use case: You have an object whose keys and values are unknown to you.
81
+
82
+ @example
83
+ ```
84
+ import type {UnknownRecord} from 'type-fest';
85
+
86
+ function toJson(object: UnknownRecord) {
87
+ return JSON.stringify(object);
88
+ }
89
+
90
+ toJson({hello: 'world'});
91
+ //=> '{"hello":"world"}'
92
+
93
+ function isObject(value: unknown): value is UnknownRecord {
94
+ return typeof value === 'object' && value !== null;
95
+ }
96
+
97
+ isObject({hello: 'world'});
98
+ //=> true
99
+
100
+ isObject('hello');
101
+ //=> false
102
+ ```
103
+
104
+ @category Type
105
+ @category Object
106
+ */
107
+ export type UnknownRecord = Record<PropertyKey, unknown>;
108
+ /**
109
+ Represents an array with `unknown` value.
110
+
111
+ Use case: You want a type that all arrays can be assigned to, but you don't care about the value.
112
+
113
+ @example
114
+ ```
115
+ import type {UnknownArray} from 'type-fest';
116
+
117
+ type IsArray<T> = T extends UnknownArray ? true : false;
118
+
119
+ type A = IsArray<['foo']>;
120
+ //=> true
121
+
122
+ type B = IsArray<readonly number[]>;
123
+ //=> true
124
+
125
+ type C = IsArray<string>;
126
+ //=> false
127
+ ```
128
+
129
+ @category Type
130
+ @category Array
131
+ */
132
+ export type UnknownArray = readonly unknown[];
133
+ /**
134
+ Returns the static, fixed-length portion of the given array, excluding variable-length parts.
135
+
136
+ @example
137
+ ```
138
+ type A = [string, number, boolean, ...string[]];
139
+ type B = StaticPartOfArray<A>;
140
+ //=> [string, number, boolean]
141
+ ```
142
+ */
143
+ export type StaticPartOfArray<
144
+ T extends UnknownArray,
145
+ Result extends UnknownArray = [],
146
+ > = T extends unknown
147
+ ? number extends T['length']
148
+ ? T extends readonly [infer U, ...infer V]
149
+ ? StaticPartOfArray<V, [...Result, U]>
150
+ : Result
151
+ : T
152
+ : never; // Should never happen
153
+ /**
154
+ Returns the variable, non-fixed-length portion of the given array, excluding static-length parts.
155
+
156
+ @example
157
+ ```
158
+ type A = [string, number, boolean, ...string[]];
159
+ type B = VariablePartOfArray<A>;
160
+ //=> string[]
161
+ ```
162
+ */
163
+ export type VariablePartOfArray<T extends UnknownArray> = T extends unknown
164
+ ? T extends readonly [...StaticPartOfArray<T>, ...infer U]
165
+ ? U
166
+ : []
167
+ : never; // Should never happen
168
+ /**
169
+ Returns a boolean for whether the given type is `any`.
170
+
171
+ @link https://stackoverflow.com/a/49928360/1490091
172
+
173
+ Useful in type utilities, such as disallowing `any`s to be passed to a function.
174
+
175
+ @example
176
+ ```
177
+ import type {IsAny} from 'type-fest';
178
+
179
+ const typedObject = {a: 1, b: 2} as const;
180
+ const anyObject: any = {a: 1, b: 2};
181
+
182
+ function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(obj: O, key: K) {
183
+ return obj[key];
184
+ }
185
+
186
+ const typedA = get(typedObject, 'a');
187
+ //=> 1
188
+
189
+ const anyA = get(anyObject, 'a');
190
+ //=> any
191
+ ```
192
+
193
+ @category Type Guard
194
+ @category Utilities
195
+ */
196
+ export type IsAny<T> = 0 extends 1 & T ? true : false;
197
+ export type Numeric = number | bigint;
198
+ export type Zero = 0 | 0n;
199
+ /**
200
+ Matches the hidden `Infinity` type.
201
+
202
+ Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.
203
+
204
+ @see NegativeInfinity
205
+
206
+ @category Numeric
207
+ */
208
+ // See https://github.com/microsoft/TypeScript/issues/31752
209
+ // eslint-disable-next-line @typescript-eslint/no-loss-of-precision
210
+ export type PositiveInfinity = 1e999;
211
+ /**
212
+ Matches the hidden `-Infinity` type.
213
+
214
+ Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.
215
+
216
+ @see PositiveInfinity
217
+
218
+ @category Numeric
219
+ */
220
+ // See https://github.com/microsoft/TypeScript/issues/31752
221
+ // eslint-disable-next-line @typescript-eslint/no-loss-of-precision
222
+ export type NegativeInfinity = -1e999;
223
+ /**
224
+ A negative `number`/`bigint` (`-∞ < x < 0`)
225
+
226
+ Use-case: Validating and documenting parameters.
227
+
228
+ @see NegativeInteger
229
+ @see NonNegative
230
+
231
+ @category Numeric
232
+ */
233
+ export type Negative<T extends Numeric> = T extends Zero
234
+ ? never
235
+ : `${T}` extends `-${string}`
236
+ ? T
237
+ : never;
238
+ /**
239
+ Returns a boolean for whether the given number is a negative number.
240
+
241
+ @see Negative
242
+
243
+ @example
244
+ ```
245
+ import type {IsNegative} from 'type-fest';
246
+
247
+ type ShouldBeFalse = IsNegative<1>;
248
+ type ShouldBeTrue = IsNegative<-1>;
249
+ ```
250
+
251
+ @category Numeric
252
+ */
253
+ export type IsNegative<T extends Numeric> = T extends Negative<T>
254
+ ? true
255
+ : false;
256
+ /**
257
+ Returns a boolean for whether two given types are both true.
258
+
259
+ Use-case: Constructing complex conditional types where multiple conditions must be satisfied.
260
+
261
+ @example
262
+ ```
263
+ import type {And} from 'type-fest';
264
+
265
+ And<true, true>;
266
+ //=> true
267
+
268
+ And<true, false>;
269
+ //=> false
270
+ ```
271
+
272
+ @see {@link Or}
273
+ */
274
+ export type And<A extends boolean, B extends boolean> = [
275
+ A,
276
+ B,
277
+ ][number] extends true
278
+ ? true
279
+ : true extends [IsEqual<A, false>, IsEqual<B, false>][number]
280
+ ? false
281
+ : never;
282
+ /**
283
+ Returns a boolean for whether either of two given types are true.
284
+
285
+ Use-case: Constructing complex conditional types where multiple conditions must be satisfied.
286
+
287
+ @example
288
+ ```
289
+ import type {Or} from 'type-fest';
290
+
291
+ Or<true, false>;
292
+ //=> true
293
+
294
+ Or<false, false>;
295
+ //=> false
296
+ ```
297
+
298
+ @see {@link And}
299
+ */
300
+ export type Or<A extends boolean, B extends boolean> = [
301
+ A,
302
+ B,
303
+ ][number] extends false
304
+ ? false
305
+ : true extends [IsEqual<A, true>, IsEqual<B, true>][number]
306
+ ? true
307
+ : never;
308
+ /**
309
+ Returns a boolean for whether a given number is greater than another number.
310
+
311
+ @example
312
+ ```
313
+ import type {GreaterThan} from 'type-fest';
314
+
315
+ GreaterThan<1, -5>;
316
+ //=> true
317
+
318
+ GreaterThan<1, 1>;
319
+ //=> false
320
+
321
+ GreaterThan<1, 5>;
322
+ //=> false
323
+ ```
324
+ */
325
+ export type GreaterThan<A extends number, B extends number> = number extends
326
+ | A
327
+ | B
328
+ ? never
329
+ : [
330
+ IsEqual<A, PositiveInfinity>,
331
+ IsEqual<A, NegativeInfinity>,
332
+ IsEqual<B, PositiveInfinity>,
333
+ IsEqual<B, NegativeInfinity>,
334
+ ] extends infer R extends [boolean, boolean, boolean, boolean]
335
+ ? Or<
336
+ And<IsEqual<R[0], true>, IsEqual<R[2], false>>,
337
+ And<IsEqual<R[3], true>, IsEqual<R[1], false>>
338
+ > extends true
339
+ ? true
340
+ : Or<
341
+ And<IsEqual<R[1], true>, IsEqual<R[3], false>>,
342
+ And<IsEqual<R[2], true>, IsEqual<R[0], false>>
343
+ > extends true
344
+ ? false
345
+ : true extends R[number]
346
+ ? false
347
+ : [IsNegative<A>, IsNegative<B>] extends infer R extends [
348
+ boolean,
349
+ boolean,
350
+ ]
351
+ ? [true, false] extends R
352
+ ? false
353
+ : [false, true] extends R
354
+ ? true
355
+ : [false, false] extends R
356
+ ? PositiveNumericStringGt<`${A}`, `${B}`>
357
+ : PositiveNumericStringGt<
358
+ `${NumberAbsolute<B>}`,
359
+ `${NumberAbsolute<A>}`
360
+ >
361
+ : never
362
+ : never;
363
+ /**
364
+ Returns a boolean for whether a given number is greater than or equal to another number.
365
+
366
+ @example
367
+ ```
368
+ import type {GreaterThanOrEqual} from 'type-fest';
369
+
370
+ GreaterThanOrEqual<1, -5>;
371
+ //=> true
372
+
373
+ GreaterThanOrEqual<1, 1>;
374
+ //=> true
375
+
376
+ GreaterThanOrEqual<1, 5>;
377
+ //=> false
378
+ ```
379
+ */
380
+ export type GreaterThanOrEqual<
381
+ A extends number,
382
+ B extends number,
383
+ > = number extends A | B ? never : A extends B ? true : GreaterThan<A, B>;
384
+ /**
385
+ Returns a boolean for whether a given number is less than another number.
386
+
387
+ @example
388
+ ```
389
+ import type {LessThan} from 'type-fest';
390
+
391
+ LessThan<1, -5>;
392
+ //=> false
393
+
394
+ LessThan<1, 1>;
395
+ //=> false
396
+
397
+ LessThan<1, 5>;
398
+ //=> true
399
+ ```
400
+ */
401
+ export type LessThan<A extends number, B extends number> = number extends A | B
402
+ ? never
403
+ : GreaterThanOrEqual<A, B> extends true
404
+ ? false
405
+ : true;
406
+ /**
407
+ Create a tuple type of the given length `<L>` and fill it with the given type `<Fill>`.
408
+
409
+ If `<Fill>` is not provided, it will default to `unknown`.
410
+
411
+ @link https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f
412
+ */
413
+ export type BuildTuple<
414
+ L extends number,
415
+ Fill = unknown,
416
+ T extends readonly unknown[] = [],
417
+ > = T['length'] extends L ? T : BuildTuple<L, Fill, [...T, Fill]>;
418
+ /**
419
+ Returns the maximum value from a tuple of integers.
420
+
421
+ Note:
422
+ - Float numbers are not supported.
423
+
424
+ @example
425
+ ```
426
+ ArrayMax<[1, 2, 5, 3]>;
427
+ //=> 5
428
+
429
+ ArrayMax<[1, 2, 5, 3, 99, -1]>;
430
+ //=> 99
431
+ ```
432
+ */
433
+ export type TupleMax<
434
+ A extends number[],
435
+ Result extends number = NegativeInfinity,
436
+ > = number extends A[number]
437
+ ? never
438
+ : A extends [infer F extends number, ...infer R extends number[]]
439
+ ? GreaterThan<F, Result> extends true
440
+ ? TupleMax<R, F>
441
+ : TupleMax<R, Result>
442
+ : Result;
443
+ /**
444
+ Returns the minimum value from a tuple of integers.
445
+
446
+ Note:
447
+ - Float numbers are not supported.
448
+
449
+ @example
450
+ ```
451
+ ArrayMin<[1, 2, 5, 3]>;
452
+ //=> 1
453
+
454
+ ArrayMin<[1, 2, 5, 3, -5]>;
455
+ //=> -5
456
+ ```
457
+ */
458
+ export type TupleMin<
459
+ A extends number[],
460
+ Result extends number = PositiveInfinity,
461
+ > = number extends A[number]
462
+ ? never
463
+ : A extends [infer F extends number, ...infer R extends number[]]
464
+ ? LessThan<F, Result> extends true
465
+ ? TupleMin<R, F>
466
+ : TupleMin<R, Result>
467
+ : Result;
468
+ /**
469
+ Return a string representation of the given string or number.
470
+
471
+ Note: This type is not the return type of the `.toString()` function.
472
+ */
473
+ export type ToString<T> = T extends string | number ? `${T}` : never;
474
+ /**
475
+ Converts a numeric string to a number.
476
+
477
+ @example
478
+ ```
479
+ type PositiveInt = StringToNumber<'1234'>;
480
+ //=> 1234
481
+
482
+ type NegativeInt = StringToNumber<'-1234'>;
483
+ //=> -1234
484
+
485
+ type PositiveFloat = StringToNumber<'1234.56'>;
486
+ //=> 1234.56
487
+
488
+ type NegativeFloat = StringToNumber<'-1234.56'>;
489
+ //=> -1234.56
490
+
491
+ type PositiveInfinity = StringToNumber<'Infinity'>;
492
+ //=> Infinity
493
+
494
+ type NegativeInfinity = StringToNumber<'-Infinity'>;
495
+ //=> -Infinity
496
+ ```
497
+
498
+ @category String
499
+ @category Numeric
500
+ @category Template literal
501
+ */
502
+ export type StringToNumber<S extends string> =
503
+ S extends `${infer N extends number}`
504
+ ? N
505
+ : S extends 'Infinity'
506
+ ? PositiveInfinity
507
+ : S extends '-Infinity'
508
+ ? NegativeInfinity
509
+ : never;
510
+ /**
511
+ Returns an array of the characters of the string.
512
+
513
+ @example
514
+ ```
515
+ StringToArray<'abcde'>;
516
+ //=> ['a', 'b', 'c', 'd', 'e']
517
+
518
+ StringToArray<string>;
519
+ //=> never
520
+ ```
521
+
522
+ @category String
523
+ */
524
+ export type StringToArray<
525
+ S extends string,
526
+ Result extends string[] = [],
527
+ > = string extends S
528
+ ? never
529
+ : S extends `${infer F}${infer R}`
530
+ ? StringToArray<R, [...Result, F]>
531
+ : Result;
532
+ /**
533
+ Returns the length of the given string.
534
+
535
+ @example
536
+ ```
537
+ StringLength<'abcde'>;
538
+ //=> 5
539
+
540
+ StringLength<string>;
541
+ //=> never
542
+ ```
543
+
544
+ @category String
545
+ @category Template literal
546
+ */
547
+ export type StringLength<S extends string> = string extends S
548
+ ? never
549
+ : StringToArray<S>['length'];
550
+ /**
551
+ Returns a boolean for whether `A` represents a number greater than `B`, where `A` and `B` are both numeric strings and have the same length.
552
+
553
+ @example
554
+ ```
555
+ SameLengthPositiveNumericStringGt<'50', '10'>;
556
+ //=> true
557
+
558
+ SameLengthPositiveNumericStringGt<'10', '10'>;
559
+ //=> false
560
+ ```
561
+ */
562
+ export type SameLengthPositiveNumericStringGt<
563
+ A extends string,
564
+ B extends string,
565
+ > = A extends `${infer FirstA}${infer RestA}`
566
+ ? B extends `${infer FirstB}${infer RestB}`
567
+ ? FirstA extends FirstB
568
+ ? SameLengthPositiveNumericStringGt<RestA, RestB>
569
+ : PositiveNumericCharacterGt<FirstA, FirstB>
570
+ : never
571
+ : false;
572
+ export type NumericString = '0123456789';
573
+ /**
574
+ Returns a boolean for whether `A` is greater than `B`, where `A` and `B` are both positive numeric strings.
575
+
576
+ @example
577
+ ```
578
+ PositiveNumericStringGt<'500', '1'>;
579
+ //=> true
580
+
581
+ PositiveNumericStringGt<'1', '1'>;
582
+ //=> false
583
+
584
+ PositiveNumericStringGt<'1', '500'>;
585
+ //=> false
586
+ ```
587
+ */
588
+ export type PositiveNumericStringGt<
589
+ A extends string,
590
+ B extends string,
591
+ > = A extends B
592
+ ? false
593
+ : [
594
+ BuildTuple<StringLength<A>, 0>,
595
+ BuildTuple<StringLength<B>, 0>,
596
+ ] extends infer R extends [readonly unknown[], readonly unknown[]]
597
+ ? R[0] extends [...R[1], ...infer Remain extends readonly unknown[]]
598
+ ? 0 extends Remain['length']
599
+ ? SameLengthPositiveNumericStringGt<A, B>
600
+ : true
601
+ : false
602
+ : never;
603
+ /**
604
+ Returns a boolean for whether `A` represents a number greater than `B`, where `A` and `B` are both positive numeric characters.
605
+
606
+ @example
607
+ ```
608
+ PositiveNumericCharacterGt<'5', '1'>;
609
+ //=> true
610
+
611
+ PositiveNumericCharacterGt<'1', '1'>;
612
+ //=> false
613
+ ```
614
+ */
615
+ export type PositiveNumericCharacterGt<
616
+ A extends string,
617
+ B extends string,
618
+ > = NumericString extends `${infer HeadA}${A}${infer TailA}`
619
+ ? NumericString extends `${infer HeadB}${B}${infer TailB}`
620
+ ? HeadA extends `${HeadB}${infer _}${infer __}`
621
+ ? true
622
+ : false
623
+ : never
624
+ : never;
625
+ /**
626
+ Returns the absolute value of a given value.
627
+
628
+ @example
629
+ ```
630
+ NumberAbsolute<-1>;
631
+ //=> 1
632
+
633
+ NumberAbsolute<1>;
634
+ //=> 1
635
+
636
+ NumberAbsolute<NegativeInfinity>
637
+ //=> PositiveInfinity
638
+ ```
639
+ */
640
+ export type NumberAbsolute<N extends number> =
641
+ `${N}` extends `-${infer StringPositiveN}`
642
+ ? StringToNumber<StringPositiveN>
643
+ : N;
644
+ /**
645
+ Check whether the given type is a number or a number string.
646
+
647
+ Supports floating-point as a string.
648
+
649
+ @example
650
+ ```
651
+ type A = IsNumberLike<'1'>;
652
+ //=> true
653
+
654
+ type B = IsNumberLike<'-1.1'>;
655
+ //=> true
656
+
657
+ type C = IsNumberLike<1>;
658
+ //=> true
659
+
660
+ type D = IsNumberLike<'a'>;
661
+ //=> false
662
+ */
663
+ export type IsNumberLike<N> = N extends number
664
+ ? true
665
+ : N extends `${number}`
666
+ ? true
667
+ : N extends `${number}.${number}`
668
+ ? true
669
+ : false;
670
+ /**
671
+ Matches any primitive, `void`, `Date`, or `RegExp` value.
672
+ */
673
+ export type BuiltIns = Primitive | void | Date | RegExp;
674
+ /**
675
+ Matches non-recursive types.
676
+ */
677
+ export type NonRecursiveType =
678
+ | BuiltIns
679
+ | Function
680
+ | (new (
681
+ ...arguments_: any[]
682
+ ) => unknown);
683
+ /**
684
+ Returns the sum of two numbers.
685
+
686
+ Note:
687
+ - A or B can only support `-999` ~ `999`.
688
+ - A and B can only be small integers, less than 1000.
689
+ - If the result is negative, you can only get `number`.
690
+
691
+ @example
692
+ ```
693
+ import type {Sum} from 'type-fest';
694
+
695
+ Sum<111, 222>;
696
+ //=> 333
697
+
698
+ Sum<-111, 222>;
699
+ //=> 111
700
+
701
+ Sum<111, -222>;
702
+ //=> number
703
+
704
+ Sum<PositiveInfinity, -9999>;
705
+ //=> PositiveInfinity
706
+
707
+ Sum<PositiveInfinity, NegativeInfinity>;
708
+ //=> number
709
+ ```
710
+
711
+ @category Numeric
712
+ */
713
+ // TODO: Support big integer and negative number.
714
+ export type Sum<A extends number, B extends number> = number extends A | B
715
+ ? number
716
+ : [
717
+ IsEqual<A, PositiveInfinity>,
718
+ IsEqual<A, NegativeInfinity>,
719
+ IsEqual<B, PositiveInfinity>,
720
+ IsEqual<B, NegativeInfinity>,
721
+ ] extends infer R extends [boolean, boolean, boolean, boolean]
722
+ ? Or<
723
+ And<IsEqual<R[0], true>, IsEqual<R[3], false>>,
724
+ And<IsEqual<R[2], true>, IsEqual<R[1], false>>
725
+ > extends true
726
+ ? PositiveInfinity
727
+ : Or<
728
+ And<IsEqual<R[1], true>, IsEqual<R[2], false>>,
729
+ And<IsEqual<R[3], true>, IsEqual<R[0], false>>
730
+ > extends true
731
+ ? NegativeInfinity
732
+ : true extends R[number]
733
+ ? number
734
+ : ([IsNegative<A>, IsNegative<B>] extends infer R
735
+ ? [false, false] extends R
736
+ ? [...BuildTuple<A>, ...BuildTuple<B>]['length']
737
+ : [true, true] extends R
738
+ ? number
739
+ : TupleMax<
740
+ [NumberAbsolute<A>, NumberAbsolute<B>]
741
+ > extends infer Max_
742
+ ? TupleMin<
743
+ [NumberAbsolute<A>, NumberAbsolute<B>]
744
+ > extends infer Min_ extends number
745
+ ? Max_ extends A | B
746
+ ? Subtract<Max_, Min_>
747
+ : number
748
+ : never
749
+ : never
750
+ : never) &
751
+ number
752
+ : never;
753
+ /**
754
+ Returns the difference between two numbers.
755
+
756
+ Note:
757
+ - A or B can only support `-999` ~ `999`.
758
+ - If the result is negative, you can only get `number`.
759
+
760
+ @example
761
+ ```
762
+ import type {Subtract} from 'type-fest';
763
+
764
+ Subtract<333, 222>;
765
+ //=> 111
766
+
767
+ Subtract<111, -222>;
768
+ //=> 333
769
+
770
+ Subtract<-111, 222>;
771
+ //=> number
772
+
773
+ Subtract<PositiveInfinity, 9999>;
774
+ //=> PositiveInfinity
775
+
776
+ Subtract<PositiveInfinity, PositiveInfinity>;
777
+ //=> number
778
+ ```
779
+
780
+ @category Numeric
781
+ */
782
+ // TODO: Support big integer and negative number.
783
+ export type Subtract<A extends number, B extends number> = number extends A | B
784
+ ? number
785
+ : [
786
+ IsEqual<A, PositiveInfinity>,
787
+ IsEqual<A, NegativeInfinity>,
788
+ IsEqual<B, PositiveInfinity>,
789
+ IsEqual<B, NegativeInfinity>,
790
+ ] extends infer R extends [boolean, boolean, boolean, boolean]
791
+ ? Or<
792
+ And<IsEqual<R[0], true>, IsEqual<R[2], false>>,
793
+ And<IsEqual<R[3], true>, IsEqual<R[1], false>>
794
+ > extends true
795
+ ? PositiveInfinity
796
+ : Or<
797
+ And<IsEqual<R[1], true>, IsEqual<R[3], false>>,
798
+ And<IsEqual<R[2], true>, IsEqual<R[0], false>>
799
+ > extends true
800
+ ? NegativeInfinity
801
+ : true extends R[number]
802
+ ? number
803
+ : [IsNegative<A>, IsNegative<B>] extends infer R
804
+ ? [false, false] extends R
805
+ ? BuildTuple<A> extends infer R
806
+ ? R extends [...BuildTuple<B>, ...infer R]
807
+ ? R['length']
808
+ : number
809
+ : never
810
+ : LessThan<A, B> extends true
811
+ ? number
812
+ : [false, true] extends R
813
+ ? Sum<A, NumberAbsolute<B>>
814
+ : Subtract<NumberAbsolute<B>, NumberAbsolute<A>>
815
+ : never
816
+ : never;
817
+ /**
818
+ Paths options.
819
+
820
+ @see {@link Paths}
821
+ */
822
+ export type PathsOptions = {
823
+ /**
824
+ The maximum depth to recurse when searching for paths.
825
+
826
+ @default 10
827
+ */
828
+ maxRecursionDepth?: number;
829
+ /**
830
+ Use bracket notation for array indices and numeric object keys.
831
+
832
+ @default false
833
+
834
+ @example
835
+ ```
836
+ type ArrayExample = {
837
+ array: ['foo'];
838
+ };
839
+
840
+ type A = Paths<ArrayExample, {bracketNotation: false}>;
841
+ //=> 'array' | 'array.0'
842
+
843
+ type B = Paths<ArrayExample, {bracketNotation: true}>;
844
+ //=> 'array' | 'array[0]'
845
+ ```
846
+
847
+ @example
848
+ ```
849
+ type NumberKeyExample = {
850
+ 1: ['foo'];
851
+ };
852
+
853
+ type A = Paths<NumberKeyExample, {bracketNotation: false}>;
854
+ //=> 1 | '1' | '1.0'
855
+
856
+ type B = Paths<NumberKeyExample, {bracketNotation: true}>;
857
+ //=> '[1]' | '[1][0]'
858
+ ```
859
+ */
860
+ bracketNotation?: boolean;
861
+ };
862
+ export type DefaultPathsOptions = {
863
+ maxRecursionDepth: 10;
864
+ bracketNotation: false;
865
+ };
866
+ /**
867
+ Generate a union of all possible paths to properties in the given object.
868
+
869
+ It also works with arrays.
870
+
871
+ Use-case: You want a type-safe way to access deeply nested properties in an object.
872
+
873
+ @example
874
+ ```
875
+ import type {Paths} from 'type-fest';
876
+
877
+ type Project = {
878
+ filename: string;
879
+ listA: string[];
880
+ listB: [{filename: string}];
881
+ folder: {
882
+ subfolder: {
883
+ filename: string;
884
+ };
885
+ };
886
+ };
887
+
888
+ type ProjectPaths = Paths<Project>;
889
+ //=> 'filename' | 'listA' | 'listB' | 'folder' | `listA.${number}` | 'listB.0' | 'listB.0.filename' | 'folder.subfolder' | 'folder.subfolder.filename'
890
+
891
+ declare function open<Path extends ProjectPaths>(path: Path): void;
892
+
893
+ open('filename'); // Pass
894
+ open('folder.subfolder'); // Pass
895
+ open('folder.subfolder.filename'); // Pass
896
+ open('foo'); // TypeError
897
+
898
+ // Also works with arrays
899
+ open('listA.1'); // Pass
900
+ open('listB.0'); // Pass
901
+ open('listB.1'); // TypeError. Because listB only has one element.
902
+ ```
903
+
904
+ @category Object
905
+ @category Array
906
+ */
907
+ export type Paths<T, Options extends PathsOptions = {}> = _Paths<
908
+ T,
909
+ {
910
+ // Set default maxRecursionDepth to 10
911
+ maxRecursionDepth: Options['maxRecursionDepth'] extends number
912
+ ? Options['maxRecursionDepth']
913
+ : DefaultPathsOptions['maxRecursionDepth'];
914
+ // Set default bracketNotation to false
915
+ bracketNotation: Options['bracketNotation'] extends boolean
916
+ ? Options['bracketNotation']
917
+ : DefaultPathsOptions['bracketNotation'];
918
+ }
919
+ >;
920
+ export type _Paths<T, Options extends Required<PathsOptions>> = T extends
921
+ | NonRecursiveType
922
+ | ReadonlyMap<unknown, unknown>
923
+ | ReadonlySet<unknown>
924
+ ? never
925
+ : IsAny<T> extends true
926
+ ? never
927
+ : T extends UnknownArray
928
+ ? number extends T['length']
929
+ ?
930
+ | InternalPaths<StaticPartOfArray<T>, Options>
931
+ | InternalPaths<Array<VariablePartOfArray<T>[number]>, Options>
932
+ : InternalPaths<T, Options>
933
+ : T extends object
934
+ ? InternalPaths<T, Options>
935
+ : never;
936
+ export type InternalPaths<
937
+ T,
938
+ Options extends Required<PathsOptions>,
939
+ > = Options['maxRecursionDepth'] extends infer MaxDepth extends number
940
+ ? Required<T> extends infer T
941
+ ? T extends EmptyObject | readonly []
942
+ ? never
943
+ : {
944
+ [Key in keyof T]: Key extends string | number // Limit `Key` to string or number.
945
+ ? (
946
+ Options['bracketNotation'] extends true
947
+ ? IsNumberLike<Key> extends true
948
+ ? `[${Key}]`
949
+ : Key | ToString<Key>
950
+ : never | Options['bracketNotation'] extends false
951
+ ? Key | ToString<Key>
952
+ : never
953
+ ) extends infer TranformedKey extends string | number
954
+ ? // 1. If style is 'a[0].b' and 'Key' is a numberlike value like 3 or '3', transform 'Key' to `[${Key}]`, else to `${Key}` | Key
955
+ // 2. If style is 'a.0.b', transform 'Key' to `${Key}` | Key
956
+ | TranformedKey
957
+ // Recursively generate paths for the current key
958
+ | (GreaterThan<MaxDepth, 0> extends true // Limit the depth to prevent infinite recursion
959
+ ? _Paths<
960
+ T[Key],
961
+ {
962
+ bracketNotation: Options['bracketNotation'];
963
+ maxRecursionDepth: Subtract<MaxDepth, 1>;
964
+ }
965
+ > extends infer SubPath
966
+ ? SubPath extends string | number
967
+ ?
968
+ | (Options['bracketNotation'] extends true
969
+ ? SubPath extends
970
+ | `[${any}]`
971
+ | `[${any}]${string}`
972
+ ? `${TranformedKey}${SubPath}` // If next node is number key like `[3]`, no need to add `.` before it.
973
+ : `${TranformedKey}.${SubPath}`
974
+ : never)
975
+ | (Options['bracketNotation'] extends false
976
+ ? `${TranformedKey}.${SubPath}`
977
+ : never)
978
+ : never
979
+ : never
980
+ : never)
981
+ : never
982
+ : never;
983
+ }[keyof T & (T extends UnknownArray ? number : unknown)]
984
+ : never
985
+ : never;
986
+ export type PlainObject = UnknownRecord;
987
+ /**
988
+ * - Set the value in an object using a known path
989
+ * - You can set a nested value by using dot notation, e.g., `foo.bar.baz`
990
+ * - If a part of the path does not exist, it will be created, either as an array or a generic object, depending on the path
991
+ * - Returns the original object
992
+ */
993
+ export declare function setValue<
994
+ Data extends PlainObject,
995
+ Path extends Paths<Data>,
996
+ >(data: Data, path: Path, value: unknown): Data;
997
+ /**
998
+ * - Set the value in an object using an unknown path
999
+ * - You can set a nested value by using dot notation, e.g., `foo.bar.baz`
1000
+ * - If a part of the path does not exist, it will be created, either as an array or a generic object, depending on the path
1001
+ * - If `ignoreCase` is `true`, path matching will be case-insensitive
1002
+ * - Returns the original object
1003
+ */
1004
+ export declare function setValue<Data extends PlainObject>(
1005
+ data: Data,
1006
+ path: string,
1007
+ value: unknown,
1008
+ ignoreCase?: boolean,
1009
+ ): Data;
1010
+
1011
+ export {};