Comparing version 2.0.0-beta.2 to 2.0.0-beta.3
35
index.js
'use strict'; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default")); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var src_exports = {}; | ||
module.exports = __toCommonJS(src_exports); | ||
__reExport(src_exports, require("./vanilla.ts"), module.exports); | ||
__reExport(src_exports, require("./react.ts"), module.exports); | ||
var vanilla = require('valtio/vanilla'); | ||
var react = require('valtio/react'); | ||
Object.keys(vanilla).forEach(function (k) { | ||
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { | ||
enumerable: true, | ||
get: function () { return vanilla[k]; } | ||
}); | ||
}); | ||
Object.keys(react).forEach(function (k) { | ||
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { | ||
enumerable: true, | ||
get: function () { return react[k]; } | ||
}); | ||
}); |
{ | ||
"name": "valtio", | ||
"private": false, | ||
"version": "2.0.0-beta.2", | ||
"version": "2.0.0-beta.3", | ||
"publishConfig": { | ||
@@ -6,0 +6,0 @@ "tag": "next" |
61
react.js
'use strict'; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var react_exports = {}; | ||
__export(react_exports, { | ||
useSnapshot: () => useSnapshot | ||
}); | ||
module.exports = __toCommonJS(react_exports); | ||
var import_react = require("react"); | ||
var import_proxy_compare = require("proxy-compare"); | ||
var import_vanilla = require("./vanilla.ts"); | ||
var react = require('react'); | ||
var proxyCompare = require('proxy-compare'); | ||
var vanilla = require('valtio/vanilla'); | ||
const useAffectedDebugValue = (state, affected) => { | ||
const pathList = (0, import_react.useRef)(); | ||
(0, import_react.useEffect)(() => { | ||
pathList.current = (0, import_proxy_compare.affectedToPathList)(state, affected, true); | ||
const pathList = react.useRef(); | ||
react.useEffect(() => { | ||
pathList.current = proxyCompare.affectedToPathList(state, affected, true); | ||
}); | ||
(0, import_react.useDebugValue)(pathList.current); | ||
react.useDebugValue(pathList.current); | ||
}; | ||
@@ -38,9 +17,9 @@ const targetCache = /* @__PURE__ */ new WeakMap(); | ||
const notifyInSync = options == null ? void 0 : options.sync; | ||
const affected = (0, import_react.useMemo)(() => /* @__PURE__ */ new WeakMap(), [proxyObject]); | ||
const lastSnapshot = (0, import_react.useRef)(); | ||
const affected = react.useMemo(() => /* @__PURE__ */ new WeakMap(), [proxyObject]); | ||
const lastSnapshot = react.useRef(); | ||
let inRender = true; | ||
const currSnapshot = (0, import_react.useSyncExternalStore)( | ||
(0, import_react.useCallback)( | ||
const currSnapshot = react.useSyncExternalStore( | ||
react.useCallback( | ||
(callback) => { | ||
const unsub = (0, import_vanilla.subscribe)(proxyObject, callback, notifyInSync); | ||
const unsub = vanilla.subscribe(proxyObject, callback, notifyInSync); | ||
callback(); | ||
@@ -52,5 +31,5 @@ return unsub; | ||
() => { | ||
const nextSnapshot = (0, import_vanilla.snapshot)(proxyObject); | ||
const nextSnapshot = vanilla.snapshot(proxyObject); | ||
try { | ||
if (!inRender && lastSnapshot.current && !(0, import_proxy_compare.isChanged)( | ||
if (!inRender && lastSnapshot.current && !proxyCompare.isChanged( | ||
lastSnapshot.current, | ||
@@ -67,6 +46,6 @@ nextSnapshot, | ||
}, | ||
() => (0, import_vanilla.snapshot)(proxyObject) | ||
() => vanilla.snapshot(proxyObject) | ||
); | ||
inRender = false; | ||
(0, import_react.useEffect)(() => { | ||
react.useEffect(() => { | ||
lastSnapshot.current = currSnapshot; | ||
@@ -77,4 +56,6 @@ }); | ||
} | ||
const proxyCache = (0, import_react.useMemo)(() => /* @__PURE__ */ new WeakMap(), []); | ||
return (0, import_proxy_compare.createProxy)(currSnapshot, affected, proxyCache, targetCache); | ||
const proxyCache = react.useMemo(() => /* @__PURE__ */ new WeakMap(), []); | ||
return proxyCompare.createProxy(currSnapshot, affected, proxyCache, targetCache); | ||
} | ||
exports.useSnapshot = useSnapshot; |
'use strict'; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var utils_exports = {}; | ||
__export(utils_exports, { | ||
useProxy: () => import_useProxy.useProxy | ||
}); | ||
module.exports = __toCommonJS(utils_exports); | ||
var import_useProxy = require("./utils/useProxy.ts"); | ||
var react$1 = require('react'); | ||
var react = require('valtio/react'); | ||
const DUMMY_SYMBOL = Symbol(); | ||
function useProxy(proxy, options) { | ||
const snapshot = react.useSnapshot(proxy, options); | ||
snapshot[DUMMY_SYMBOL]; | ||
let isRendering = true; | ||
react$1.useLayoutEffect(() => { | ||
isRendering = false; | ||
}); | ||
return new Proxy(proxy, { | ||
get(target, prop) { | ||
return isRendering ? snapshot[prop] : target[prop]; | ||
} | ||
}); | ||
} | ||
exports.useProxy = useProxy; |
35
utils.js
'use strict'; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default")); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var utils_exports = {}; | ||
module.exports = __toCommonJS(utils_exports); | ||
__reExport(utils_exports, require("./vanilla/utils.ts"), module.exports); | ||
__reExport(utils_exports, require("./react/utils.ts"), module.exports); | ||
var utils = require('valtio/vanilla/utils'); | ||
var utils$1 = require('valtio/react/utils'); | ||
Object.keys(utils).forEach(function (k) { | ||
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { | ||
enumerable: true, | ||
get: function () { return utils[k]; } | ||
}); | ||
}); | ||
Object.keys(utils$1).forEach(function (k) { | ||
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, { | ||
enumerable: true, | ||
get: function () { return utils$1[k]; } | ||
}); | ||
}); |
'use strict'; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
} | ||
return to; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var vanilla_exports = {}; | ||
__export(vanilla_exports, { | ||
getVersion: () => getVersion, | ||
proxy: () => proxy, | ||
ref: () => ref, | ||
snapshot: () => snapshot, | ||
subscribe: () => subscribe, | ||
unstable_buildProxyFunction: () => unstable_buildProxyFunction | ||
}); | ||
module.exports = __toCommonJS(vanilla_exports); | ||
var import_proxy_compare = require("proxy-compare"); | ||
var proxyCompare = require('proxy-compare'); | ||
const isObject = (x) => typeof x === "object" && x !== null; | ||
@@ -40,3 +14,3 @@ const proxyStateMap = /* @__PURE__ */ new WeakMap(); | ||
const snap = Array.isArray(target) ? [] : Object.create(Object.getPrototypeOf(target)); | ||
(0, import_proxy_compare.markToTrack)(snap, true); | ||
proxyCompare.markToTrack(snap, true); | ||
snapCache.set(target, [version, snap]); | ||
@@ -60,3 +34,3 @@ Reflect.ownKeys(target).forEach((key) => { | ||
if (refSet.has(value)) { | ||
(0, import_proxy_compare.markToTrack)(value, false); | ||
proxyCompare.markToTrack(value, false); | ||
} else if (proxyStateMap.has(value)) { | ||
@@ -171,3 +145,3 @@ const [target2, ensureVersion] = proxyStateMap.get( | ||
if (isObject(value)) { | ||
value = (0, import_proxy_compare.getUntracked)(value) || value; | ||
value = proxyCompare.getUntracked(value) || value; | ||
} | ||
@@ -283,1 +257,8 @@ let nextValue = value; | ||
const unstable_buildProxyFunction = buildProxyFunction; | ||
exports.getVersion = getVersion; | ||
exports.proxy = proxy; | ||
exports.ref = ref; | ||
exports.snapshot = snapshot; | ||
exports.subscribe = subscribe; | ||
exports.unstable_buildProxyFunction = unstable_buildProxyFunction; |
'use strict'; | ||
var __defProp = Object.defineProperty; | ||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor; | ||
var __getOwnPropNames = Object.getOwnPropertyNames; | ||
var __hasOwnProp = Object.prototype.hasOwnProperty; | ||
var __export = (target, all) => { | ||
for (var name in all) | ||
__defProp(target, name, { get: all[name], enumerable: true }); | ||
var vanilla = require('valtio/vanilla'); | ||
function subscribeKey(proxyObject, key, callback, notifyInSync) { | ||
let prevValue = proxyObject[key]; | ||
return vanilla.subscribe( | ||
proxyObject, | ||
() => { | ||
const nextValue = proxyObject[key]; | ||
if (!Object.is(prevValue, nextValue)) { | ||
callback(prevValue = nextValue); | ||
} | ||
}, | ||
notifyInSync | ||
); | ||
} | ||
let currentCleanups; | ||
function watch(callback, options) { | ||
let alive = true; | ||
const cleanups = /* @__PURE__ */ new Set(); | ||
const subscriptions = /* @__PURE__ */ new Map(); | ||
const cleanup = () => { | ||
if (alive) { | ||
alive = false; | ||
cleanups.forEach((clean) => clean()); | ||
cleanups.clear(); | ||
subscriptions.forEach((unsubscribe) => unsubscribe()); | ||
subscriptions.clear(); | ||
} | ||
}; | ||
const revalidate = async () => { | ||
if (!alive) { | ||
return; | ||
} | ||
cleanups.forEach((clean) => clean()); | ||
cleanups.clear(); | ||
const proxiesToSubscribe = /* @__PURE__ */ new Set(); | ||
const parent = currentCleanups; | ||
currentCleanups = cleanups; | ||
try { | ||
const promiseOrPossibleCleanup = callback((proxyObject) => { | ||
proxiesToSubscribe.add(proxyObject); | ||
if (alive && !subscriptions.has(proxyObject)) { | ||
const unsubscribe = vanilla.subscribe(proxyObject, revalidate, options == null ? void 0 : options.sync); | ||
subscriptions.set(proxyObject, unsubscribe); | ||
} | ||
return proxyObject; | ||
}); | ||
const couldBeCleanup = promiseOrPossibleCleanup && promiseOrPossibleCleanup instanceof Promise ? await promiseOrPossibleCleanup : promiseOrPossibleCleanup; | ||
if (couldBeCleanup) { | ||
if (alive) { | ||
cleanups.add(couldBeCleanup); | ||
} else { | ||
cleanup(); | ||
} | ||
} | ||
} finally { | ||
currentCleanups = parent; | ||
} | ||
subscriptions.forEach((unsubscribe, proxyObject) => { | ||
if (!proxiesToSubscribe.has(proxyObject)) { | ||
subscriptions.delete(proxyObject); | ||
unsubscribe(); | ||
} | ||
}); | ||
}; | ||
if (currentCleanups) { | ||
currentCleanups.add(cleanup); | ||
} | ||
revalidate(); | ||
return cleanup; | ||
} | ||
const DEVTOOLS = Symbol(); | ||
function devtools(proxyObject, options) { | ||
const { enabled, name = "", ...rest } = options || {}; | ||
let extension; | ||
try { | ||
extension = (enabled != null ? enabled : process.env.NODE_ENV !== "production") && window.__REDUX_DEVTOOLS_EXTENSION__; | ||
} catch (e) { | ||
} | ||
if (!extension) { | ||
if (process.env.NODE_ENV !== "production" && enabled) { | ||
console.warn("[Warning] Please install/enable Redux devtools extension"); | ||
} | ||
return; | ||
} | ||
let isTimeTraveling = false; | ||
const devtools2 = extension.connect({ name, ...rest }); | ||
const unsub1 = vanilla.subscribe(proxyObject, (ops) => { | ||
const action = ops.filter(([_, path]) => path[0] !== DEVTOOLS).map(([op, path]) => `${op}:${path.map(String).join(".")}`).join(", "); | ||
if (!action) { | ||
return; | ||
} | ||
if (isTimeTraveling) { | ||
isTimeTraveling = false; | ||
} else { | ||
const snapWithoutDevtools = Object.assign({}, vanilla.snapshot(proxyObject)); | ||
delete snapWithoutDevtools[DEVTOOLS]; | ||
devtools2.send( | ||
{ | ||
type: action, | ||
updatedAt: (/* @__PURE__ */ new Date()).toLocaleString() | ||
}, | ||
snapWithoutDevtools | ||
); | ||
} | ||
}); | ||
const unsub2 = devtools2.subscribe((message) => { | ||
var _a, _b, _c, _d, _e, _f; | ||
if (message.type === "ACTION" && message.payload) { | ||
try { | ||
Object.assign(proxyObject, JSON.parse(message.payload)); | ||
} catch (e) { | ||
console.error( | ||
"please dispatch a serializable value that JSON.parse() and proxy() support\n", | ||
e | ||
); | ||
} | ||
} | ||
if (message.type === "DISPATCH" && message.state) { | ||
if (((_a = message.payload) == null ? void 0 : _a.type) === "JUMP_TO_ACTION" || ((_b = message.payload) == null ? void 0 : _b.type) === "JUMP_TO_STATE") { | ||
isTimeTraveling = true; | ||
const state = JSON.parse(message.state); | ||
Object.assign(proxyObject, state); | ||
} | ||
proxyObject[DEVTOOLS] = message; | ||
} else if (message.type === "DISPATCH" && ((_c = message.payload) == null ? void 0 : _c.type) === "COMMIT") { | ||
devtools2.init(vanilla.snapshot(proxyObject)); | ||
} else if (message.type === "DISPATCH" && ((_d = message.payload) == null ? void 0 : _d.type) === "IMPORT_STATE") { | ||
const actions = (_e = message.payload.nextLiftedState) == null ? void 0 : _e.actionsById; | ||
const computedStates = ((_f = message.payload.nextLiftedState) == null ? void 0 : _f.computedStates) || []; | ||
isTimeTraveling = true; | ||
computedStates.forEach(({ state }, index) => { | ||
const action = actions[index] || "No action found"; | ||
Object.assign(proxyObject, state); | ||
if (index === 0) { | ||
devtools2.init(vanilla.snapshot(proxyObject)); | ||
} else { | ||
devtools2.send(action, vanilla.snapshot(proxyObject)); | ||
} | ||
}); | ||
} | ||
}); | ||
devtools2.init(vanilla.snapshot(proxyObject)); | ||
return () => { | ||
unsub1(); | ||
unsub2 == null ? void 0 : unsub2(); | ||
}; | ||
} | ||
const isObject = (x) => typeof x === "object" && x !== null; | ||
let defaultRefSet; | ||
const getDefaultRefSet = () => { | ||
if (!defaultRefSet) { | ||
defaultRefSet = vanilla.unstable_buildProxyFunction()[2]; | ||
} | ||
return defaultRefSet; | ||
}; | ||
var __copyProps = (to, from, except, desc) => { | ||
if (from && typeof from === "object" || typeof from === "function") { | ||
for (let key of __getOwnPropNames(from)) | ||
if (!__hasOwnProp.call(to, key) && key !== except) | ||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); | ||
const deepClone = (obj, getRefSet = getDefaultRefSet) => { | ||
if (!isObject(obj) || getRefSet().has(obj)) { | ||
return obj; | ||
} | ||
return to; | ||
const baseObject = Array.isArray(obj) ? [] : Object.create(Object.getPrototypeOf(obj)); | ||
Reflect.ownKeys(obj).forEach((key) => { | ||
baseObject[key] = deepClone(obj[key], getRefSet); | ||
}); | ||
return baseObject; | ||
}; | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
var utils_exports = {}; | ||
__export(utils_exports, { | ||
deepClone: () => import_deepClone.deepClone, | ||
devtools: () => import_devtools.devtools, | ||
proxyMap: () => import_proxyMap.proxyMap, | ||
proxySet: () => import_proxySet.proxySet, | ||
subscribeKey: () => import_subscribeKey.subscribeKey, | ||
watch: () => import_watch.watch | ||
}); | ||
module.exports = __toCommonJS(utils_exports); | ||
var import_subscribeKey = require("./utils/subscribeKey.ts"); | ||
var import_watch = require("./utils/watch.ts"); | ||
var import_devtools = require("./utils/devtools.ts"); | ||
var import_deepClone = require("./utils/deepClone.ts"); | ||
var import_proxySet = require("./utils/proxySet.ts"); | ||
var import_proxyMap = require("./utils/proxyMap.ts"); | ||
function proxySet(initialValues) { | ||
const set = vanilla.proxy({ | ||
data: Array.from(new Set(initialValues)), | ||
has(value) { | ||
return this.data.indexOf(value) !== -1; | ||
}, | ||
add(value) { | ||
let hasProxy = false; | ||
if (typeof value === "object" && value !== null) { | ||
hasProxy = this.data.indexOf(vanilla.proxy(value)) !== -1; | ||
} | ||
if (this.data.indexOf(value) === -1 && !hasProxy) { | ||
this.data.push(value); | ||
} | ||
return this; | ||
}, | ||
delete(value) { | ||
const index = this.data.indexOf(value); | ||
if (index === -1) { | ||
return false; | ||
} | ||
this.data.splice(index, 1); | ||
return true; | ||
}, | ||
clear() { | ||
this.data.splice(0); | ||
}, | ||
get size() { | ||
return this.data.length; | ||
}, | ||
forEach(cb) { | ||
this.data.forEach((value) => { | ||
cb(value, value, this); | ||
}); | ||
}, | ||
get [Symbol.toStringTag]() { | ||
return "Set"; | ||
}, | ||
toJSON() { | ||
return new Set(this.data); | ||
}, | ||
[Symbol.iterator]() { | ||
return this.data[Symbol.iterator](); | ||
}, | ||
values() { | ||
return this.data.values(); | ||
}, | ||
keys() { | ||
return this.data.values(); | ||
}, | ||
entries() { | ||
return new Set(this.data).entries(); | ||
} | ||
}); | ||
Object.defineProperties(set, { | ||
data: { | ||
enumerable: false | ||
}, | ||
size: { | ||
enumerable: false | ||
}, | ||
toJSON: { | ||
enumerable: false | ||
} | ||
}); | ||
Object.seal(set); | ||
return set; | ||
} | ||
function proxyMap(entries) { | ||
const map = vanilla.proxy({ | ||
data: Array.from(entries || []), | ||
has(key) { | ||
return this.data.some((p) => p[0] === key); | ||
}, | ||
set(key, value) { | ||
const record = this.data.find((p) => p[0] === key); | ||
if (record) { | ||
record[1] = value; | ||
} else { | ||
this.data.push([key, value]); | ||
} | ||
return this; | ||
}, | ||
get(key) { | ||
var _a; | ||
return (_a = this.data.find((p) => p[0] === key)) == null ? void 0 : _a[1]; | ||
}, | ||
delete(key) { | ||
const index = this.data.findIndex((p) => p[0] === key); | ||
if (index === -1) { | ||
return false; | ||
} | ||
this.data.splice(index, 1); | ||
return true; | ||
}, | ||
clear() { | ||
this.data.splice(0); | ||
}, | ||
get size() { | ||
return this.data.length; | ||
}, | ||
toJSON() { | ||
return new Map(this.data); | ||
}, | ||
forEach(cb) { | ||
this.data.forEach((p) => { | ||
cb(p[1], p[0], this); | ||
}); | ||
}, | ||
keys() { | ||
return this.data.map((p) => p[0]).values(); | ||
}, | ||
values() { | ||
return this.data.map((p) => p[1]).values(); | ||
}, | ||
entries() { | ||
return new Map(this.data).entries(); | ||
}, | ||
get [Symbol.toStringTag]() { | ||
return "Map"; | ||
}, | ||
[Symbol.iterator]() { | ||
return this.entries(); | ||
} | ||
}); | ||
Object.defineProperties(map, { | ||
data: { | ||
enumerable: false | ||
}, | ||
size: { | ||
enumerable: false | ||
}, | ||
toJSON: { | ||
enumerable: false | ||
} | ||
}); | ||
Object.seal(map); | ||
return map; | ||
} | ||
exports.deepClone = deepClone; | ||
exports.devtools = devtools; | ||
exports.proxyMap = proxyMap; | ||
exports.proxySet = proxySet; | ||
exports.subscribeKey = subscribeKey; | ||
exports.watch = watch; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
74192
1560
7