inferred-types 0.33.4 → 0.34.2

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 (48) hide show
  1. package/.vscode/settings.json +1 -0
  2. package/dist/index.d.ts +204 -103
  3. package/dist/index.js +20 -6
  4. package/dist/index.mjs +17 -6
  5. package/package.json +3 -3
  6. package/src/runtime/combinators/or.ts +4 -14
  7. package/src/runtime/type-checks/isArray.ts +30 -1
  8. package/src/runtime/type-checks/isBoolean.ts +1 -1
  9. package/src/runtime/type-checks/isFalse.ts +24 -12
  10. package/src/runtime/type-checks/isObject.ts +1 -1
  11. package/src/runtime/type-checks/isString.ts +1 -1
  12. package/src/runtime/type-checks/isTrue.ts +13 -29
  13. package/src/runtime/type-checks/isUndefined.ts +1 -1
  14. package/src/runtime/type-checks/startsWith.ts +9 -11
  15. package/src/types/Mutable.ts +1 -1
  16. package/src/types/Narrowable.ts +1 -2
  17. package/src/types/boolean-logic/EndsWith.ts +40 -0
  18. package/src/types/boolean-logic/Extends.ts +22 -0
  19. package/src/types/{type-checks → boolean-logic}/Includes.ts +3 -4
  20. package/src/types/{type-checks → boolean-logic}/IsLiteral.ts +52 -5
  21. package/src/types/boolean-logic/IsScalar.ts +20 -0
  22. package/src/types/{type-checks → boolean-logic}/IsUndefined.ts +5 -1
  23. package/src/types/boolean-logic/Or.ts +12 -0
  24. package/src/types/{type-checks → boolean-logic}/StartsWith.ts +12 -13
  25. package/src/types/{type-checks → boolean-logic}/TypeDefault.ts +1 -1
  26. package/src/types/boolean-logic/array.ts +57 -0
  27. package/src/types/boolean-logic/boolean.ts +84 -0
  28. package/src/types/boolean-logic/equivalency.ts +15 -0
  29. package/src/types/{type-checks → boolean-logic}/index.ts +4 -3
  30. package/src/types/{type-checks → boolean-logic}/object.ts +4 -1
  31. package/src/types/{type-checks → boolean-logic}/string.ts +1 -1
  32. package/src/types/dictionary/MapTo.ts +1 -1
  33. package/src/types/functions/LogicFunction.ts +1 -1
  34. package/src/types/index.ts +1 -1
  35. package/src/types/lists/FilterTuple.ts +20 -0
  36. package/src/types/lists/index.ts +1 -0
  37. package/tests/boolean-logic/Contains.test.ts +55 -0
  38. package/tests/{TypeInfo → boolean-logic}/IsLiteral.spec.ts +0 -0
  39. package/tests/dictionary/{PrependValuesWithFunction.ts → PrependValuesWithFunction.test.ts} +0 -0
  40. package/tests/dictionary/TypeDefault.test.ts +1 -1
  41. package/tests/lists/Length.test.ts +19 -0
  42. package/tests/runtime/if-is.spec.ts +113 -5
  43. package/src/types/type-checks/EndsWith.ts +0 -22
  44. package/src/types/type-checks/Extends.ts +0 -14
  45. package/src/types/type-checks/IsBooleanLiteral.ts +0 -16
  46. package/src/types/type-checks/IsNumericLiteral.ts +0 -16
  47. package/src/types/type-checks/IsScalar.ts +0 -14
  48. package/src/types/type-checks/IsStringLiteral.ts +0 -14
@@ -9,6 +9,7 @@
9
9
  "Dasherize",
10
10
  "dasherized",
11
11
  "Decomp",
12
+ "foey",
12
13
  "foofoo",
13
14
  "fooy",
14
15
  "ruleset",
package/dist/index.d.ts CHANGED
@@ -141,6 +141,110 @@ type Keys<T extends Record<string, any> | readonly string[], W extends string |
141
141
  */
142
142
  type Length<T extends readonly any[]> = T["length"];
143
143
 
