@nuxodin/item 0.6.13 → 0.6.14

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxodin/item",
3
- "version": "0.6.13",
3
+ "version": "0.6.14",
4
4
  "description": "Reactive state library",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -24,7 +24,10 @@
24
24
  #getter = null; // current/cached getter promise
25
25
  #getterExpiry = Infinity; // ttl is checked lazily on access — no timer per cache entry
26
26
  // expired getters count as gone (lazy ttl)
27
- get #cachedGetter() { return Date.now() < this.#getterExpiry ? this.#getter : null; }
27
+ get #cachedGetter() {
28
+ const g = this.#getter;
29
+ return g && (this.#getterExpiry === Infinity || Date.now() < this.#getterExpiry) ? g : null;
30
+ }
28
31
  onpending = null;
29
32
  onchange = null;
30
33
 
@@ -128,7 +131,8 @@
128
131
 
129
132
  // ignore if latest getter value is the same
130
133
  // Value already set (no-op). Returns undefined to avoid falsy issues (value could be 0, false, etc.)
131
- if (this.#cachedGetter?.state === 'fulfilled' && isEqual(this.#cachedGetter.value, value)) return;
134
+ const cached = this.#cachedGetter;
135
+ if (cached?.state === 'fulfilled' && isEqual(cached.value, value)) return;
132
136
 
133
137
  this.#expectedValue = value;
134
138
  const promise = this.#createSetter(value);