@solid-primitives/utils 5.2.1 → 5.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.
package/dist/index.cjs CHANGED
@@ -17,9 +17,15 @@ exports.compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
17
17
  exports.arrayEquals = (a, b) => a === b || a.length === b.length && a.every((e, i) => e === b[i]);
18
18
  function chain(callbacks) {
19
19
  return (...args) => {
20
- for (const callback of callbacks) {
21
- if (typeof callback === "function")
22
- callback(...args);
20
+ for (const callback of callbacks)
21
+ callback && callback(...args);
22
+ };
23
+ }
24
+ function reverseChain(callbacks) {
25
+ return (...args) => {
26
+ for (let i = callbacks.length - 1; i >= 0; i--) {
27
+ const callback = callbacks[i];
28
+ callback && callback(...args);
23
29
  }
24
30
  };
25
31
  }
@@ -170,3 +176,4 @@ exports.createStaticStore = createStaticStore;
170
176
  exports.defer = defer;
171
177
  exports.handleDiffArray = handleDiffArray;
172
178
  exports.isObject = isObject;
179
+ exports.reverseChain = reverseChain;
package/dist/index.d.ts CHANGED
@@ -108,6 +108,10 @@ declare const arrayEquals: (a: readonly unknown[], b: readonly unknown[]) => boo
108
108
  declare function chain<Args extends [] | any[]>(callbacks: {
109
109
  [Symbol.iterator](): IterableIterator<((...args: Args) => any) | undefined>;
110
110
  }): (...args: Args) => void;
111
+ /**
112
+ * Returns a function that will call all functions in the reversed order with the same arguments.
113
+ */
114
+ declare function reverseChain<Args extends [] | any[]>(callbacks: (((...args: Args) => any) | undefined)[]): (...args: Args) => void;
111
115
  declare const clamp: (n: number, min: number, max: number) => number;
112
116
  /**
113
117
  * Accesses the value of a MaybeAccessor
@@ -203,4 +207,4 @@ declare function handleDiffArray<T>(current: readonly T[], prev: readonly T[], h
203
207
  */
204
208
  declare function createHydrateSignal<T>(serverValue: T, update: () => T, options?: SignalOptions<T>): Signal<T>;
205
209
 
206
- export { AccessReturnTypes, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, Narrow, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, RequiredKeys, SetterParam, Simplify, StaticStoreSetter, Tail, Truthy, UnboxLazy, UnionToIntersection, Values, access, accessArray, accessWith, arrayEquals, asAccessor, asArray, chain, clamp, compare, createCallbackStack, createHydrateSignal, createMicrotask, createStaticStore, defer, entries, handleDiffArray, isClient, isDev, isObject, isProd, isServer, keys, noop, ofClass, tryOnCleanup, withAccess };
210
+ export { AccessReturnTypes, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, Narrow, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, RequiredKeys, SetterParam, Simplify, StaticStoreSetter, Tail, Truthy, UnboxLazy, UnionToIntersection, Values, access, accessArray, accessWith, arrayEquals, asAccessor, asArray, chain, clamp, compare, createCallbackStack, createHydrateSignal, createMicrotask, createStaticStore, defer, entries, handleDiffArray, isClient, isDev, isObject, isProd, isServer, keys, noop, ofClass, reverseChain, tryOnCleanup, withAccess };
package/dist/index.js CHANGED
@@ -15,9 +15,15 @@ var compare = (a, b) => a < b ? -1 : a > b ? 1 : 0;
15
15
  var arrayEquals = (a, b) => a === b || a.length === b.length && a.every((e, i) => e === b[i]);
16
16
  function chain(callbacks) {
17
17
  return (...args) => {
18
- for (const callback of callbacks) {
19
- if (typeof callback === "function")
20
- callback(...args);
18
+ for (const callback of callbacks)
19
+ callback && callback(...args);
20
+ };
21
+ }
22
+ function reverseChain(callbacks) {
23
+ return (...args) => {
24
+ for (let i = callbacks.length - 1; i >= 0; i--) {
25
+ const callback = callbacks[i];
26
+ callback && callback(...args);
21
27
  }
22
28
  };
23
29
  }
@@ -160,4 +166,4 @@ function createHydrateSignal(serverValue, update, options) {
160
166
  return [state, setState];
161
167
  }
162
168
 
163
- export { access, accessArray, accessWith, arrayEquals, asAccessor, asArray, chain, clamp, compare, createCallbackStack, createHydrateSignal, createMicrotask, createStaticStore, defer, entries, handleDiffArray, isClient, isDev, isObject, isProd, isServer, keys, noop, ofClass, tryOnCleanup, withAccess };
169
+ export { access, accessArray, accessWith, arrayEquals, asAccessor, asArray, chain, clamp, compare, createCallbackStack, createHydrateSignal, createMicrotask, createStaticStore, defer, entries, handleDiffArray, isClient, isDev, isObject, isProd, isServer, keys, noop, ofClass, reverseChain, tryOnCleanup, withAccess };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solid-primitives/utils",
3
- "version": "5.2.1",
3
+ "version": "5.3.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
  "contributors": [