144
+ /**
145
+ * **Equal**`<X,Y>`
146
+ *
147
+ * Type utility which tests whether two types -- `X` and `Y` -- are exactly the same type
148
+ */
149
+ type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => T extends Y ? 1 : 2 ? true : false;
150
+ /**
151
+ * **NotEqual**`<X,Y>`
152
+ *
153
+ * Type utility which tests whether two types -- `X` and `Y` -- are _not_ exactly the same type
154
+ */
155
+ type NotEqual<X, Y> = true extends Equal<X, Y> ? false : true;
156
+
157
+ /**
158
+ * **AfterFirst**`<T>`
159
+ *
160
+ * returns the elements in an array _after_ the first element
161
+ */
162
+ type AfterFirst<T extends readonly any[]> = T extends readonly [any, ...any[]] ? T extends readonly [any, ...infer Rest] ? Rest : never : T;
163
+
164
+ /**
165
+ * returns the first `string` value from an array of values
166
+ */
167
+ type FirstString<T> = T extends [infer S extends string, ...unknown[]] ? S : never;
168
+
169
+ /**
170
+ * **FilterTuple**
171
+ *
172
+ * Allows a known tuple `T` to be _filtered down_ by eliminating all items
173
+ * in the Tuple that _extend_ type `F`
174
+ * ```ts
175
+ * type T = [1,"foo",3];
176
+ * // [1,3]
177
+ * type T2 = FilterTuple<T, string>;
178
+ * ```
179
+ */
180
+ type FilterTuple<TTuple extends any[] | readonly any[], TFilter, Result extends any[] = []> = TTuple extends [infer A, ...infer R] ? [A] extends [TFilter] ? FilterTuple<R, TFilter, Result> : FilterTuple<R, TFilter, [...Result, A]> : Result;
181
+
182
+ /**
183
+ * **Split**`<T, SEP>`
184
+ *
185
+ * Splits a string literal `T` by string literal _separator_ `SEP`. The result is an array
186
+ * of string literals.
187
+ */
188
+ type Split<T extends string, SEP extends string, ANSWER extends string[] = []> = string extends T ? string[] : T extends SEP ? ANSWER : T extends `${infer HEAD}${SEP}${infer TAIL}` ? Split<TAIL, SEP, [...ANSWER, HEAD]> : [...ANSWER, T];
189
+
190
+ /**
191
+ * Get the type of a property of an object:
192
+ * ```ts
193
+ * const car = { make: "Chevy", model: "Malibu", }
194
+ * ```
195
+ */
196
+ type Get<T, K> = K extends `${infer FK}.${infer L}` ? FK extends keyof T ? Get<T[FK], L> : never : K extends keyof T ? T[K] : never;
197
+
198
+ /**
199
+ * A union of types used in conjunction with the `literalValues()` function
200
+ * to produce a _narrow_ type definition of a passed in dictionary object.
201
+ */
202
+ type Narrowable = string | number | boolean | symbol | object | undefined | void | null | {};
203
+
204
+ /**
205
+ * Create a union type based on a given property in an array of objects
206
+ * ```ts
207
+ * const data = [
208
+ * { id: 123, color: "blue" },
209
+ * { id: 456, color: "red" },
210
+ * ] as const;
211
+ * // 123 | 456
212
+ * type U = UniqueForProp<typeof data, "id">;
213
+ * ```
214
+ */
215
+ type UniqueForProp<T extends readonly Record<string, Narrowable>[], P extends string> = Readonly<Get<T[number], P>>;
216
+
217
+ type IsArray<T> = [T] extends [any[]] ? true : [T] extends [readonly any[]] ? true : false;
218
+ type IsReadonlyArray<T> = T extends readonly any[] ? true : false;
219
+ /**
220
+ * **IfArray**`<T, IF, ELSE>`
221
+ *
222
+ * Type utility which convert to type `IF` or `ELSE` based on whether `T` is an array
223
+ */
224
+ type IfArray<T extends Narrowable, IF extends Narrowable, ELSE extends Narrowable> = IsArray<T> extends true ? IF : ELSE;
225
+ /**
226
+ * **IfArray**`<T, IF, ELSE>`
227
+ *
228
+ * Type utility which convert to type `IF` or `ELSE` based on whether `T` is a readonly array
229
+ */
230
+ type IfReadonlyArray<T extends Narrowable, IF extends Narrowable, ELSE extends Narrowable> = IsReadonlyArray<T> extends true ? IF : ELSE;
231
+ /**
232
+ * **Contains**`<T, A>`
233
+ *
234
+ * Type utility which checks whether a type `T` exists within an array `A`. Result is
235
+ * `true` if `T` _extends_ any element in `A` making it match widely against `A`. If you
236
+ * prefer a narrower match you can use `NarrowlyContains<T,A>` instead.
237
+ */
238
+ type Contains<T extends Narrowable, A extends readonly any[]> = First<A> extends T ? true : [] extends AfterFirst<A> ? false : Contains<T, AfterFirst<A>>;
239
+ /**
240
+ * **NarrowlyContains**`<T, A>`
241
+ *
242
+ * Type utility which checks whether a type `T` exists within an array `A`. Result is
243
+ * `true` if `T` _extends_ any element in `A` making it match widely against `A`. If you
244
+ * prefer a wider match you can use `Contains<T,A>` instead.
245
+ */
246
+ type NarrowlyContains<T extends Narrowable, A extends readonly any[]> = Equal<First<A>, T> extends true ? true : [] extends AfterFirst<A> ? false : NarrowlyContains<T, AfterFirst<A>>;
247
+
144
248
  /**
145
249
  * Converts a Tuple type into a _union_ of the tuple elements
146
250
  * ```ts
@@ -168,19 +272,47 @@ type UnionToTuple<U, Last = LastInUnion<U>> = [U] extends [never] ? [] : [...Uni
168
272
 
169
273
  type Widen<T> = T extends string ? string : T extends number ? number : T extends boolean ? boolean : T;
170
274
 
275
+ type IsBoolean<T> = T extends boolean ? true : false;
276
+ /**
277
+ * Type utility which returns `true` or `false` based on
278
+ * whether the type holds the narrow "true" type.
279
+ * ```ts
280
+ * // true
281
+ * type T = IsTrue<true>;
282
+ * // boolean
283
+ * type U = IsTrue<boolean>;
284
+ * // false
285
+ * type F = IsTrue<false>;
286
+ * type F2 = IsTrue<"false">;
287
+ * ```
288
+ */
289
+ type IsTrue<T extends Narrowable> = IsBoolean<T> extends true ? T extends true ? true : T extends false ? false : unknown : false;
290
+ type IsFalse<T extends Narrowable> = IsBoolean<T> extends true ? T extends false ? true : true extends T ? false : unknown : false;
291
+ /**
292
+ * Type utility which checks for literal `true` value and then switches type
293
+ * to the IF, ELSE, or MAYBE generic types passed in where _maybe_ is when T
294
+ * is the wide type of `boolean`
295
+ */
296
+ type IfTrue<T extends boolean, IF extends Narrowable, ELSE extends Narrowable, MAYBE extends Narrowable> = IsTrue<T> extends true ? IF : IsTrue<T> extends false ? ELSE : MAYBE;
297
+ /**
298
+ * Type utility which checks for literal `false` value and then switches type
299
+ * to the IF, ELSE, or MAYBE generic types passed in where _maybe_ is when T
300
+ * is the wide type of `boolean`
301
+ */
302
+ type IfFalse<T extends Narrowable, IF extends Narrowable, ELSE extends Narrowable, MAYBE extends Narrowable> = IsFalse<T> extends true ? IF : IsTrue<T> extends false ? ELSE : MAYBE;
171
303
  /**
172
304
  * **IsBooleanLiteral**
173
305
  *
174
306
  * Type utility which returns true/false if the boolean value is a _boolean literal_ versus
175
307
  * just the wider _boolean_ type.
176
308
  */
177
- type IsBooleanLiteral<T extends boolean> = boolean extends T ? false : true;
309
+ type IsBooleanLiteral<T extends Narrowable> = IsTrue<T> extends true ? true : IsFalse<T> extends true ? true : false;
178
310
  /**
179
311
  * **IfBooleanLiteral**
180
312
  *
181
313
  * Branch utility which returns `IF` type when `T` is a boolean literal and `ELSE` otherwise
182
314
  */
183
- type IfBooleanLiteral<T extends boolean, IF, ELSE> = IsBooleanLiteral<T> extends true ? IF : ELSE;
315
+ type IfBooleanLiteral<T extends boolean, IF extends Narrowable, ELSE extends Narrowable> = IsBooleanLiteral<T> extends true ? IF : ELSE;
184
316
 
185
317
  /**
186
318
  * **IsStringLiteral**
@@ -188,14 +320,15 @@ type IfBooleanLiteral<T extends boolean, IF, ELSE> = IsBooleanLiteral<T> extends
188
320
  * Type utility which returns true/false if the string a _string literal_ versus
189
321
  * just the _string_ type.
190
322
  */
