reactive-box
Advanced tools
Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "reactive-box", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Minimalistic, fast, and highly efficient reactivity", | ||
@@ -47,3 +47,3 @@ "scripts": { | ||
"homepage": "https://github.com/betula/reactive-box#readme", | ||
"gitHead": "fb575f497551405fc044780b73f21c787656f8ed" | ||
"gitHead": "c97d386107cd302a18b96a965b53a52fc9acd4b0" | ||
} |
declare function box<T>( | ||
initialValue?: T, | ||
onChange?: (currentValue?: T, previousValue?: T) => void | ||
onChange?: (currentValue?: T, previousValue?: T) => void, | ||
comparer?: (value?: T, nextValue?: T) => boolean | ||
): [() => T, (nextValue?: T) => void]; | ||
declare function sel<T extends () => any>(body: T): [T, () => void]; | ||
declare function sel<T extends () => any>( | ||
body: T, | ||
comparer?: (value?: T, prevValue?: T) => boolean | ||
): [T, () => void]; | ||
@@ -8,0 +12,0 @@ declare function expr<T extends () => void>(body: T): [T, () => void]; |
@@ -71,3 +71,3 @@ /** | ||
const box = (value, change_listener) => { | ||
const box = (value, change_listener, comparer = Object.is) => { | ||
const box_node = [new Set()]; | ||
@@ -78,3 +78,3 @@ return [ | ||
? (next_value) => { | ||
if (!Object.is(value, next_value)) { | ||
if (!comparer(value, next_value)) { | ||
const prev_value = value; | ||
@@ -87,3 +87,3 @@ value = next_value; | ||
: (next_value) => { | ||
if (!Object.is(value, next_value)) { | ||
if (!comparer(value, next_value)) { | ||
value = next_value; | ||
@@ -96,3 +96,3 @@ write(box_node); | ||
const sel = (body) => { | ||
const sel = (body, comparer = Object.is) => { | ||
let cache; | ||
@@ -109,3 +109,3 @@ let last_context; | ||
} | ||
return !Object.is(prev, cache); | ||
return !comparer(cache, prev); | ||
}; | ||
@@ -112,0 +112,0 @@ const sel_node = [new Set(), new Set(), 0, recalc]; |
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
8872
162