@semantq/state
Advanced tools
+2
-0
@@ -15,3 +15,5 @@ // index.js | ||
| export { $props }; | ||
| export { $getValue, $getValueMemo } from './pulse.js'; | ||
| // Binding utilities (grouped under `state`) | ||
@@ -18,0 +20,0 @@ export const state = { |
+28
-0
| //pulse | ||
| import { PulseCore } from './PulseCore.js'; | ||
| export function $getValue(proxy) { | ||
| if (!proxy) return proxy; | ||
| // Fast path for PulseCore instances | ||
| if (proxy instanceof PulseCore) return proxy._value; | ||
| // Compatibility path for other reactive objects | ||
| if (typeof proxy === 'object') { | ||
| if ('_value' in proxy) return proxy._value; | ||
| if ('value' in proxy) return proxy.value; | ||
| } | ||
| return proxy; | ||
| } | ||
| // Memoized version | ||
| const valueCache = new WeakMap(); | ||
| export function $getValueMemo(proxy) { | ||
| if (!proxy) return proxy; | ||
| if (valueCache.has(proxy)) return valueCache.get(proxy); | ||
| const value = $getValue(proxy); | ||
| valueCache.set(proxy, value); | ||
| return value; | ||
| } | ||
| export function pulse(initialValue, options = {}) { | ||
@@ -5,0 +33,0 @@ const { key, storage = localStorage } = options; |
+1
-1
| { | ||
| "name": "@semantq/state", | ||
| "version": "1.0.6", | ||
| "version": "1.0.7", | ||
| "description": "A reactivity state management system for Semantq", | ||
@@ -5,0 +5,0 @@ "main": "./core/index.js", |
54775
1.29%818
2.63%