wana
Version:
Easy observable state for React
39 lines (35 loc) • 1.13 kB
JavaScript
const emptyArray = Object.freeze([]);
const setHidden = (obj, key, value) => Object.defineProperty(obj, key, {value, configurable: true});
function rethrowError(error) {
throw error;
}
const noop = () => {
};
const nope = () => false;
const flop = () => {
throw Error("Not yet implemented");
};
const hasOwn = Function.call.bind({}.hasOwnProperty);
const getOwnDescriptor = Object.getOwnPropertyDescriptor;
function getDescriptor(self, key) {
let desc;
let proto = self;
do {
if (desc = getOwnDescriptor(proto, key)) {
return desc;
}
} while (proto = Object.getPrototypeOf(proto));
}
const globals = {
observe: null,
auto: null,
onRender: null,
onChange: null
};
const observe = (target, key) => !!globals.observe && (globals.observe(target, key), true);
const $$ = Symbol.for("wana:state");
const $O = Symbol.for("wana:observable");
const SIZE = Symbol.for("wana:size");
const $T = Symbol.for("wana:traps");
export { $$, $O, $T, SIZE, emptyArray, flop, getDescriptor, getOwnDescriptor, globals, hasOwn, noop, nope, observe, rethrowError, setHidden };
//# sourceMappingURL=815e560c.mjs.map