@nuxodin/item 0.6.12 → 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/item.d.ts CHANGED
@@ -100,6 +100,9 @@ export interface ItemProxyChildren { [key: string]: ItemProxy<unknown, Item>; }
100
100
 
101
101
  export interface ItemProxyMethods<T = ItemValue,TRaw extends Item = Item> {
102
102
  readonly [$item]: TRaw;
103
+ // the proxy is callable, so TS would type these as Function members; at runtime they are children
104
+ readonly name: ItemProxy<unknown, Item>;
105
+ readonly length: ItemProxy<unknown, Item>;
103
106
  <TValue = T>(): TValue;
104
107
  (value: unknown): Promise<any> | undefined;
105
108
  then<TResult1 = T, TResult2 = never>(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuxodin/item",
3
- "version": "0.6.12",
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);