191
- type IsStringLiteral<T> = [T] extends [string] ? (string extends T ? false : true) : false;
323
+ type IsStringLiteral<T extends Narrowable> = [T] extends [string] ? string extends T ? false : true : false;
192
324
  /**
193
325
  * **IfStringLiteral**
194
326
  *
195
327
  * Branch utility which returns `IF` type when `T` is a string literal and `ELSE` otherwise
196
328
  */
197
- type IfStringLiteral<T, IF, ELSE> = [IsStringLiteral<T>] extends [true] ? IF : ELSE;
198
-
329
+ type IfStringLiteral<T extends string, IF extends Narrowable, ELSE extends Narrowable> = [
330
+ IsStringLiteral<T>
331
+ ] extends [true] ? IF : ELSE;
199
332
  /**
200
333
  * **IsNumericLiteral**
201
334
  *
@@ -208,8 +341,7 @@ type IsNumericLiteral<T extends number> = number extends T ? false : true;
208
341
  *
209
342
  * Branch utility which returns `IF` type when `T` is a numeric literal and `ELSE` otherwise
210
343
  */
211
- type IfNumericLiteral<T extends number, IF, ELSE> = IsNumericLiteral<T> extends true ? IF : ELSE;
212
-
344
+ type IfNumericLiteral<T extends number, IF extends Narrowable, ELSE extends Narrowable> = IsNumericLiteral<T> extends true ? IF : ELSE;
213
345
  /**
214
346
  * **IsLiteral**
215
347
  *
@@ -235,17 +367,17 @@ type IsOptionalLiteral<T> = [Exclude<T, undefined>] extends [string] ? IsStringL
235
367
  *
236
368
  * Branch type utility with return `IF` when `T` is a _literal_ value and `ELSE` otherwise
237
369
  */
238
- type IfLiteral<T, IF, ELSE> = IsLiteral<T> extends true ? IF : ELSE;
370
+ type IfLiteral<T, IF extends Narrowable, ELSE extends Narrowable> = IsLiteral<T> extends true ? IF : ELSE;
239
371
  /**
240
372
  * **IfOptionalLiteral**
241
373
  *
242
374
  * Branch type utility with return `IF` when `T` is a _literal_ value (with possibly
243
375
  * the inclusion of _undefined_); otherwise returns the type `ELSE`
244
376
  */
245
- type IfOptionalLiteral<T, IF, ELSE> = IsOptionalLiteral<T> extends true ? IF : ELSE;
377
+ type IfOptionalLiteral<T, IF extends Narrowable, ELSE extends Narrowable> = IsOptionalLiteral<T> extends true ? IF : ELSE;
246
378
 
247
379
  /**
248
- * **Includes<TSource, TValue>**
380
+ * **Includes**`<TSource, TValue>`
249
381
  *
250
382
  * Type utility which returns `true` or `false` based on whether `TValue` is found
251
383
  * in `TSource`. Where `TSource` can be a string literal or an array of string literals.
@@ -254,21 +386,15 @@ type IfOptionalLiteral<T, IF, ELSE> = IsOptionalLiteral<T> extends true ? IF : E
254
386
  * no way to know at design-time whether the value includes `TValue` and so it will return
255
387
  * a type of `boolean`.
256
388
  */
257
- type Includes<TSource extends string | string[], TValue extends string> = TSource extends string[] ? IsStringLiteral<TupleToUnion<TSource>> extends true ? IsLiteral<TValue> extends true ? TValue extends TupleToUnion<TSource> ? true : false : boolean : boolean : TSource extends string ? IsLiteral<TSource> extends true ? IsLiteral<TValue> extends true ? TSource extends `${string}${TValue}${string}` ? true : false : boolean : boolean : boolean;
389
+ type Includes<TSource extends string | readonly string[], TValue extends string> = TSource extends string[] ? IsStringLiteral<TupleToUnion<TSource>> extends true ? IsLiteral<TValue> extends true ? TValue extends TupleToUnion<TSource> ? true : false : boolean : boolean : TSource extends string ? IsLiteral<TSource> extends true ? IsLiteral<TValue> extends true ? TSource extends `${string}${TValue}${string}` ? true : false : boolean : boolean : boolean;
258
390
 
259
- type IsScalar<T> = [T] extends [string] ? true : [T] extends [number] ? true : [T] extends [boolean] ? true : false;
391
+ type IsScalar<T extends Narrowable> = [T] extends [string] ? true : [T] extends [number] ? true : [T] extends [boolean] ? true : false;
260
392
  /**
261
- * **IfScalar**
393
+ * **IfScalar**`<T, IF, ELSE>`
262
394
  *
263
- * Branch type utility which returns `IF` when `T` is a scalar value and `ELSE` otherwise
264
- */
265
- type IfScalar<T, IF, ELSE> = IsScalar<T> extends true ? IF : ELSE;
266
-
267
- /**
268
- * A union of types used in conjunction with the `literalValues()` function
269
- * to produce a _narrow_ type definition of a passed in dictionary object.
395
+ * Branch type utility which returns `IF` when `T` is a scalar value (aka, string, number, or boolean) and `ELSE` otherwise
270
396
  */
271
- type Narrowable = string | number | boolean | symbol | object | undefined | void | null | {};
397
+ type IfScalar<T extends Narrowable, IF extends Narrowable, ELSE extends Narrowable> = IsScalar<T> extends true ? IF : ELSE;
272
398
 
273
399
  /**
274
400
  * **IsUndefined**
@@ -282,21 +408,21 @@ type IsUndefined<T extends Narrowable> = T extends undefined ? true : false;
282
408
  * Type utility which returns `IF` type when `T` is an _undefined_
283
409
  * otherwise returns `ELSE` type.
284
410
  */
285
- type IfUndefined<T, IF, ELSE> = IsUndefined<T> extends true ? IF : ELSE;
411
+ type IfUndefined<T, IF extends Narrowable, ELSE extends Narrowable> = IsUndefined<T> extends true ? IF : ELSE;
286
412
 
287
413
  /**
288
- * **Extends**
414
+ * **Extends**`<T, EXTENDS>`
289
415
  *
290
- * Boolean type utility which returns `true` if `E` _extends_ `T`.
416
+ * Boolean type utility which returns `true` if `T` _extends_ `EXTENDS`.
291
417
  */
292
- type Extends<E, T> = E extends T ? true : false;
418
+ type Extends<T extends Narrowable, EXTENDS extends Narrowable> = T extends EXTENDS ? true : false;
293
419
  /**
294
420
  * **IfExtends**
295
421
  *
296
422
  * Branching type utility which returns type `IF` when `E` _extends_ `T`; otherwise
297
423
  * it will return the type `ELSE`.
298
424
  */
