@solid-primitives/utils 7.0.0-next.3 → 7.0.0-next.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/README.md +13 -0
- package/dist/colors/helpers.d.ts +41 -43
- package/dist/colors/helpers.js +6 -8
- package/dist/colors/intl.d.ts +16 -17
- package/dist/colors/manipulation.d.ts +131 -133
- package/dist/colors/types.d.ts +24 -26
- package/dist/immutable/array.d.ts +105 -106
- package/dist/immutable/copy.d.ts +22 -23
- package/dist/immutable/number.d.ts +8 -9
- package/dist/immutable/object.d.ts +52 -52
- package/dist/immutable/types.d.ts +6 -6
- package/dist/immutable/update.d.ts +23 -25
- package/dist/index.d.ts +248 -229
- package/dist/index.js +28 -3
- package/dist/types.d.ts +53 -55
- package/package.json +7 -7
package/dist/types.d.ts
CHANGED
|
@@ -1,79 +1,77 @@
|
|
|
1
1
|
/* @ts-self-types="./types.d.ts" */
|
|
2
2
|
import { Accessor, Setter } from "solid-js";
|
|
3
|
-
|
|
4
3
|
//#region src/types.d.ts
|
|
5
4
|
/**
|
|
6
|
-
* Can be single or in an array
|
|
7
|
-
*/
|
|
8
|
-
type Many<T> = T | T[];
|
|
9
|
-
type Values<O extends Object> = O[keyof O];
|
|
10
|
-
type Noop = (...a: any[]) => void;
|
|
11
|
-
type Directive<P = true> = (el: Element, props: Accessor<P>) => void;
|
|
5
|
+
* Can be single or in an array
|
|
6
|
+
*/
|
|
7
|
+
export type Many<T> = T | T[];
|
|
8
|
+
export type Values<O extends Object> = O[keyof O];
|
|
9
|
+
export type Noop = (...a: any[]) => void;
|
|
10
|
+
export type Directive<P = true> = (el: Element, props: Accessor<P>) => void;
|
|
12
11
|
/**
|
|
13
|
-
* Infers the type of the array elements
|
|
14
|
-
*/
|
|
15
|
-
type ItemsOf<T> = T extends (infer E)[] ? E : never;
|
|
16
|
-
type ItemsOfMany<T> = T extends any[] ? ItemsOf<T> : T;
|
|
17
|
-
type SetterParam<T> = Parameters<Setter<T>>[0];
|
|
12
|
+
* Infers the type of the array elements
|
|
13
|
+
*/
|
|
14
|
+
export type ItemsOf<T> = T extends (infer E)[] ? E : never;
|
|
15
|
+
export type ItemsOfMany<T> = T extends any[] ? ItemsOf<T> : T;
|
|
16
|
+
export type SetterParam<T> = Parameters<Setter<T>>[0];
|
|
18
17
|
/**
|
|
19
|
-
* T or a reactive/non-reactive function returning T
|
|
20
|
-
*/
|
|
21
|
-
type MaybeAccessor<T> = T | Accessor<T>;
|
|
18
|
+
* T or a reactive/non-reactive function returning T
|
|
19
|
+
*/
|
|
20
|
+
export type MaybeAccessor<T> = T | Accessor<T>;
|
|
22
21
|
/**
|
|
23
|
-
* Accessed value of a MaybeAccessor
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* MaybeAccessorValue<MaybeAccessor<string>>
|
|
27
|
-
* // => string
|
|
28
|
-
* MaybeAccessorValue<MaybeAccessor<() => string>>
|
|
29
|
-
* // => string | (() => string)
|
|
30
|
-
* MaybeAccessorValue<MaybeAccessor<string> | Function>
|
|
31
|
-
* // => string | void
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
type MaybeAccessorValue<T extends MaybeAccessor<any>> = T extends (() => any) ? ReturnType<T> : T;
|
|
35
|
-
type AccessorArray<T> = [...Extract<{ [K in keyof T]: Accessor<T[K]
|
|
36
|
-
type OnAccessEffectFunction<S, Prev, Next extends Prev = Prev> = (input: AccessReturnTypes<S>, prevInput: AccessReturnTypes<S>, v: Prev) => Next;
|
|
37
|
-
type AccessReturnTypes<S> = S extends MaybeAccessor<any>[] ? { [I in keyof S]: AccessReturnTypes<S[I]
|
|
22
|
+
* Accessed value of a MaybeAccessor
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* MaybeAccessorValue<MaybeAccessor<string>>
|
|
26
|
+
* // => string
|
|
27
|
+
* MaybeAccessorValue<MaybeAccessor<() => string>>
|
|
28
|
+
* // => string | (() => string)
|
|
29
|
+
* MaybeAccessorValue<MaybeAccessor<string> | Function>
|
|
30
|
+
* // => string | void
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export type MaybeAccessorValue<T extends MaybeAccessor<any>> = T extends (() => any) ? ReturnType<T> : T;
|
|
34
|
+
export type AccessorArray<T> = [...Extract<{ [K in keyof T]: Accessor<T[K]>; }, readonly unknown[]>];
|
|
35
|
+
export type OnAccessEffectFunction<S, Prev, Next extends Prev = Prev> = (input: AccessReturnTypes<S>, prevInput: AccessReturnTypes<S>, v: Prev) => Next;
|
|
36
|
+
export type AccessReturnTypes<S> = S extends MaybeAccessor<any>[] ? { [I in keyof S]: AccessReturnTypes<S[I]>; } : MaybeAccessorValue<S>;
|
|
38
37
|
/** Allows to make shallow overwrites to an interface */
|
|
39
|
-
type Modify<T, R> = Omit<T, keyof R> & R;
|
|
38
|
+
export type Modify<T, R> = Omit<T, keyof R> & R;
|
|
40
39
|
/** Allows to make nested overwrites to an interface */
|
|
41
|
-
type ModifyDeep<A extends AnyObject, B extends DeepPartialAny<A>> = { [K in keyof A]: B[K] extends never ? A[K] : B[K] extends AnyObject ? ModifyDeep<A[K], B[K]> : B[K] } & (A extends AnyObject ? Omit<B, keyof A> : A);
|
|
40
|
+
export type ModifyDeep<A extends AnyObject, B extends DeepPartialAny<A>> = { [K in keyof A]: B[K] extends never ? A[K] : B[K] extends AnyObject ? ModifyDeep<A[K], B[K]> : B[K]; } & (A extends AnyObject ? Omit<B, keyof A> : A);
|
|
42
41
|
/** Makes each property optional and turns each leaf property into any, allowing for type overrides by narrowing any. */
|
|
43
|
-
type DeepPartialAny<T> = { [P in keyof T]?: T[P] extends AnyObject ? DeepPartialAny<T[P]> : any };
|
|
42
|
+
export type DeepPartialAny<T> = { [P in keyof T]?: T[P] extends AnyObject ? DeepPartialAny<T[P]> : any; };
|
|
44
43
|
/** Removes the `[...list]` functionality */
|
|
45
|
-
type NonIterable<T> = T & {
|
|
44
|
+
export type NonIterable<T> = T & {
|
|
46
45
|
[Symbol.iterator]: never;
|
|
47
46
|
};
|
|
48
47
|
/** Get the required keys of an object */
|
|
49
|
-
type RequiredKeys<T> = keyof { [K in keyof T as T extends { [_ in K]: unknown } ? K : never]: 0 };
|
|
48
|
+
export type RequiredKeys<T> = keyof { [K in keyof T as T extends { [_ in K]: unknown; } ? K : never]: 0; };
|
|
50
49
|
/** Remove the first item of a tuple [1, 2, 3, 4] => [2, 3, 4] */
|
|
51
|
-
type Tail<T extends any[]> = ((...t: T) => void) extends ((x: any, ...u: infer U) => void) ? U : never;
|
|
50
|
+
export type Tail<T extends any[]> = ((...t: T) => void) extends ((x: any, ...u: infer U) => void) ? U : never;
|
|
52
51
|
/** `A | B => A & B` */
|
|
53
|
-
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
54
|
-
type ExtractIfPossible<T, U> = Extract<T, U> extends never ? U : Extract<T, U>;
|
|
55
|
-
type AnyObject = Record<PropertyKey, any>;
|
|
56
|
-
type AnyStatic = [] | any[] | AnyObject;
|
|
57
|
-
type AnyFunction = (...args: any[]) => any;
|
|
58
|
-
type AnyClass = abstract new (...args: any) => any;
|
|
59
|
-
type PrimitiveValue = PropertyKey | boolean | bigint | null | undefined;
|
|
60
|
-
type FalsyValue = false | 0 | "" | null | undefined;
|
|
61
|
-
type Truthy<T> = Exclude<T, FalsyValue>;
|
|
62
|
-
type Falsy<T> = Extract<T, FalsyValue>;
|
|
63
|
-
type Position = {
|
|
52
|
+
export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
53
|
+
export type ExtractIfPossible<T, U> = Extract<T, U> extends never ? U : Extract<T, U>;
|
|
54
|
+
export type AnyObject = Record<PropertyKey, any>;
|
|
55
|
+
export type AnyStatic = [] | any[] | AnyObject;
|
|
56
|
+
export type AnyFunction = (...args: any[]) => any;
|
|
57
|
+
export type AnyClass = abstract new (...args: any) => any;
|
|
58
|
+
export type PrimitiveValue = PropertyKey | boolean | bigint | null | undefined;
|
|
59
|
+
export type FalsyValue = false | 0 | "" | null | undefined;
|
|
60
|
+
export type Truthy<T> = Exclude<T, FalsyValue>;
|
|
61
|
+
export type Falsy<T> = Extract<T, FalsyValue>;
|
|
62
|
+
export type Position = {
|
|
64
63
|
x: number;
|
|
65
64
|
y: number;
|
|
66
65
|
};
|
|
67
|
-
type Size = {
|
|
66
|
+
export type Size = {
|
|
68
67
|
width: number;
|
|
69
68
|
height: number;
|
|
70
69
|
};
|
|
71
70
|
/** Unwraps the type definition of an object, making it more readable */
|
|
72
|
-
type Simplify<T> = T extends object ? { [K in keyof T]: T[K] } : T;
|
|
71
|
+
export type Simplify<T> = T extends object ? { [K in keyof T]: T[K]; } : T;
|
|
73
72
|
/** Unboxes type definition, making it more readable */
|
|
74
|
-
type UnboxLazy<T> = T extends (() => infer U) ? U : T;
|
|
75
|
-
type RawNarrow<T> = (T extends [] ? [] : never) | (T extends string | number | bigint | boolean ? T : never) | { [K in keyof T]: T[K] extends Function ? T[K] : RawNarrow<T[K]
|
|
76
|
-
type Narrow<T> = T extends [] ? T : RawNarrow<T>;
|
|
77
|
-
type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
78
|
-
//#endregion
|
|
79
|
-
export { AccessReturnTypes, AccessorArray, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, Narrow, NoInfer, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, RequiredKeys, SetterParam, Simplify, Size, Tail, Truthy, UnboxLazy, UnionToIntersection, Values };
|
|
73
|
+
export type UnboxLazy<T> = T extends (() => infer U) ? U : T;
|
|
74
|
+
type RawNarrow<T> = (T extends [] ? [] : never) | (T extends string | number | bigint | boolean ? T : never) | { [K in keyof T]: T[K] extends Function ? T[K] : RawNarrow<T[K]>; };
|
|
75
|
+
export type Narrow<T> = T extends [] ? T : RawNarrow<T>;
|
|
76
|
+
export type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
77
|
+
//#endregion
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solid-primitives/utils",
|
|
3
|
-
"version": "7.0.0-next.
|
|
4
|
-
"description": "A bunch of reactive utility types and functions, for building primitives
|
|
3
|
+
"version": "7.0.0-next.7",
|
|
4
|
+
"description": "A bunch of reactive utility types and functions, for building primitives",
|
|
5
5
|
"author": "Damian Tarnawski @thetarnav <gthetarnav@gmail.com>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Tom Pichaud <dev.tompichaud@icloud.com>"
|
|
@@ -134,15 +134,15 @@
|
|
|
134
134
|
"COLOR_INTL_TRANSLATIONS"
|
|
135
135
|
],
|
|
136
136
|
"category": "Utilities",
|
|
137
|
-
"gzip":
|
|
137
|
+
"gzip": 1591
|
|
138
138
|
},
|
|
139
139
|
"peerDependencies": {
|
|
140
|
-
"@solidjs/web": "^2.0.0-
|
|
141
|
-
"solid-js": "^2.0.0-
|
|
140
|
+
"@solidjs/web": "^2.0.0-rc.14",
|
|
141
|
+
"solid-js": "^2.0.0-rc.14"
|
|
142
142
|
},
|
|
143
143
|
"devDependencies": {
|
|
144
|
-
"@solidjs/web": "2.0.0-
|
|
145
|
-
"solid-js": "2.0.0-
|
|
144
|
+
"@solidjs/web": "2.0.0-rc.14",
|
|
145
|
+
"solid-js": "2.0.0-rc.14"
|
|
146
146
|
},
|
|
147
147
|
"scripts": {
|
|
148
148
|
"dev": "node --import=@nothing-but/node-resolve-ts --experimental-transform-types ../../scripts/dev.ts",
|