@solid-primitives/utils
Advanced tools
Comparing version 2.0.3 to 2.1.0
@@ -261,3 +261,12 @@ import { Accessor, Setter, onCleanup } from 'solid-js'; | ||
declare function createStaticStore<T extends Readonly<AnyStatic>>(init: T): [access: T, write: StaticStoreSetter<T>]; | ||
/** | ||
* Handle items removed and added to the array by diffing it by refference. | ||
* | ||
* @param current new array instance | ||
* @param prev previous array copy | ||
* @param handleAdded called once for every added item to array | ||
* @param handleRemoved called once for every removed from array | ||
*/ | ||
declare function handleDiffArray<T>(current: T[], prev: T[], handleAdded: (item: T) => void, handleRemoved: (item: T) => void): void; | ||
export { AccessReturnTypes, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Definite, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, Mutable, 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, isServer, keys, noop, ofClass, onRootCleanup, promiseTimeout, raceTimeout, warn, withAccess }; | ||
export { AccessReturnTypes, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Definite, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, Mutable, 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, handleDiffArray, isClient, isDev, isObject, isProd, isServer, keys, noop, ofClass, onRootCleanup, promiseTimeout, raceTimeout, warn, withAccess }; |
@@ -160,2 +160,33 @@ var __defProp = Object.defineProperty; | ||
} | ||
function handleDiffArray(current, prev, handleAdded, handleRemoved) { | ||
const currLength = current.length; | ||
const prevLength = prev.length; | ||
let i = 0; | ||
if (!prevLength) { | ||
for (; i < currLength; i++) | ||
handleAdded(current[i]); | ||
return; | ||
} | ||
if (!currLength) { | ||
for (; i < prevLength; i++) | ||
handleRemoved(prev[i]); | ||
return; | ||
} | ||
for (; i < prevLength; i++) { | ||
if (prev[i] !== current[i]) | ||
break; | ||
} | ||
let prevEl; | ||
let currEl; | ||
prev = prev.slice(i); | ||
current = current.slice(i); | ||
for (prevEl of prev) { | ||
if (!current.includes(prevEl)) | ||
handleRemoved(prevEl); | ||
} | ||
for (currEl of current) { | ||
if (!prev.includes(currEl)) | ||
handleAdded(currEl); | ||
} | ||
} | ||
export { | ||
@@ -178,2 +209,3 @@ access, | ||
forEachEntry, | ||
handleDiffArray, | ||
isClient, | ||
@@ -180,0 +212,0 @@ isDev, |
{ | ||
"name": "@solid-primitives/utils", | ||
"version": "2.0.3", | ||
"version": "2.1.0", | ||
"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
29494
762