299
- type IfExtends<E, T, IF, ELSE> = Extends<E, T> extends true ? IF : ELSE;
425
+ type IfExtends<T extends Narrowable, EXTENDS extends Narrowable, IF extends Narrowable, ELSE extends Narrowable> = Extends<T, EXTENDS> extends true ? IF : ELSE;
300
426
 
301
427
  /**
302
428
  * Often when mutating the shape of an object you will end up with the union of a number of
@@ -347,7 +473,7 @@ type IsObject<T> = Mutable<T> extends Record<string, any> ? T extends FunctionTy
347
473
  * Branch type utility with return `IF` when `T` extends an object type
348
474
  * and `ELSE` otherwise
349
475
  */
350
- type IfObject<T, IF, ELSE> = IsObject<T> extends true ? IF : ELSE;
476
+ type IfObject<T, IF extends Narrowable, ELSE extends Narrowable> = IsObject<T> extends true ? IF : ELSE;
351
477
 
352
478
  /**
353
479
  * **StartsWith**<TValue, TStartsWith>
@@ -358,8 +484,7 @@ type IfObject<T, IF, ELSE> = IsObject<T> extends true ? IF : ELSE;
358
484
  * to a literal `true` or `false` but if either is not a literal that it will
359
485
  * just resolve to `boolean` as the value can not be known at design time..
360
486
  */
361
- type StartsWith<TValue extends unknown, TStartsWith extends unknown> = TValue extends string ? TStartsWith extends string ? TValue extends `${TStartsWith}${string}` ? IfStringLiteral<TValue, //
362
- IfStringLiteral<TStartsWith, true, boolean>, boolean> : IfStringLiteral<TValue, false, boolean> : false : false;
487
+ type StartsWith<TValue extends string, TStartsWith extends string> = IsStringLiteral<TStartsWith> extends true ? IsStringLiteral<TValue> extends true ? TValue extends `${TStartsWith}${string}` ? true : false : boolean : boolean;
363
488
  /**
364
489
  * **IfStartsWith**<TValue, TStartsWith, IF, ELSE, MAYBE>
365
490
  *
@@ -370,7 +495,7 @@ IfStringLiteral<TStartsWith, true, boolean>, boolean> : IfStringLiteral<TValue,
370
495
  * which can be stated for cases where TValue or TStartsWith _might_ be the wider `string`
371
496
  * type and therefore the type is unknown at design time.
372
497
  */
373
- type IfStartsWith<TValue extends unknown, TStartsWith extends unknown, IF extends Narrowable, ELSE extends Narrowable> = StartsWith<TValue, TStartsWith> extends true ? IF : StartsWith<TValue, TStartsWith> extends false ? ELSE : IF | ELSE;
498
+ type IfStartsWith<TValue extends string, TStartsWith extends string, IF extends Narrowable, ELSE extends Narrowable> = StartsWith<TValue, TStartsWith> extends true ? IF : StartsWith<TValue, TStartsWith> extends false ? ELSE : IF | ELSE;
374
499
 
375
500
  /**
376
501
  * **EndsWith**<T,U>
@@ -381,8 +506,22 @@ type IfStartsWith<TValue extends unknown, TStartsWith extends unknown, IF extend
381
506
  * to a literal `true` or `false` but if either is not a literal that it will
382
507
  * just resolve to `boolean` as the value can not be known at design time..
383
508
  */
384
- type EndsWith<T extends unknown, U extends unknown> = T extends string ? U extends string ? T extends `${string}${U}` ? IfStringLiteral<T, //
385
- IfStringLiteral<U, true, boolean>, boolean> : IfStringLiteral<T, false, boolean> : false : false;
509
+ type EndsWith<TValue extends string, TEndsWith extends string> = IsStringLiteral<TEndsWith> extends true ? IsStringLiteral<TValue> extends true ? TValue extends `${string}${TEndsWith}` ? true : false : boolean : boolean;
510
+ /**
511
+ * **IfEndsWith**<TValue, TEndsWith, IF, ELSE, MAYBE>
512
+ *
513
+ * Type utility which converts type to `IF` type _if_ `TValue` _ends with_ `TEndsWith` but
514
+ * otherwise converts type to `ELSE`. If there are wide types in the mix then the type will
515
+ * result in the union of IF and ELSE.
516
+ */
517
+ type IfEndsWith<TValue extends string, TEndsWith extends string, IF extends Narrowable, ELSE extends Narrowable> = EndsWith<TValue, TEndsWith> extends true ? IF : EndsWith<TValue, TEndsWith> extends false ? ELSE : IF | ELSE;
518
+
519
+ /**
520
+ * **Or**`<T>`
521
+ *
522
+ * Takes an array of boolean values and produces a boolean OR across these values
523
+ */
524
+ type Or<T extends readonly boolean[]> = NarrowlyContains<true, T> extends true ? true : NarrowlyContains<boolean, T> extends true ? boolean : false;
386
525
 
387
526
  /**
388
527
  * Makes a readonly structure mutable
@@ -1212,14 +1351,6 @@ O extends (...args: any[]) => any = (...args: any[]) => any> = SimplifyObject<{
1212
1351
  [K in keyof T]: T[K] extends O ? T[K] extends (...args: infer A) => any ? Record<K, (...args: A) => R> : Record<K, T[K]> : Record<K, T[K]>;
1213
1352
  }[keyof T]>;
1214
1353
 
1215
- /**
1216
- * Get the type of a property of an object:
1217
- * ```ts
1218
- * const car = { make: "Chevy", model: "Malibu", }
1219
- * ```
1220
- */
1221
- type Get<T, K> = K extends `${infer FK}.${infer L}` ? FK extends keyof T ? Get<T[FK], L> : never : K extends keyof T ? T[K] : never;
1222
-
1223
1354
  /**
1224
1355
  * Expresses whether an option is "opt" (optional) or "req" (required)
1225
1356
  */
@@ -1544,7 +1675,7 @@ type FinalReturn<T extends any> = T extends (...args: any[]) => any ? FinalRetur
1544
1675
  /**
1545
1676
  * A function which returns a boolean value
1546
1677
  */
1547
- type LogicFunction<T extends any[]> = (...args: T) => boolean;
1678
+ type LogicFunction<T extends readonly any[]> = (...args: T) => boolean;
1548
1679
 
