@solid-primitives/utils
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -10,2 +10,3 @@ import { Accessor, onCleanup } from 'solid-js'; | ||
declare type Fn<R = void> = () => R; | ||
declare type Get<T> = (v: T) => void; | ||
/** | ||
@@ -18,2 +19,3 @@ * Can be single or in an array | ||
declare type Noop = (...a: any[]) => void; | ||
declare type Directive<P = true> = (el: Element, props: Accessor<P>) => void; | ||
/** | ||
@@ -23,2 +25,3 @@ * Infers the type of the array elements | ||
declare type ItemsOf<T> = T extends (infer E)[] ? E : never; | ||
declare type ItemsOfMany<T> = T extends any[] ? ItemsOf<T> : T; | ||
/** | ||
@@ -55,8 +58,13 @@ * T or a reactive/non-reactive function returning T | ||
}; | ||
/** `A | B => A & B` */ | ||
declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never; | ||
declare type ExtractIfPossible<T, U> = Extract<T, U> extends never ? U : Extract<T, U>; | ||
declare type AnyObject = Record<string, any>; | ||
declare type AnyFunction = (...args: any[]) => any; | ||
declare type AnyClass = abstract new (...args: any) => any; | ||
declare type LiteralKey = string | number | symbol; | ||
declare type PrimitiveValue = string | boolean | number | bigint | symbol | null | undefined; | ||
declare type FalsyValue = false | 0 | "" | null | undefined; | ||
declare type Truthy<T> = T extends FalsyValue ? never : T; | ||
declare type Falsy<T> = T extends FalsyValue ? T : never; | ||
declare type Truthy<T> = Exclude<T, FalsyValue>; | ||
declare type Falsy<T> = Extract<T, FalsyValue>; | ||
/** | ||
@@ -83,2 +91,3 @@ * Destructible store object, with values changed to accessors | ||
declare const isArray: (val: any) => val is any[]; | ||
declare const ofClass: (v: any, c: AnyClass) => boolean; | ||
declare const compare: (a: any, b: any) => number; | ||
@@ -92,2 +101,4 @@ /** | ||
declare const tuple: <T extends any[] | []>(input: T) => T; | ||
/** `Array.prototype.includes()` without so strict types. Also allows for checking for multiple items */ | ||
declare const includes: (arr: any[], ...items: any) => boolean; | ||
/** | ||
@@ -212,2 +223,2 @@ * Accesses the value of a MaybeAccessor | ||
export { AccessReturnTypes, AnyFunction, AnyObject, DeepPartialAny, Destore, Falsy, FalsyValue, Fn, ItemsOf, Keys, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, Noop, OnAccessEffectFunction, PrimitiveValue, Truthy, Values, access, accessArray, accessAsArray, asAccessor, asArray, compare, createCallbackStack, destore, entries, forEach, isArray, isBoolean, isClient, isDefined, isFunction, isNumber, isObject, isString, keys, noop, onAccess, onRootCleanup, promiseTimeout, raceTimeout, tuple, withAccess }; | ||
export { AccessReturnTypes, AnyClass, AnyFunction, AnyObject, DeepPartialAny, Destore, Directive, ExtractIfPossible, Falsy, FalsyValue, Fn, Get, ItemsOf, ItemsOfMany, Keys, LiteralKey, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, Noop, OnAccessEffectFunction, PrimitiveValue, Truthy, UnionToIntersection, Values, access, accessArray, accessAsArray, asAccessor, asArray, compare, createCallbackStack, destore, entries, forEach, includes, isArray, isBoolean, isClient, isDefined, isFunction, isNumber, isObject, isString, keys, noop, ofClass, onAccess, onRootCleanup, promiseTimeout, raceTimeout, tuple, withAccess }; |
@@ -13,4 +13,12 @@ // src/index.ts | ||
var isArray = (val) => Array.isArray(val); | ||
var ofClass = (v, c) => v instanceof c || v && v.constructor === c; | ||
var compare = (a, b) => a < b ? -1 : a > b ? 1 : 0; | ||
var tuple = (input) => input; | ||
var includes = (arr, ...items) => { | ||
for (const item of arr) { | ||
if (items.includes(item)) | ||
return true; | ||
} | ||
return false; | ||
}; | ||
var access = (v) => isFunction(v) ? v() : v; | ||
@@ -73,2 +81,3 @@ var accessAsArray = (value) => asArray(access(value)); | ||
forEach, | ||
includes, | ||
isArray, | ||
@@ -85,2 +94,3 @@ isBoolean, | ||
noop, | ||
ofClass, | ||
onAccess, | ||
@@ -87,0 +97,0 @@ onRootCleanup, |
{ | ||
"name": "@solid-primitives/utils", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
21907
469
0
0