@solid-primitives/utils
Advanced tools
Comparing version 0.0.250 to 0.0.255
@@ -5,2 +5,4 @@ import { Accessor } from 'solid-js'; | ||
declare type Many<T> = T | T[]; | ||
declare type Keys<O extends Object> = keyof O; | ||
declare type Values<O extends Object> = O[Keys<O>]; | ||
/** | ||
@@ -16,4 +18,11 @@ * Infers the element type of an array | ||
declare const withAccess: <T, A extends MaybeAccessor<T>, V = MaybeAccessorValue<A>>(value: A, fn: (value: NonNullable<V>) => void) => void; | ||
declare const forEach: <A extends unknown, V = MaybeAccessorValue<A>>(array: A, iterator: (item: V extends any[] ? ItemsOf<V> : V, index: number, array: V extends any[] ? V : V[]) => void) => void; | ||
declare const entries: <A extends MaybeAccessor<Object>, V = MaybeAccessorValue<A>>(object: A) => [string, Values<V>][]; | ||
declare const promiseTimeout: (ms: number, throwOnTimeout?: boolean, reason?: string) => Promise<void>; | ||
declare const objectOmit: <T extends Object, K extends (keyof T)[]>(object: T, ...keys: K) => Omit<T, ItemsOf<K>>; | ||
declare const createCallbackStack: <Arg0 = void, Arg1 = void, Arg2 = void, Arg3 = void>() => { | ||
push: (...callbacks: Fn[]) => void; | ||
execute: (arg0: Arg0, arg1: Arg1, arg2: Arg2, arg3: Arg3) => void; | ||
clear: Fn; | ||
}; | ||
declare const stringConcat: (...a: MaybeAccessor<any>[]) => string; | ||
@@ -25,2 +34,2 @@ declare const concat: <A extends any[], V = MaybeAccessorValue<ItemsOf<A>>>(...a: A) => (V extends any[] ? ItemsOf<V> : V)[]; | ||
export { Fn, ItemsOf, Many, MaybeAccessor, MaybeAccessorValue, access, accessAsArray, concat, isClient, objectOmit, promiseTimeout, stringConcat, toArray, toFloat, toInt, withAccess }; | ||
export { Fn, ItemsOf, Keys, Many, MaybeAccessor, MaybeAccessorValue, Values, access, accessAsArray, concat, createCallbackStack, entries, forEach, isClient, objectOmit, promiseTimeout, stringConcat, toArray, toFloat, toInt, withAccess }; |
@@ -13,2 +13,4 @@ // src/index.ts | ||
}; | ||
var forEach = (array, iterator) => accessAsArray(array).forEach(iterator); | ||
var entries = (object) => Object.entries(access(object)); | ||
var promiseTimeout = (ms, throwOnTimeout = false, reason = "Timeout") => new Promise((resolve, reject) => throwOnTimeout ? setTimeout(() => reject(reason), ms) : setTimeout(resolve, ms)); | ||
@@ -22,2 +24,14 @@ var objectOmit = (object, ...keys) => { | ||
}; | ||
var createCallbackStack = () => { | ||
let stack = []; | ||
const clear = () => stack = []; | ||
return { | ||
push: (...callbacks) => stack.push(...callbacks), | ||
execute: (arg0, arg1, arg2, arg3) => { | ||
stack.forEach((cb) => cb(arg0, arg1, arg2, arg3)); | ||
clear(); | ||
}, | ||
clear | ||
}; | ||
}; | ||
var stringConcat = (...a) => a.reduce((t, c) => t + access(c), ""); | ||
@@ -35,2 +49,5 @@ var concat = (...a) => a.reduce((t, c) => { | ||
concat, | ||
createCallbackStack, | ||
entries, | ||
forEach, | ||
isClient, | ||
@@ -37,0 +54,0 @@ objectOmit, |
{ | ||
"name": "@solid-primitives/utils", | ||
"version": "0.0.250", | ||
"version": "0.0.255", | ||
"description": "A bunch of reactive utility types and functions, for building primitives with Solid.js", | ||
@@ -5,0 +5,0 @@ "author": "Damian Tarnawski @thetarnav <gthetarnav@gmail.com>", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9023
170
0