1549
1680
  type DictFromKv<T extends readonly {
1550
1681
  key: string;
@@ -1593,39 +1724,6 @@ type KvFrom<T extends object> = Array<{
1593
1724
  */
1594
1725
  type KvTuple<T, K extends keyof T> = [K, Record<K, T[K]>];
1595
1726
 
1596
- /**
1597
- * **AfterFirst**`<T>`
1598
- *
1599
- * returns the elements in an array _after_ the first element
1600
- */
1601
- type AfterFirst<T extends readonly any[]> = T extends readonly [any, ...any[]] ? T extends readonly [any, ...infer Rest] ? Rest : never : T;
1602
-
1603
- /**
1604
- * returns the first `string` value from an array of values
1605
- */
1606
- type FirstString<T> = T extends [infer S extends string, ...unknown[]] ? S : never;
1607
-
1608
- /**
1609
- * **Split**`<T, SEP>`
1610
- *
1611
- * Splits a string literal `T` by string literal _separator_ `SEP`. The result is an array
1612
- * of string literals.
1613
- */
1614
- type Split<T extends string, SEP extends string, ANSWER extends string[] = []> = string extends T ? string[] : T extends SEP ? ANSWER : T extends `${infer HEAD}${SEP}${infer TAIL}` ? Split<TAIL, SEP, [...ANSWER, HEAD]> : [...ANSWER, T];
1615
-
1616
- /**
1617
- * Create a union type based on a given property in an array of objects
1618
- * ```ts
1619
- * const data = [
1620
- * { id: 123, color: "blue" },
1621
- * { id: 456, color: "red" },
1622
- * ] as const;
1623
- * // 123 | 456
1624
- * type U = UniqueForProp<typeof data, "id">;
1625
- * ```
1626
- */
1627
- type UniqueForProp<T extends readonly Record<string, Narrowable>[], P extends string> = Readonly<Get<T[number], P>>;
1628
-
1629
1727
  type DictArrayFilterCallback<K extends keyof T, T extends object, R extends true | false> = (key: K, value: Pick<T, K>) => R;
1630
1728
  /**
1631
1729
  * An element in a `DictArray` shaped as a two element tuple: `[key, kv]`.
@@ -1738,13 +1836,7 @@ declare const api: <N extends Narrowable, TPrivate extends Readonly<Record<any,
1738
1836
  */
1739
1837
  declare const and: <T extends any[]>(...ops: readonly LogicFunction<T>[]) => LogicFunction<T>;
1740
1838
 
1741
- /**
1742
- * Groups a number of "logic functions" together by combining their results using
1743
- * the logical **OR** operator.
1744
- *
1745
- * **Note:** a "logic function" is any function which returns a boolean
1746
- */
1747
- declare const or: <T extends any[]>(...ops: LogicFunction<T>[]) => LogicFunction<T>;
1839
+ declare function or<O extends readonly boolean[]>(...conditions: O): Or<O>;
1748
1840
 
1749
1841
  /**
1750
1842
  * Groups a number of "logic functions" together by combining their results using
@@ -2165,10 +2257,15 @@ type SuggestNumeric<T extends number> = T | (number & {});
2165
2257
  type Condition<TInput extends Narrowable, TResult extends boolean> = (input: TInput) => TResult;
2166
2258
  declare const condition: <TInput extends Narrowable, C extends Condition<Narrowable, boolean>>(c: C, input: TInput) => boolean;
2167
2259
 
2168
- type IsArray<T> = T extends any[] ? true : false;
2169
2260
  declare function isArray<T>(i: T): IsArray<T>;
2261
+ /**
2262
+ * **ifArray**(T, IF, ELSE)
2263
+ *
2264
+ * A utility which evaluates a type `T` for whether it is an array and then
2265
+ */
2266
+ declare function ifArray<T extends Narrowable, IF extends Narrowable, ELSE extends Narrowable>(val: T, isAnArray: <N extends T & readonly any[]>(arr: N) => IF, isNotAnArray: <N extends Exclude<T, any[]>>(nonArr: N) => ELSE): IfArray<T, IF, ELSE>;
2267
+ declare function ifArrayPartial<T extends Narrowable>(): <IF extends Narrowable, ELSE extends Narrowable>(isAnArray: <N extends T & readonly any[]>(arr: N) => IF, isNotAnArray: <N_1 extends Exclude<T, any[]>>(nonArr: N_1) => ELSE) => <V extends T>(val: V) => IfArray<V, IF, ELSE>;
2170
2268
 
2171
- type IsBoolean<T> = T extends boolean ? true : false;
2172
2269
  /**
2173
2270
  * Runtime and type checks whether a variable is a boolean value.
2174
2271
  */
@@ -2186,8 +2283,23 @@ declare function isBoolean<T extends any>(i: T): IsBoolean<T>;
2186
2283
  */
2187
2284
  declare function ifBoolean<T, IF, ELSE>(val: T, ifVal: IF, elseVal: ELSE): IsBoolean<T> extends true ? IF : ELSE;
2188
2285
 
2189
- type IsFalse<T extends Narrowable> = IsBoolean<T> extends true ? T extends false ? true : true extends T ? false : unknown : false;
2190
2286
  declare function isFalse<T>(i: T): IsFalse<T>;
2287
+ /**
2288
+ * **ifTrue**
2289
+ *
2290
+ * Strongly type-aware conditional statement which checks whether a value is
2291
+ * a _true_ and returns one of two values (strongly typed) based on the evaluation
2292
+ * of this criteria.
2293
+ *
2294
+ * @param val the value being tested
2295
+ * @param ifVal the value (strongly typed) returned if val is _true_ value
2296
+ * @param elseVal the value (strongly typed) returned if val is NOT a _true_ value
2297
+ *
2298
+ * Note: at runtime there's no way to distinguish if the value was widely or loosely
2299
+ * typed so unlike the type utility there is no "MAYBE" state but if a wide type if
2300
+ * encountered the _type_ will the union of `IF` and `ELSE`.
2301
+ */
2302
+ declare function ifFalse<T extends boolean, IF extends Narrowable, ELSE extends Narrowable>(val: T, ifVal: IF, elseVal: ELSE): IfFalse<T, IF, ELSE, IF | ELSE>;
2191
2303
 
2192
2304
  type IsFunction<T> = T extends FunctionType ? true : false;
2193
2305
  type HybridFunction<TProps extends {}> = (<TArgs extends any[]>(...args: TArgs) => any) & TProps;
@@ -2260,7 +2372,7 @@ type IsString<T> = T extends string ? true : false;
2260
2372
  * returns `IF` type if it is, otherwise returns the type `ELSE`.
2261
2373
  */
2262
2374
  type IfString<T extends Narrowable, //
2263
- IF extends Narrowable, ELSE extends Narrowable> = IsString<T> extends true ? IF : ELSE;
2375
+ IF extends Narrowable, ELSE extends Narrowable> = IsString<T> extends true ? IF : IsString<T> extends false ? ELSE : IF | ELSE;
2264
2376
 
2265
2377
  /**
2266
2378
  * **isString**
@@ -2287,20 +2399,6 @@ declare function ifString<T extends Narrowable, IF extends Narrowable, ELSE exte
2287
2399
 
2288
2400
  declare function isSymbol<T>(i: T): T extends symbol ? true : false;
2289
2401
 
2290
- /**
2291
- * Type utility which returns `true` or `false` based on
2292
- * whether the type holds the narrow "true" type.
2293
- * ```ts
2294
- * // true
2295
- * type T = IsTrue<true>;
2296
- * // unknown
2297
- * type U = IsTrue<boolean>;
2298
- * // false
2299
- * type F = IsTrue<false>;
2300
- * type F2 = IsTrue<"false">;
2301
- * ```
2302
- */
2303
- type IsTrue<T> = IsBoolean<T> extends true ? T extends true ? true : T extends false ? false : unknown : false;
2304
2402
  /**
2305
2403
  * Run-time and type checking of whether a variable is `true`.
2306
2404
  */
@@ -2309,14 +2407,17 @@ declare function isTrue<T extends Narrowable>(i: T): IsTrue<T>;
2309
2407
  * **ifTrue**
2310
2408
  *
2311
2409
  * Strongly type-aware conditional statement which checks whether a value is
2312
- * a _true_ and returns one of two values (strongly typed) based on the evaluation
2313
- * of this criteria.
2410
+ * _true_.
2314
2411
  *
2315
2412
  * @param val the value being tested
2316
2413
  * @param ifVal the value (strongly typed) returned if val is _true_ value
2317
2414
  * @param elseVal the value (strongly typed) returned if val is NOT a _true_ value
2415
+ *
2416
+ * Note: at runtime there's no way to distinguish if the value was widely or loosely
2417
+ * typed so unlike the type utility there is no "MAYBE" state but if a wide type if
2418
+ * encountered the _type_ will the union of `IF` and `ELSE`.
2318
2419
  */
2319
- declare function ifTrue<T extends Narrowable, IF, ELSE>(val: T, ifVal: IF, elseVal: ELSE): IsTrue<T> extends true ? IF : ELSE;
2420
+ declare function ifTrue<T extends boolean, IF extends Narrowable, ELSE extends Narrowable>(val: T, ifVal: IF, elseVal: ELSE): IfTrue<T, IF, ELSE, IF | ELSE>;
2320
2421
 
2321
2422
  declare function isUndefined<T extends Narrowable>(i: T): undefined extends T ? true : false;
2322
2423
  /**
@@ -2440,4 +2541,4 @@ interface IFluentConfigurator<C> {
2440
2541
  */
2441
2542
  declare function FluentConfigurator<I>(initial?: I): IFluentConfigurator<{}>;
2442
2543
 
2443
- export { AfterFirst, AllCaps, Alpha, AlphaNumeric, AnyFunction, Api, ApiFunction, ApiValue, AppendToDictionary, AppendToObject, ArrConcat, Array$1 as Array, ArrayConverter, AsArray, AsFinalizedConfig, AssertExtends, Box, BoxValue, BoxedFnParams, BoxedReturn, Bracket, Break, CamelCase, CapitalizeWords, Cardinality, Cardinality0, Cardinality1, CardinalityExplicit, CardinalityFilter0, CardinalityFilter1, CardinalityIn, CardinalityInput, CardinalityNode, CardinalityOut, CardinalityTuple, ClosingBracket, Condition, ConditionFilter, Configurator, ConfiguredMap, Constructor, DEFAULT_MANY_TO_ONE_MAPPING, DEFAULT_ONE_TO_MANY_MAPPING, DEFAULT_ONE_TO_ONE_MAPPING, DashToSnake, DashUppercase, Dasherize, DecomposeMapConfig, DefaultManyToOneMapping, DefaultOneToManyMapping, DefaultOneToOneMapping, DefinePropertiesApi, DictArrApi, DictArray, DictArrayFilterCallback, DictArrayKv, DictChangeValue, DictFromKv, DictKvTuple, DictPartialApplication, DictPrependWithFn, DictReturnValues, DomainName, DynamicRule, DynamicRuleSet, Email, EndsWith, EnumValues, ExpandRecursively, ExpectExtends, ExplicitFunction, Extends, FilterContains, FilterDefn, FilterEnds, FilterEquals, FilterFn, FilterGreaterThan, FilterIs, FilterLessThan, FilterNotEqual, FilterStarts, FinalReturn, FinalizedMapConfig, First, FirstKey, FirstKeyValue, FirstOfEach, FirstOrUndefined, FirstString, FluentConfigurator, FluentFunction, FnShape, FromDictArray, FullyQualifiedUrl, FunctionType, GeneralDictionary, Get, HasUppercase, HybridFunction, IConfigurator, IFluentConfigurator, If, IfBooleanLiteral, IfExtends, IfExtendsThen, IfLiteral, IfNumericLiteral, IfObject, IfOptionalLiteral, IfScalar, IfStartsWith, IfStringLiteral, IfUndefined, Include, Includes, IntersectingKeys, Ipv4, IsArray, IsBoolean, IsBooleanLiteral, IsCapitalized, IsFalse, IsFunction, IsLiteral, IsNull, IsNumber, IsNumericLiteral, IsObject, IsOptionalLiteral, IsScalar, IsStringLiteral, IsTrue, IsUndefined, KebabCase, KeyValue, KeyedRecord, Keys, KeysWithValue, KvFrom, KvTuple, LastInUnion, LeftWhitespace, Length, LogicFunction, LogicalCombinator, LowerAllCaps, LowerAlpha, ManyToMany, ManyToOne, ManyToZero, MapCard, MapCardinality, MapCardinalityFrom, MapCardinalityIllustrated, MapConfig, MapFn, MapFnInput, MapFnOutput, MapIR, MapInput, MapInputFrom, MapOR, MapOutput, MapOutputFrom, MapTo, Mapper, MapperApi, MaybeFalse, MaybeTrue, Mutable, MutableProps, NarrowBox, Narrowable, NetworkProtocol, NonAlpha, NonNumericKeys, NonStringKeys, Not, NotFilter, Numeric, NumericFilter, NumericKeys, NumericString, ObjectType, OneToMany, OneToOne, OneToZero, Opaque, OpeningBracket, OptRequired, OptionalKeys, OptionalProps, Parenthesis, PascalCase, Pluralize, PrivateKey, PrivateKeys, PublicKeys, Punctuation, PureFluentApi, RelativeUrl, Replace, RequireProps, RequiredKeys, RequiredProps, Retain, RightWhitespace, RuleDefinition, RuntimeProp, RuntimeType, SameKeys, SecondOfEach, SimpleFunction, SimplifyObject, SnakeCase, SpecialCharacters, Split, StartsWith, StringDelimiter, StringFilter, StringKeys, StringLength, Suggest, SuggestNumeric, ToFluent, Transformer, Trim, TrimLeft, TrimRight, TupleToUnion, Type, TypeApi, TypeDefault, TypeDefinition, TypeGuard, TypeOptions, Unbox, UndefinedArrayIsUnknown, UndefinedTreatment, UndefinedValue, UnionToIntersection, UnionToTuple, UniqueDictionary, UniqueForProp, Uniqueness, UnwrapNot, UpperAlpha, UrlBuilder, VariableName, Where, WhereNot, Whitespace, Widen, WithNumericKeys, WithStringKeys, WithValue, ZeroToMany, ZeroToOne, ZeroToZero, ZipCode, and, api, arrayToKeyLookup, arrayToObject, asArray, box, condition, createFnWithProps, defineProperties, defineType, dictArr, dictToKv, dictionaryTransform, entries, filter, filterDictArray, fnWithProps, groupBy, idLiteral, idTypeGuard, identity, ifBoolean, ifNull, ifNumber, ifString, ifTrue, ifUndefined, isArray, isBoolean, isBox, isFalse, isFunction, isNotFilter, isNull, isNumber, isNumericFilter, isObject, isString, isSymbol, isTrue, isType, isUndefined, keys, kindLiteral, kv, kvToDict, literal, mapTo, mapToDict, mapToFn, mapValues, nameLiteral, not, or, readonlyFnWithProps, ruleSet, strArrayToDict, type, typeApi, unbox, withValue };
2544
+ export { AfterFirst, AllCaps, Alpha, AlphaNumeric, AnyFunction, Api, ApiFunction, ApiValue, AppendToDictionary, AppendToObject, ArrConcat, Array$1 as Array, ArrayConverter, AsArray, AsFinalizedConfig, AssertExtends, Box, BoxValue, BoxedFnParams, BoxedReturn, Bracket, Break, CamelCase, CapitalizeWords, Cardinality, Cardinality0, Cardinality1, CardinalityExplicit, CardinalityFilter0, CardinalityFilter1, CardinalityIn, CardinalityInput, CardinalityNode, CardinalityOut, CardinalityTuple, ClosingBracket, Condition, ConditionFilter, Configurator, ConfiguredMap, Constructor, Contains, DEFAULT_MANY_TO_ONE_MAPPING, DEFAULT_ONE_TO_MANY_MAPPING, DEFAULT_ONE_TO_ONE_MAPPING, DashToSnake, DashUppercase, Dasherize, DecomposeMapConfig, DefaultManyToOneMapping, DefaultOneToManyMapping, DefaultOneToOneMapping, DefinePropertiesApi, DictArrApi, DictArray, DictArrayFilterCallback, DictArrayKv, DictChangeValue, DictFromKv, DictKvTuple, DictPartialApplication, DictPrependWithFn, DictReturnValues, DomainName, DynamicRule, DynamicRuleSet, Email, EndsWith, EnumValues, Equal, ExpandRecursively, ExpectExtends, ExplicitFunction, Extends, FilterContains, FilterDefn, FilterEnds, FilterEquals, FilterFn, FilterGreaterThan, FilterIs, FilterLessThan, FilterNotEqual, FilterStarts, FilterTuple, FinalReturn, FinalizedMapConfig, First, FirstKey, FirstKeyValue, FirstOfEach, FirstOrUndefined, FirstString, FluentConfigurator, FluentFunction, FnShape, FromDictArray, FullyQualifiedUrl, FunctionType, GeneralDictionary, Get, HasUppercase, HybridFunction, IConfigurator, IFluentConfigurator, If, IfArray, IfBooleanLiteral, IfEndsWith, IfExtends, IfExtendsThen, IfFalse, IfLiteral, IfNumericLiteral, IfObject, IfOptionalLiteral, IfReadonlyArray, IfScalar, IfStartsWith, IfStringLiteral, IfTrue, IfUndefined, Include, Includes, IntersectingKeys, Ipv4, IsArray, IsBoolean, IsBooleanLiteral, IsCapitalized, IsFalse, IsFunction, IsLiteral, IsNull, IsNumber, IsNumericLiteral, IsObject, IsOptionalLiteral, IsReadonlyArray, IsScalar, IsStringLiteral, IsTrue, IsUndefined, KebabCase, KeyValue, KeyedRecord, Keys, KeysWithValue, KvFrom, KvTuple, LastInUnion, LeftWhitespace, Length, LogicFunction, LogicalCombinator, LowerAllCaps, LowerAlpha, ManyToMany, ManyToOne, ManyToZero, MapCard, MapCardinality, MapCardinalityFrom, MapCardinalityIllustrated, MapConfig, MapFn, MapFnInput, MapFnOutput, MapIR, MapInput, MapInputFrom, MapOR, MapOutput, MapOutputFrom, MapTo, Mapper, MapperApi, MaybeFalse, MaybeTrue, Mutable, MutableProps, NarrowBox, Narrowable, NarrowlyContains, NetworkProtocol, NonAlpha, NonNumericKeys, NonStringKeys, Not, NotEqual, NotFilter, Numeric, NumericFilter, NumericKeys, NumericString, ObjectType, OneToMany, OneToOne, OneToZero, Opaque, OpeningBracket, OptRequired, OptionalKeys, OptionalProps, Or, Parenthesis, PascalCase, Pluralize, PrivateKey, PrivateKeys, PublicKeys, Punctuation, PureFluentApi, RelativeUrl, Replace, RequireProps, RequiredKeys, RequiredProps, Retain, RightWhitespace, RuleDefinition, RuntimeProp, RuntimeType, SameKeys, SecondOfEach, SimpleFunction, SimplifyObject, SnakeCase, SpecialCharacters, Split, StartsWith, StringDelimiter, StringFilter, StringKeys, StringLength, Suggest, SuggestNumeric, ToFluent, Transformer, Trim, TrimLeft, TrimRight, TupleToUnion, Type, TypeApi, TypeDefault, TypeDefinition, TypeGuard, TypeOptions, Unbox, UndefinedArrayIsUnknown, UndefinedTreatment, UndefinedValue, UnionToIntersection, UnionToTuple, UniqueDictionary, UniqueForProp, Uniqueness, UnwrapNot, UpperAlpha, UrlBuilder, VariableName, Where, WhereNot, Whitespace, Widen, WithNumericKeys, WithStringKeys, WithValue, ZeroToMany, ZeroToOne, ZeroToZero, ZipCode, and, api, arrayToKeyLookup, arrayToObject, asArray, box, condition, createFnWithProps, defineProperties, defineType, dictArr, dictToKv, dictionaryTransform, entries, filter, filterDictArray, fnWithProps, groupBy, idLiteral, idTypeGuard, identity, ifArray, ifArrayPartial, ifBoolean, ifFalse, ifNull, ifNumber, ifString, ifTrue, ifUndefined, isArray, isBoolean, isBox, isFalse, isFunction, isNotFilter, isNull, isNumber, isNumericFilter, isObject, isString, isSymbol, isTrue, isType, isUndefined, keys, kindLiteral, kv, kvToDict, literal, mapTo, mapToDict, mapToFn, mapValues, nameLiteral, not, or, readonlyFnWithProps, ruleSet, strArrayToDict, type, typeApi, unbox, withValue };
package/dist/index.js CHANGED
@@ -48,7 +48,10 @@ __export(src_exports, {
48
48
  idLiteral: () => idLiteral,
49
49
  idTypeGuard: () => idTypeGuard,
50
50
  identity: () => identity,
51
+ ifArray: () => ifArray,
52
+ ifArrayPartial: () => ifArrayPartial,
51
53
  ifBoolean: () => ifBoolean,
54
+ ifFalse: () => ifFalse,
52
55
  ifNull: () => ifNull,
53
56
  ifNumber: () => ifNumber,
54
57
  ifString: () => ifString,
@@ -151,12 +154,9 @@ var and = (...ops) => {
151
154
  };
152
155
 
153
156
  // src/runtime/combinators/or.ts
154
- var or = (...ops) => {
155
- const fn = (...args) => {
156
- return [...ops].some((i) => i(...args));
157
- };
158
- return fn;
159
- };
157
+ function or(...conditions) {
158
+ return conditions.some((v) => v === true) ? true : false;
159
+ }
160
160
 
161
161
  // src/runtime/combinators/not.ts
162
162
  var not = (op) => {
@@ -175,6 +175,14 @@ var condition = (c, input) => {
175
175
  function isArray(i) {
176
176
  return Array.isArray(i) === true;
177
177
  }
178
+ function ifArray(val, isAnArray, isNotAnArray) {
179
+ return isArray(val) ? isAnArray(val) : isNotAnArray(val);
180
+ }
181
+ function ifArrayPartial() {
182
+ return (isAnArray, isNotAnArray) => {
183
+ return (val) => ifArray(val, isAnArray, isNotAnArray);
184
+ };
185
+ }
178
186
 
179
187
  // src/runtime/type-checks/isBoolean.ts
180
188
  function isBoolean(i) {
@@ -188,6 +196,9 @@ function ifBoolean(val, ifVal, elseVal) {
188
196
  function isFalse(i) {
189
197
  return typeof i === "boolean" && !i;
190
198
  }
199
+ function ifFalse(val, ifVal, elseVal) {
200
+ return isFalse(val) ? ifVal : elseVal;
201
+ }
191
202
 
192
203
  // src/runtime/type-checks/isFunction.ts
193
204
  function isFunction(input) {
@@ -795,7 +806,10 @@ function literal(obj) {
795
806
  idLiteral,
796
807
  idTypeGuard,
797
808
  identity,
809
+ ifArray,
810
+ ifArrayPartial,
798
811
  ifBoolean,
812
+ ifFalse,
799
813
  ifNull,
800
814
  ifNumber,
801
815
  ifString,
package/dist/index.mjs CHANGED
@@ -58,12 +58,9 @@ var and = (...ops) => {
58
58
  };
59
59
 
60
60
  // src/runtime/combinators/or.ts
61
- var or = (...ops) => {
62
- const fn = (...args) => {
63
- return [...ops].some((i) => i(...args));
64
- };
65
- return fn;
66
- };
61
+ function or(...conditions) {
62
+ return conditions.some((v) => v === true) ? true : false;
63
+ }
67
64
 
68
65
  // src/runtime/combinators/not.ts
69
66
  var not = (op) => {
@@ -82,6 +79,14 @@ var condition = (c, input) => {
82
79
  function isArray(i) {
83
80
  return Array.isArray(i) === true;
84
81
  }
82
+ function ifArray(val, isAnArray, isNotAnArray) {
83
+ return isArray(val) ? isAnArray(val) : isNotAnArray(val);
84
+ }
85
+ function ifArrayPartial() {
86
+ return (isAnArray, isNotAnArray) => {
87
+ return (val) => ifArray(val, isAnArray, isNotAnArray);
88
+ };
89
+ }
85
90
 
86
91
  // src/runtime/type-checks/isBoolean.ts
87
92
  function isBoolean(i) {
@@ -95,6 +100,9 @@ function ifBoolean(val, ifVal, elseVal) {
95
100
  function isFalse(i) {
96
101
  return typeof i === "boolean" && !i;
97
102
  }
103
+ function ifFalse(val, ifVal, elseVal) {
104
+ return isFalse(val) ? ifVal : elseVal;
105
+ }
98
106
 
99
107
  // src/runtime/type-checks/isFunction.ts
100
108
  function isFunction(input) {
@@ -701,7 +709,10 @@ export {
701
709
  idLiteral,
702
710
  idTypeGuard,
703
711
  identity,
712
+ ifArray,
713
+ ifArrayPartial,
704
714
  ifBoolean,
715
+ ifFalse,
705
716
  ifNull,
706
717
  ifNumber,
707
718
  ifString,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "inferred-types",
3
- "version": "0.33.4",
3
+ "version": "0.34.2",
4
4
  "description": "Functions which provide useful type inference on TS projects",
5
5
  "license": "MIT",
6
6
  "author": "Ken Snyder<ken@ken.net>",
@@ -22,11 +22,11 @@
22
22
  "watch:bundle": "npx tsup src/index.ts --dts --format=esm,cjs --watch",
23
23
  "clean": "rimraf dist/**/*",
24
24
  "lint": "eslint src/**/*.ts --fix && tsc --noEmit ",
25
- "lint:full": "eslint src/**/*.ts && eslint test/**/*.ts && tsc --noEmit",
25
+ "lint:full": "eslint src/**/*.ts && eslint tests/**/*.ts && tsc --noEmit",
26
26
  "test": "vitest",
27
27
  "test:ci": "vitest run",
28
28
  "audit:fix": "pnpm audit --fix",
29
- "release": "run-s lint release:latest test:ci audit:fix release:bump",
29
+ "release": "run-s lint:full release:latest test:ci audit:fix release:bump",
30
30
  "release:latest": "pnpm install",
31
31
  "release:bump": "bumpp"
32
32
  },