@solid-primitives/utils 1.4.0 → 1.5.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.
- package/dist/index.cjs +8 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.js +7 -0
- package/package.json +2 -2
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
|
@@ -93,6 +93,10 @@ declare const ofClass: (v: any, c: AnyClass) => boolean;
|
|
|
93
93
|
/** Check if value is typeof "object" or "function" */
|
|
94
94
|
declare function isObject(value: any): value is AnyObject;
|
|
95
95
|
declare const compare: (a: any, b: any) => number;
|
|
96
|
+
/**
|
|
97
|
+
* Returns a function that will call all functions in the order they were chained with the same arguments.
|
|
98
|
+
*/
|
|
99
|
+
declare function chain<Args extends [] | any[]>(...callbacks: ((...args: Args) => any)[]): (...args: Args) => void;
|
|
96
100
|
declare const clamp: (n: number, min: number, max: number) => number;
|
|
97
101
|
/**
|
|
98
102
|
* Accesses the value of a MaybeAccessor
|
|
@@ -236,4 +240,4 @@ declare type StaticStoreSetter<T extends Readonly<AnyStatic>> = {
|
|
|
236
240
|
*/
|
|
237
241
|
declare function createStaticStore<T extends Readonly<AnyStatic>>(init: T): [access: T, write: StaticStoreSetter<T>];
|
|
238
242
|
|
|
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 };
|
|
243
|
+
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, 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.0",
|
|
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",
|
|
@@ -44,4 +44,4 @@
|
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"solid-js": "^1.3.1"
|
|
46
46
|
}
|
|
47
|
-
}
|
|
47
|
+
}
|