@solid-primitives/utils 6.2.3 → 6.3.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.
@@ -1,90 +0,0 @@
1
- import { Accessor, Setter } from 'solid-js';
2
-
3
- /**
4
- * Can be single or in an array
5
- */
6
- type Many<T> = T | T[];
7
- type Values<O extends Object> = O[keyof O];
8
- type Noop = (...a: any[]) => void;
9
- type Directive<P = true> = (el: Element, props: Accessor<P>) => void;
10
- /**
11
- * Infers the type of the array elements
12
- */
13
- type ItemsOf<T> = T extends (infer E)[] ? E : never;
14
- type ItemsOfMany<T> = T extends any[] ? ItemsOf<T> : T;
15
- type SetterParam<T> = Parameters<Setter<T>>[0];
16
- /**
17
- * T or a reactive/non-reactive function returning T
18
- */
19
- type MaybeAccessor<T> = T | Accessor<T>;
20
- /**
21
- * Accessed value of a MaybeAccessor
22
- * @example
23
- * ```ts
24
- * MaybeAccessorValue<MaybeAccessor<string>>
25
- * // => string
26
- * MaybeAccessorValue<MaybeAccessor<() => string>>
27
- * // => string | (() => string)
28
- * MaybeAccessorValue<MaybeAccessor<string> | Function>
29
- * // => string | void
30
- * ```
31
- */
32
- type MaybeAccessorValue<T extends MaybeAccessor<any>> = T extends () => any ? ReturnType<T> : T;
33
- type OnAccessEffectFunction<S, Prev, Next extends Prev = Prev> = (input: AccessReturnTypes<S>, prevInput: AccessReturnTypes<S>, v: Prev) => Next;
34
- type AccessReturnTypes<S> = S extends MaybeAccessor<any>[] ? {
35
- [I in keyof S]: AccessReturnTypes<S[I]>;
36
- } : MaybeAccessorValue<S>;
37
- /** Allows to make shallow overwrites to an interface */
38
- type Modify<T, R> = Omit<T, keyof R> & R;
39
- /** Allows to make nested overwrites to an interface */
40
- type ModifyDeep<A extends AnyObject, B extends DeepPartialAny<A>> = {
41
- [K in keyof A]: B[K] extends never ? A[K] : B[K] extends AnyObject ? ModifyDeep<A[K], B[K]> : B[K];
42
- } & (A extends AnyObject ? Omit<B, keyof A> : A);
43
- /** Makes each property optional and turns each leaf property into any, allowing for type overrides by narrowing any. */
44
- type DeepPartialAny<T> = {
45
- [P in keyof T]?: T[P] extends AnyObject ? DeepPartialAny<T[P]> : any;
46
- };
47
- /** Removes the `[...list]` functionality */
48
- type NonIterable<T> = T & {
49
- [Symbol.iterator]: never;
50
- };
51
- /** Get the required keys of an object */
52
- type RequiredKeys<T> = keyof {
53
- [K in keyof T as T extends {
54
- [_ in K]: unknown;
55
- } ? K : never]: 0;
56
- };
57
- /** Remove the first item of a tuple [1, 2, 3, 4] => [2, 3, 4] */
58
- type Tail<T extends any[]> = ((...t: T) => void) extends (x: any, ...u: infer U) => void ? U : never;
59
- /** `A | B => A & B` */
60
- type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
61
- type ExtractIfPossible<T, U> = Extract<T, U> extends never ? U : Extract<T, U>;
62
- type AnyObject = Record<PropertyKey, any>;
63
- type AnyStatic = [] | any[] | AnyObject;
64
- type AnyFunction = (...args: any[]) => any;
65
- type AnyClass = abstract new (...args: any) => any;
66
- type PrimitiveValue = PropertyKey | boolean | bigint | null | undefined;
67
- type FalsyValue = false | 0 | "" | null | undefined;
68
- type Truthy<T> = Exclude<T, FalsyValue>;
69
- type Falsy<T> = Extract<T, FalsyValue>;
70
- type Position = {
71
- x: number;
72
- y: number;
73
- };
74
- type Size = {
75
- width: number;
76
- height: number;
77
- };
78
- /** Unwraps the type definition of an object, making it more readable */
79
- type Simplify<T> = T extends object ? {
80
- [K in keyof T]: T[K];
81
- } : T;
82
- /** Unboxes type definition, making it more readable */
83
- type UnboxLazy<T> = T extends () => infer U ? U : T;
84
- type RawNarrow<T> = (T extends [] ? [] : never) | (T extends string | number | bigint | boolean ? T : never) | {
85
- [K in keyof T]: T[K] extends Function ? T[K] : RawNarrow<T[K]>;
86
- };
87
- type Narrow<T> = T extends [] ? T : RawNarrow<T>;
88
- type NoInfer<T> = [T][T extends any ? 0 : never];
89
-
90
- export { AnyClass as A, Directive as D, ExtractIfPossible as E, FalsyValue as F, ItemsOf as I, MaybeAccessorValue as M, Noop as N, OnAccessEffectFunction as O, PrimitiveValue as P, RequiredKeys as R, SetterParam as S, Tail as T, UnionToIntersection as U, Values as V, AnyObject as a, MaybeAccessor as b, AnyFunction as c, Many as d, ItemsOfMany as e, AccessReturnTypes as f, Modify as g, ModifyDeep as h, DeepPartialAny as i, NonIterable as j, AnyStatic as k, Truthy as l, Falsy as m, Position as n, Size as o, Simplify as p, UnboxLazy as q, Narrow as r, NoInfer as s };