Replace isPlainObject
This commit is contained in:
parent
4e75f8bf2f
commit
6411ee4e34
4 changed files with 33 additions and 24 deletions
44
package-lock.json
generated
44
package-lock.json
generated
|
@ -10,6 +10,7 @@
|
|||
"dependencies": {
|
||||
"@pixi/particle-emitter": "^5.0.4",
|
||||
"core-js": "^3.6.5",
|
||||
"is-plain-object": "^5.0.0",
|
||||
"jest-environment-jsdom": "^28.1.1",
|
||||
"lodash.clonedeep": "^4.5.0",
|
||||
"lz-string": "^1.4.4",
|
||||
|
@ -6053,6 +6054,18 @@
|
|||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/clone-deep/node_modules/is-plain-object": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
|
||||
"integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"isobject": "^3.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/co": {
|
||||
"version": "4.6.0",
|
||||
"resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz",
|
||||
|
@ -9173,13 +9186,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/is-plain-object": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
|
||||
"integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"isobject": "^3.0.1"
|
||||
},
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
|
||||
"integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
|
@ -21484,6 +21493,17 @@
|
|||
"is-plain-object": "^2.0.4",
|
||||
"kind-of": "^6.0.2",
|
||||
"shallow-clone": "^3.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"is-plain-object": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
|
||||
"integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"isobject": "^3.0.1"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"co": {
|
||||
|
@ -23777,13 +23797,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"is-plain-object": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
|
||||
"integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"isobject": "^3.0.1"
|
||||
}
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz",
|
||||
"integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q=="
|
||||
},
|
||||
"is-potential-custom-element-name": {
|
||||
"version": "1.0.1",
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
"dependencies": {
|
||||
"@pixi/particle-emitter": "^5.0.4",
|
||||
"core-js": "^3.6.5",
|
||||
"is-plain-object": "^5.0.0",
|
||||
"jest-environment-jsdom": "^28.1.1",
|
||||
"lodash.clonedeep": "^4.5.0",
|
||||
"lz-string": "^1.4.4",
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import Decimal from "util/bignum";
|
||||
import { isPlainObject } from "util/common";
|
||||
import { isPlainObject } from "is-plain-object";
|
||||
import { ProxiedWithState, ProxyPath, ProxyState } from "util/proxies";
|
||||
import { reactive, unref } from "vue";
|
||||
import transientState from "./state";
|
||||
|
@ -51,11 +51,7 @@ const playerHandler: ProxyHandler<Record<PropertyKey, any>> = {
|
|||
}
|
||||
|
||||
const value = target[ProxyState][key];
|
||||
if (
|
||||
key !== "value" &&
|
||||
(isPlainObject(value) || Array.isArray(value)) &&
|
||||
!(value instanceof Decimal)
|
||||
) {
|
||||
if (key !== "value" && (isPlainObject(value) || Array.isArray(value))) {
|
||||
if (value !== target[key]?.[ProxyState]) {
|
||||
const path = [...target[ProxyPath], key];
|
||||
target[key] = new Proxy({ [ProxyState]: value, [ProxyPath]: path }, playerHandler);
|
||||
|
|
|
@ -8,10 +8,6 @@ export function camelToTitle(camel: string): string {
|
|||
return title;
|
||||
}
|
||||
|
||||
export function isPlainObject(object: unknown): boolean {
|
||||
return Object.prototype.toString.call(object) === "[object Object]";
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/ban-types
|
||||
export function isFunction(func: unknown): func is Function {
|
||||
return typeof func === "function";
|
||||
|
|
Loading…
Reference in a new issue