@solid-primitives/utils 1.4.0 → 1.5.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.
- package/dist/index.cjs +8 -0
- package/dist/index.d.ts +19 -1
- package/dist/index.js +7 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -38,6 +38,7 @@ __export(src_exports, {
|
|
|
38
38
|
accessWith: () => accessWith,
|
|
39
39
|
asAccessor: () => asAccessor,
|
|
40
40
|
asArray: () => asArray,
|
|
41
|
+
chain: () => chain,
|
|
41
42
|
clamp: () => clamp,
|
|
42
43
|
compare: () => compare,
|
|
43
44
|
createCallbackStack: () => createCallbackStack,
|
|
@@ -75,6 +76,12 @@ function isObject(value) {
|
|
|
75
76
|
return value !== null && (typeof value === "object" || typeof value === "function");
|
|
76
77
|
}
|
|
77
78
|
var compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
79
|
+
function chain(...callbacks) {
|
|
80
|
+
return (...args) => {
|
|
81
|
+
for (const callback of callbacks)
|
|
82
|
+
callback(...args);
|
|
83
|
+
};
|
|
84
|
+
}
|
|
78
85
|
var clamp = (n, min, max) => Math.min(Math.max(n, min), max);
|
|
79
86
|
var access = (v) => typeof v === "function" && !v.length ? v() : v;
|
|
80
87
|
var asArray = (value) => Array.isArray(value) ? value : [value];
|
|
@@ -202,6 +209,7 @@ function createStaticStore(init) {
|
|
|
202
209
|
accessWith,
|
|
203
210
|
asAccessor,
|
|
204
211
|
asArray,
|
|
212
|
+
chain,
|
|
205
213
|
clamp,
|
|
206
214
|
compare,
|
|
207
215
|
createCallbackStack,
|
package/dist/index.d.ts
CHANGED
|
@@ -54,6 +54,20 @@ declare type NonIterable<T> = T & {
|
|
|
54
54
|
declare type Definite<T> = {
|
|
55
55
|
[K in keyof T]-?: T[K];
|
|
56
56
|
};
|
|
57
|
+
/** Unwraps the type definition of an object, making it more readable */
|
|
58
|
+
declare type Simplify<T> = T extends object ? {
|
|
59
|
+
[K in keyof T]: T[K];
|
|
60
|
+
} : T;
|
|
61
|
+
/** Unboxes type definition, making it more readable */
|
|
62
|
+
declare type UnboxLazy<T> = T extends () => infer U ? U : T;
|
|
63
|
+
/** Get the required keys of an object */
|
|
64
|
+
declare type RequiredKeys<T> = keyof {
|
|
65
|
+
[K in keyof T as T extends {
|
|
66
|
+
[_ in K]: unknown;
|
|
67
|
+
} ? K : never]: 0;
|
|
68
|
+
};
|
|
69
|
+
/** Remove the first item of a tuple [1, 2, 3, 4] => [2, 3, 4] */
|
|
70
|
+
declare type Tail<T extends any[]> = ((...t: T) => void) extends (x: any, ...u: infer U) => void ? U : never;
|
|
57
71
|
/** `A | B => A & B` */
|
|
58
72
|
declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
|
|
59
73
|
declare type ExtractIfPossible<T, U> = Extract<T, U> extends never ? U : Extract<T, U>;
|
|
@@ -93,6 +107,10 @@ declare const ofClass: (v: any, c: AnyClass) => boolean;
|
|
|
93
107
|
/** Check if value is typeof "object" or "function" */
|
|
94
108
|
declare function isObject(value: any): value is AnyObject;
|
|
95
109
|
declare const compare: (a: any, b: any) => number;
|
|
110
|
+
/**
|
|
111
|
+
* Returns a function that will call all functions in the order they were chained with the same arguments.
|
|
112
|
+
*/
|
|
113
|
+
declare function chain<Args extends [] | any[]>(...callbacks: ((...args: Args) => any)[]): (...args: Args) => void;
|
|
96
114
|
declare const clamp: (n: number, min: number, max: number) => number;
|
|
97
115
|
/**
|
|
98
116
|
* Accesses the value of a MaybeAccessor
|
|
@@ -236,4 +254,4 @@ declare type StaticStoreSetter<T extends Readonly<AnyStatic>> = {
|
|
|
236
254
|
*/
|
|
237
255
|
declare function createStaticStore<T extends Readonly<AnyStatic>>(init: T): [access: T, write: StaticStoreSetter<T>];
|
|
238
256
|
|
|
239
|
-
export { AccessReturnTypes, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Definite, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, SetterValue, StaticStoreSetter, Trigger, TriggerCache, Truthy, UnionToIntersection, Values, access, accessArray, accessWith, asAccessor, asArray, clamp, compare, createCallbackStack, createMicrotask, createProxy, createStaticStore, createTrigger, createTriggerCache, entries, forEachEntry, isClient, isDev, isObject, isProd, keys, noop, ofClass, onRootCleanup, promiseTimeout, raceTimeout, warn, withAccess };
|
|
257
|
+
export { AccessReturnTypes, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Definite, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, RequiredKeys, SetterValue, Simplify, StaticStoreSetter, Tail, Trigger, TriggerCache, Truthy, UnboxLazy, UnionToIntersection, Values, access, accessArray, accessWith, asAccessor, asArray, chain, clamp, compare, createCallbackStack, createMicrotask, createProxy, createStaticStore, createTrigger, createTriggerCache, entries, forEachEntry, isClient, isDev, isObject, isProd, keys, noop, ofClass, onRootCleanup, promiseTimeout, raceTimeout, warn, withAccess };
|
package/dist/index.js
CHANGED
|
@@ -28,6 +28,12 @@ function isObject(value) {
|
|
|
28
28
|
return value !== null && (typeof value === "object" || typeof value === "function");
|
|
29
29
|
}
|
|
30
30
|
var compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
|
|
31
|
+
function chain(...callbacks) {
|
|
32
|
+
return (...args) => {
|
|
33
|
+
for (const callback of callbacks)
|
|
34
|
+
callback(...args);
|
|
35
|
+
};
|
|
36
|
+
}
|
|
31
37
|
var clamp = (n, min, max) => Math.min(Math.max(n, min), max);
|
|
32
38
|
var access = (v) => typeof v === "function" && !v.length ? v() : v;
|
|
33
39
|
var asArray = (value) => Array.isArray(value) ? value : [value];
|
|
@@ -154,6 +160,7 @@ export {
|
|
|
154
160
|
accessWith,
|
|
155
161
|
asAccessor,
|
|
156
162
|
asArray,
|
|
163
|
+
chain,
|
|
157
164
|
clamp,
|
|
158
165
|
compare,
|
|
159
166
|
createCallbackStack,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solid-primitives/utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "A bunch of reactive utility types and functions, for building primitives with Solid.js",
|
|
5
5
|
"author": "Damian Tarnawski @thetarnav <gthetarnav@gmail.com>",
|
|
6
6
|
"license": "MIT",
|