@domql/state 2.5.200 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/create.js +16 -131
- package/dist/cjs/create.js +11 -100
- package/dist/cjs/index.js +0 -2
- package/dist/cjs/methods.js +105 -50
- package/dist/cjs/updateState.js +41 -41
- package/dist/esm/create.js +15 -141
- package/dist/esm/index.js +0 -2
- package/dist/esm/methods.js +110 -51
- package/dist/esm/updateState.js +45 -36
- package/index.js +0 -2
- package/methods.js +117 -53
- package/package.json +5 -5
- package/updateState.js +56 -46
- package/dist/cjs/ignore.js +0 -57
- package/dist/cjs/inherit.js +0 -117
- package/dist/esm/ignore.js +0 -37
- package/dist/esm/inherit.js +0 -97
- package/ignore.js +0 -8
- package/inherit.js +0 -131
package/dist/cjs/ignore.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var ignore_exports = {};
|
|
20
|
-
__export(ignore_exports, {
|
|
21
|
-
IGNORE_STATE_PARAMS: () => IGNORE_STATE_PARAMS
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(ignore_exports);
|
|
24
|
-
const IGNORE_STATE_PARAMS = [
|
|
25
|
-
"update",
|
|
26
|
-
"parse",
|
|
27
|
-
"clean",
|
|
28
|
-
"create",
|
|
29
|
-
"destroy",
|
|
30
|
-
"add",
|
|
31
|
-
"toggle",
|
|
32
|
-
"remove",
|
|
33
|
-
"apply",
|
|
34
|
-
"set",
|
|
35
|
-
"reset",
|
|
36
|
-
"replace",
|
|
37
|
-
"quietReplace",
|
|
38
|
-
"quietUpdate",
|
|
39
|
-
"applyReplace",
|
|
40
|
-
"applyFunction",
|
|
41
|
-
"keys",
|
|
42
|
-
"values",
|
|
43
|
-
"ref",
|
|
44
|
-
"rootUpdate",
|
|
45
|
-
"parentUpdate",
|
|
46
|
-
"parent",
|
|
47
|
-
"__element",
|
|
48
|
-
"__depends",
|
|
49
|
-
"__ref",
|
|
50
|
-
"__children",
|
|
51
|
-
"root",
|
|
52
|
-
"setByPath",
|
|
53
|
-
"setPathCollection",
|
|
54
|
-
"removeByPath",
|
|
55
|
-
"removePathCollection",
|
|
56
|
-
"getByPath"
|
|
57
|
-
];
|
package/dist/cjs/inherit.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var inherit_exports = {};
|
|
20
|
-
__export(inherit_exports, {
|
|
21
|
-
checkIfInherits: () => checkIfInherits,
|
|
22
|
-
createInheritedState: () => createInheritedState,
|
|
23
|
-
createNestedObjectByKeyPath: () => createNestedObjectByKeyPath,
|
|
24
|
-
findInheritedState: () => findInheritedState,
|
|
25
|
-
getChildStateInKey: () => getChildStateInKey,
|
|
26
|
-
getParentStateInKey: () => getParentStateInKey,
|
|
27
|
-
getRootStateInKey: () => getRootStateInKey,
|
|
28
|
-
isState: () => isState
|
|
29
|
-
});
|
|
30
|
-
module.exports = __toCommonJS(inherit_exports);
|
|
31
|
-
var import_utils = require("@domql/utils");
|
|
32
|
-
var import_ignore = require("./ignore.js");
|
|
33
|
-
const getRootStateInKey = (stateKey, parentState) => {
|
|
34
|
-
if (!stateKey.includes("~/")) return;
|
|
35
|
-
const arr = stateKey.split("~/");
|
|
36
|
-
if (arr.length > 1) return parentState.root;
|
|
37
|
-
};
|
|
38
|
-
const getParentStateInKey = (stateKey, parentState) => {
|
|
39
|
-
if (!stateKey.includes("../")) return;
|
|
40
|
-
const arr = stateKey.split("../");
|
|
41
|
-
const arrLength = arr.length - 1;
|
|
42
|
-
for (let i = 0; i < arrLength; i++) {
|
|
43
|
-
if (!parentState.parent) return null;
|
|
44
|
-
parentState = parentState.parent;
|
|
45
|
-
}
|
|
46
|
-
return parentState;
|
|
47
|
-
};
|
|
48
|
-
const getChildStateInKey = (stateKey, parentState, options = {}) => {
|
|
49
|
-
const arr = stateKey.split("/");
|
|
50
|
-
const arrLength = arr.length - 1;
|
|
51
|
-
for (let i = 0; i < arrLength; i++) {
|
|
52
|
-
const childKey = arr[i];
|
|
53
|
-
const grandChildKey = arr[i + 1];
|
|
54
|
-
if (childKey === "__proto__" || grandChildKey === "__proto__") return;
|
|
55
|
-
let childInParent = parentState[childKey];
|
|
56
|
-
if (!childInParent) childInParent = parentState[childKey] = {};
|
|
57
|
-
if (!childInParent[grandChildKey]) childInParent[grandChildKey] = {};
|
|
58
|
-
stateKey = grandChildKey;
|
|
59
|
-
parentState = childInParent;
|
|
60
|
-
}
|
|
61
|
-
if (options.returnParent) return parentState;
|
|
62
|
-
return parentState[stateKey];
|
|
63
|
-
};
|
|
64
|
-
const findInheritedState = (element, parent, options = {}) => {
|
|
65
|
-
const ref = element.__ref;
|
|
66
|
-
let stateKey = ref.__state;
|
|
67
|
-
if (!checkIfInherits(element)) return;
|
|
68
|
-
const rootState = getRootStateInKey(stateKey, parent.state);
|
|
69
|
-
let parentState = parent.state;
|
|
70
|
-
if (rootState) {
|
|
71
|
-
parentState = rootState;
|
|
72
|
-
stateKey = stateKey.replaceAll("~/", "");
|
|
73
|
-
} else {
|
|
74
|
-
const findGrandParentState = getParentStateInKey(stateKey, parent.state);
|
|
75
|
-
if (findGrandParentState) {
|
|
76
|
-
parentState = findGrandParentState;
|
|
77
|
-
stateKey = stateKey.replaceAll("../", "");
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (!parentState) return;
|
|
81
|
-
return getChildStateInKey(stateKey, parentState, options);
|
|
82
|
-
};
|
|
83
|
-
const createInheritedState = (element, parent) => {
|
|
84
|
-
const ref = element.__ref;
|
|
85
|
-
const inheritedState = findInheritedState(element, parent);
|
|
86
|
-
if ((0, import_utils.isUndefined)(inheritedState)) return element.state;
|
|
87
|
-
if ((0, import_utils.is)(inheritedState)("object", "array")) {
|
|
88
|
-
return (0, import_utils.deepClone)(inheritedState, { exclude: import_ignore.IGNORE_STATE_PARAMS });
|
|
89
|
-
} else if ((0, import_utils.is)(inheritedState)("string", "number", "boolean")) {
|
|
90
|
-
ref.__stateType = typeof inheritedState;
|
|
91
|
-
return { value: inheritedState };
|
|
92
|
-
}
|
|
93
|
-
console.warn(ref.__state, "is not present. Replacing with", {});
|
|
94
|
-
};
|
|
95
|
-
const checkIfInherits = (element) => {
|
|
96
|
-
const ref = element.__ref;
|
|
97
|
-
const stateKey = ref.__state;
|
|
98
|
-
if (stateKey && (0, import_utils.is)(stateKey)("number", "string", "boolean")) return true;
|
|
99
|
-
return false;
|
|
100
|
-
};
|
|
101
|
-
const isState = function(state) {
|
|
102
|
-
if (!(0, import_utils.isObjectLike)(state)) return false;
|
|
103
|
-
return state.update && state.parse && state.clean && state.create && state.parent && state.destroy && state.rootUpdate && state.parentUpdate && state.keys && state.values && state.toggle && state.replace && state.quietUpdate && state.quietReplace && state.add && state.apply && state.applyReplace && state.setByPath && state.setPathCollection && state.removeByPath && state.removePathCollection && state.getByPath && state.applyFunction && state.__element && state.__children;
|
|
104
|
-
};
|
|
105
|
-
const createNestedObjectByKeyPath = (path, value) => {
|
|
106
|
-
if (!path) {
|
|
107
|
-
return value || {};
|
|
108
|
-
}
|
|
109
|
-
const keys = path.split("/");
|
|
110
|
-
const obj = {};
|
|
111
|
-
let ref = obj;
|
|
112
|
-
keys.forEach((key, index) => {
|
|
113
|
-
ref[key] = index === keys.length - 1 ? value || {} : {};
|
|
114
|
-
ref = ref[key];
|
|
115
|
-
});
|
|
116
|
-
return obj;
|
|
117
|
-
};
|
package/dist/esm/ignore.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const IGNORE_STATE_PARAMS = [
|
|
2
|
-
"update",
|
|
3
|
-
"parse",
|
|
4
|
-
"clean",
|
|
5
|
-
"create",
|
|
6
|
-
"destroy",
|
|
7
|
-
"add",
|
|
8
|
-
"toggle",
|
|
9
|
-
"remove",
|
|
10
|
-
"apply",
|
|
11
|
-
"set",
|
|
12
|
-
"reset",
|
|
13
|
-
"replace",
|
|
14
|
-
"quietReplace",
|
|
15
|
-
"quietUpdate",
|
|
16
|
-
"applyReplace",
|
|
17
|
-
"applyFunction",
|
|
18
|
-
"keys",
|
|
19
|
-
"values",
|
|
20
|
-
"ref",
|
|
21
|
-
"rootUpdate",
|
|
22
|
-
"parentUpdate",
|
|
23
|
-
"parent",
|
|
24
|
-
"__element",
|
|
25
|
-
"__depends",
|
|
26
|
-
"__ref",
|
|
27
|
-
"__children",
|
|
28
|
-
"root",
|
|
29
|
-
"setByPath",
|
|
30
|
-
"setPathCollection",
|
|
31
|
-
"removeByPath",
|
|
32
|
-
"removePathCollection",
|
|
33
|
-
"getByPath"
|
|
34
|
-
];
|
|
35
|
-
export {
|
|
36
|
-
IGNORE_STATE_PARAMS
|
|
37
|
-
};
|
package/dist/esm/inherit.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { deepClone, is, isObjectLike, isUndefined } from "@domql/utils";
|
|
2
|
-
import { IGNORE_STATE_PARAMS } from "./ignore.js";
|
|
3
|
-
const getRootStateInKey = (stateKey, parentState) => {
|
|
4
|
-
if (!stateKey.includes("~/")) return;
|
|
5
|
-
const arr = stateKey.split("~/");
|
|
6
|
-
if (arr.length > 1) return parentState.root;
|
|
7
|
-
};
|
|
8
|
-
const getParentStateInKey = (stateKey, parentState) => {
|
|
9
|
-
if (!stateKey.includes("../")) return;
|
|
10
|
-
const arr = stateKey.split("../");
|
|
11
|
-
const arrLength = arr.length - 1;
|
|
12
|
-
for (let i = 0; i < arrLength; i++) {
|
|
13
|
-
if (!parentState.parent) return null;
|
|
14
|
-
parentState = parentState.parent;
|
|
15
|
-
}
|
|
16
|
-
return parentState;
|
|
17
|
-
};
|
|
18
|
-
const getChildStateInKey = (stateKey, parentState, options = {}) => {
|
|
19
|
-
const arr = stateKey.split("/");
|
|
20
|
-
const arrLength = arr.length - 1;
|
|
21
|
-
for (let i = 0; i < arrLength; i++) {
|
|
22
|
-
const childKey = arr[i];
|
|
23
|
-
const grandChildKey = arr[i + 1];
|
|
24
|
-
if (childKey === "__proto__" || grandChildKey === "__proto__") return;
|
|
25
|
-
let childInParent = parentState[childKey];
|
|
26
|
-
if (!childInParent) childInParent = parentState[childKey] = {};
|
|
27
|
-
if (!childInParent[grandChildKey]) childInParent[grandChildKey] = {};
|
|
28
|
-
stateKey = grandChildKey;
|
|
29
|
-
parentState = childInParent;
|
|
30
|
-
}
|
|
31
|
-
if (options.returnParent) return parentState;
|
|
32
|
-
return parentState[stateKey];
|
|
33
|
-
};
|
|
34
|
-
const findInheritedState = (element, parent, options = {}) => {
|
|
35
|
-
const ref = element.__ref;
|
|
36
|
-
let stateKey = ref.__state;
|
|
37
|
-
if (!checkIfInherits(element)) return;
|
|
38
|
-
const rootState = getRootStateInKey(stateKey, parent.state);
|
|
39
|
-
let parentState = parent.state;
|
|
40
|
-
if (rootState) {
|
|
41
|
-
parentState = rootState;
|
|
42
|
-
stateKey = stateKey.replaceAll("~/", "");
|
|
43
|
-
} else {
|
|
44
|
-
const findGrandParentState = getParentStateInKey(stateKey, parent.state);
|
|
45
|
-
if (findGrandParentState) {
|
|
46
|
-
parentState = findGrandParentState;
|
|
47
|
-
stateKey = stateKey.replaceAll("../", "");
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (!parentState) return;
|
|
51
|
-
return getChildStateInKey(stateKey, parentState, options);
|
|
52
|
-
};
|
|
53
|
-
const createInheritedState = (element, parent) => {
|
|
54
|
-
const ref = element.__ref;
|
|
55
|
-
const inheritedState = findInheritedState(element, parent);
|
|
56
|
-
if (isUndefined(inheritedState)) return element.state;
|
|
57
|
-
if (is(inheritedState)("object", "array")) {
|
|
58
|
-
return deepClone(inheritedState, { exclude: IGNORE_STATE_PARAMS });
|
|
59
|
-
} else if (is(inheritedState)("string", "number", "boolean")) {
|
|
60
|
-
ref.__stateType = typeof inheritedState;
|
|
61
|
-
return { value: inheritedState };
|
|
62
|
-
}
|
|
63
|
-
console.warn(ref.__state, "is not present. Replacing with", {});
|
|
64
|
-
};
|
|
65
|
-
const checkIfInherits = (element) => {
|
|
66
|
-
const ref = element.__ref;
|
|
67
|
-
const stateKey = ref.__state;
|
|
68
|
-
if (stateKey && is(stateKey)("number", "string", "boolean")) return true;
|
|
69
|
-
return false;
|
|
70
|
-
};
|
|
71
|
-
const isState = function(state) {
|
|
72
|
-
if (!isObjectLike(state)) return false;
|
|
73
|
-
return state.update && state.parse && state.clean && state.create && state.parent && state.destroy && state.rootUpdate && state.parentUpdate && state.keys && state.values && state.toggle && state.replace && state.quietUpdate && state.quietReplace && state.add && state.apply && state.applyReplace && state.setByPath && state.setPathCollection && state.removeByPath && state.removePathCollection && state.getByPath && state.applyFunction && state.__element && state.__children;
|
|
74
|
-
};
|
|
75
|
-
const createNestedObjectByKeyPath = (path, value) => {
|
|
76
|
-
if (!path) {
|
|
77
|
-
return value || {};
|
|
78
|
-
}
|
|
79
|
-
const keys = path.split("/");
|
|
80
|
-
const obj = {};
|
|
81
|
-
let ref = obj;
|
|
82
|
-
keys.forEach((key, index) => {
|
|
83
|
-
ref[key] = index === keys.length - 1 ? value || {} : {};
|
|
84
|
-
ref = ref[key];
|
|
85
|
-
});
|
|
86
|
-
return obj;
|
|
87
|
-
};
|
|
88
|
-
export {
|
|
89
|
-
checkIfInherits,
|
|
90
|
-
createInheritedState,
|
|
91
|
-
createNestedObjectByKeyPath,
|
|
92
|
-
findInheritedState,
|
|
93
|
-
getChildStateInKey,
|
|
94
|
-
getParentStateInKey,
|
|
95
|
-
getRootStateInKey,
|
|
96
|
-
isState
|
|
97
|
-
};
|
package/ignore.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
export const IGNORE_STATE_PARAMS = [
|
|
4
|
-
'update', 'parse', 'clean', 'create', 'destroy', 'add', 'toggle', 'remove', 'apply', 'set', 'reset',
|
|
5
|
-
'replace', 'quietReplace', 'quietUpdate', 'applyReplace', 'applyFunction', 'keys', 'values', 'ref',
|
|
6
|
-
'rootUpdate', 'parentUpdate', 'parent', '__element', '__depends', '__ref', '__children', 'root',
|
|
7
|
-
'setByPath', 'setPathCollection', 'removeByPath', 'removePathCollection', 'getByPath'
|
|
8
|
-
]
|
package/inherit.js
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { deepClone, is, isObjectLike, isUndefined } from '@domql/utils'
|
|
4
|
-
import { IGNORE_STATE_PARAMS } from './ignore.js'
|
|
5
|
-
|
|
6
|
-
export const getRootStateInKey = (stateKey, parentState) => {
|
|
7
|
-
if (!stateKey.includes('~/')) return
|
|
8
|
-
const arr = stateKey.split('~/')
|
|
9
|
-
if (arr.length > 1) return parentState.root
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const getParentStateInKey = (stateKey, parentState) => {
|
|
13
|
-
if (!stateKey.includes('../')) return
|
|
14
|
-
const arr = stateKey.split('../')
|
|
15
|
-
const arrLength = arr.length - 1
|
|
16
|
-
for (let i = 0; i < arrLength; i++) {
|
|
17
|
-
if (!parentState.parent) return null
|
|
18
|
-
parentState = parentState.parent
|
|
19
|
-
}
|
|
20
|
-
return parentState
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const getChildStateInKey = (stateKey, parentState, options = {}) => {
|
|
24
|
-
const arr = stateKey.split('/')
|
|
25
|
-
const arrLength = arr.length - 1
|
|
26
|
-
for (let i = 0; i < arrLength; i++) {
|
|
27
|
-
const childKey = arr[i]
|
|
28
|
-
const grandChildKey = arr[i + 1]
|
|
29
|
-
|
|
30
|
-
if (childKey === '__proto__' || grandChildKey === '__proto__') return
|
|
31
|
-
|
|
32
|
-
let childInParent = parentState[childKey]
|
|
33
|
-
if (!childInParent) childInParent = parentState[childKey] = {} // check for array
|
|
34
|
-
if (!childInParent[grandChildKey]) childInParent[grandChildKey] = {} // check for array
|
|
35
|
-
|
|
36
|
-
stateKey = grandChildKey
|
|
37
|
-
parentState = childInParent
|
|
38
|
-
}
|
|
39
|
-
if (options.returnParent) return parentState
|
|
40
|
-
return parentState[stateKey]
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export const findInheritedState = (element, parent, options = {}) => {
|
|
44
|
-
const ref = element.__ref
|
|
45
|
-
let stateKey = ref.__state
|
|
46
|
-
if (!checkIfInherits(element)) return
|
|
47
|
-
|
|
48
|
-
const rootState = getRootStateInKey(stateKey, parent.state)
|
|
49
|
-
let parentState = parent.state
|
|
50
|
-
|
|
51
|
-
if (rootState) {
|
|
52
|
-
parentState = rootState
|
|
53
|
-
stateKey = stateKey.replaceAll('~/', '')
|
|
54
|
-
} else {
|
|
55
|
-
const findGrandParentState = getParentStateInKey(stateKey, parent.state)
|
|
56
|
-
if (findGrandParentState) {
|
|
57
|
-
parentState = findGrandParentState
|
|
58
|
-
stateKey = stateKey.replaceAll('../', '')
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (!parentState) return
|
|
63
|
-
return getChildStateInKey(stateKey, parentState, options)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export const createInheritedState = (element, parent) => {
|
|
67
|
-
const ref = element.__ref
|
|
68
|
-
const inheritedState = findInheritedState(element, parent)
|
|
69
|
-
if (isUndefined(inheritedState)) return element.state
|
|
70
|
-
|
|
71
|
-
if (is(inheritedState)('object', 'array')) {
|
|
72
|
-
return deepClone(inheritedState, { exclude: IGNORE_STATE_PARAMS })
|
|
73
|
-
} else if (is(inheritedState)('string', 'number', 'boolean')) {
|
|
74
|
-
ref.__stateType = typeof inheritedState
|
|
75
|
-
return { value: inheritedState }
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
console.warn(ref.__state, 'is not present. Replacing with', {})
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export const checkIfInherits = (element) => {
|
|
82
|
-
const ref = element.__ref
|
|
83
|
-
const stateKey = ref.__state
|
|
84
|
-
|
|
85
|
-
if (stateKey && is(stateKey)('number', 'string', 'boolean')) return true
|
|
86
|
-
return false
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
export const isState = function (state) {
|
|
90
|
-
if (!isObjectLike(state)) return false
|
|
91
|
-
return state.update &&
|
|
92
|
-
state.parse &&
|
|
93
|
-
state.clean &&
|
|
94
|
-
state.create &&
|
|
95
|
-
state.parent &&
|
|
96
|
-
state.destroy &&
|
|
97
|
-
state.rootUpdate &&
|
|
98
|
-
state.parentUpdate &&
|
|
99
|
-
state.keys &&
|
|
100
|
-
state.values &&
|
|
101
|
-
state.toggle &&
|
|
102
|
-
state.replace &&
|
|
103
|
-
state.quietUpdate &&
|
|
104
|
-
state.quietReplace &&
|
|
105
|
-
state.add &&
|
|
106
|
-
state.apply &&
|
|
107
|
-
state.applyReplace &&
|
|
108
|
-
state.setByPath &&
|
|
109
|
-
state.setPathCollection &&
|
|
110
|
-
state.removeByPath &&
|
|
111
|
-
state.removePathCollection &&
|
|
112
|
-
state.getByPath &&
|
|
113
|
-
state.applyFunction &&
|
|
114
|
-
state.__element &&
|
|
115
|
-
state.__children
|
|
116
|
-
// return arrayContainsOtherArray(keys, ['update', 'parse', 'clean', 'create', 'parent', 'rootUpdate'])
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export const createNestedObjectByKeyPath = (path, value) => {
|
|
120
|
-
if (!path) {
|
|
121
|
-
return value || {}
|
|
122
|
-
}
|
|
123
|
-
const keys = path.split('/')
|
|
124
|
-
const obj = {}
|
|
125
|
-
let ref = obj
|
|
126
|
-
keys.forEach((key, index) => {
|
|
127
|
-
ref[key] = index === keys.length - 1 ? value || {} : {}
|
|
128
|
-
ref = ref[key]
|
|
129
|
-
})
|
|
130
|
-
return obj
|
|
131
|
-
}
|