@solid-primitives/immutable
Advanced tools
Comparing version 1.0.9 to 1.0.10
@@ -31,2 +31,2 @@ import { Accessor } from 'solid-js'; | ||
export { ImmutableArray, ImmutableObject, ImmutablePrimitive, ImmutableValue, createImmutable }; | ||
export { type ImmutableArray, type ImmutableObject, type ImmutablePrimitive, type ImmutableValue, createImmutable }; |
@@ -58,13 +58,8 @@ import { createMemo, untrack, $PROXY, $TRACK, runWithOwner, getOwner, onCleanup, createRoot, getListener } from 'solid-js'; | ||
get(target, property, receiver) { | ||
if (property === $RAW) | ||
return untrack(this.s); | ||
if (property === $PROXY || property === $TRACK) | ||
return receiver; | ||
if (property === Symbol.iterator) | ||
return void 0; | ||
if (property === this.c.key) | ||
return untrack(this.s)[this.c.key]; | ||
if (property === $RAW) return untrack(this.s); | ||
if (property === $PROXY || property === $TRACK) return receiver; | ||
if (property === Symbol.iterator) return void 0; | ||
if (property === this.c.key) return untrack(this.s)[this.c.key]; | ||
let cached = this.#cache.get(property); | ||
if (cached) | ||
return cached.get(); | ||
if (cached) return cached.get(); | ||
let valueAccessor = () => { | ||
@@ -111,21 +106,12 @@ const source = this.s(); | ||
get(_, property, receiver) { | ||
if (property === $RAW) | ||
return untrack(this.s); | ||
if (property === $PROXY) | ||
return receiver; | ||
if (property === $TRACK) | ||
return this.#trackItems(), receiver; | ||
if (property === Symbol.iterator) | ||
return this.#trackItems(), untrack(this.s)[property]; | ||
if (property === "length") | ||
return this.#trackLength(); | ||
if (typeof property === "symbol") | ||
return this.s()[property]; | ||
if (property in Array.prototype) | ||
return Array.prototype[property].bind(receiver); | ||
if (property === $RAW) return untrack(this.s); | ||
if (property === $PROXY) return receiver; | ||
if (property === $TRACK) return this.#trackItems(), receiver; | ||
if (property === Symbol.iterator) return this.#trackItems(), untrack(this.s)[property]; | ||
if (property === "length") return this.#trackLength(); | ||
if (typeof property === "symbol") return this.s()[property]; | ||
if (property in Array.prototype) return Array.prototype[property].bind(receiver); | ||
const num = typeof property === "string" ? parseInt(property) : property; | ||
if (!Number.isInteger(num) || num < 0) | ||
return this.s()[property]; | ||
if (num >= untrack(this.#trackLength)) | ||
return this.#trackLength(), this.s()[num]; | ||
if (!Number.isInteger(num) || num < 0) return this.s()[property]; | ||
if (num >= untrack(this.#trackLength)) return this.#trackLength(), this.s()[num]; | ||
return untrack(this.#trackItems)[num].get(); | ||
@@ -153,4 +139,3 @@ } | ||
const id = v[this.c.key]; | ||
if (id === this.#lastId && isWrappable(this.#prev)) | ||
return this.#prev; | ||
if (id === this.#lastId && isWrappable(this.#prev)) return this.#prev; | ||
this.#lastId = id; | ||
@@ -157,0 +142,0 @@ this.#dispose(); |
{ | ||
"name": "@solid-primitives/immutable", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"description": "Primitive for rectifying immutable values and dealing with immutability in Solid.", | ||
@@ -55,3 +55,3 @@ "author": "Damian Tarnawski <gthetarnav@gmail.com>", | ||
"dependencies": { | ||
"@solid-primitives/keyed": "^1.2.2", | ||
"@solid-primitives/keyed": "^1.2.3", | ||
"@solid-primitives/utils": "^6.2.3" | ||
@@ -58,0 +58,0 @@ }, |
@@ -14,3 +14,3 @@ <p> | ||
- [`createImmutable`](#createImmutable) - Creates a store derived from the given immutable source. | ||
- [`createImmutable`](#createimmutable) - Creates a store derived from the given immutable source. | ||
@@ -17,0 +17,0 @@ ## Installation |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
22706
7
350