@domql/state 2.5.85 → 2.5.90
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 +6 -2
- package/dist/cjs/create.js +3 -1
- package/dist/cjs/ignore.js +2 -0
- package/dist/cjs/inherit.js +1 -1
- package/dist/cjs/methods.js +16 -0
- package/ignore.js +1 -1
- package/inherit.js +2 -0
- package/methods.js +16 -0
- package/package.json +2 -2
package/create.js
CHANGED
|
@@ -6,6 +6,7 @@ import { IGNORE_STATE_PARAMS } from './ignore'
|
|
|
6
6
|
import {
|
|
7
7
|
add,
|
|
8
8
|
apply,
|
|
9
|
+
applyFunction,
|
|
9
10
|
clean,
|
|
10
11
|
destroy,
|
|
11
12
|
parentUpdate,
|
|
@@ -17,7 +18,8 @@ import {
|
|
|
17
18
|
toggle,
|
|
18
19
|
replace,
|
|
19
20
|
quietUpdate,
|
|
20
|
-
quietReplace
|
|
21
|
+
quietReplace,
|
|
22
|
+
applyReplace
|
|
21
23
|
} from './methods'
|
|
22
24
|
import { updateState } from './updateState'
|
|
23
25
|
import { checkIfInherits, createInheritedState } from './inherit'
|
|
@@ -109,12 +111,14 @@ const applyMethods = (element) => {
|
|
|
109
111
|
toggle: toggle.bind(state),
|
|
110
112
|
remove: remove.bind(state),
|
|
111
113
|
apply: apply.bind(state),
|
|
114
|
+
applyReplace: applyReplace.bind(state),
|
|
115
|
+
applyFunction: applyFunction.bind(state),
|
|
112
116
|
set: set.bind(state),
|
|
113
117
|
quietUpdate: quietUpdate.bind(state),
|
|
114
118
|
replace: replace.bind(state),
|
|
115
119
|
quietReplace: quietReplace.bind(state),
|
|
116
120
|
reset: reset.bind(state),
|
|
117
|
-
parent: element.parent.state,
|
|
121
|
+
parent: element.parent.state || state,
|
|
118
122
|
__element: element,
|
|
119
123
|
__children: {},
|
|
120
124
|
root: ref.root ? ref.root.state : state
|
package/dist/cjs/create.js
CHANGED
|
@@ -107,12 +107,14 @@ const applyMethods = (element) => {
|
|
|
107
107
|
toggle: import_methods.toggle.bind(state),
|
|
108
108
|
remove: import_methods.remove.bind(state),
|
|
109
109
|
apply: import_methods.apply.bind(state),
|
|
110
|
+
applyReplace: import_methods.applyReplace.bind(state),
|
|
111
|
+
applyFunction: import_methods.applyFunction.bind(state),
|
|
110
112
|
set: import_methods.set.bind(state),
|
|
111
113
|
quietUpdate: import_methods.quietUpdate.bind(state),
|
|
112
114
|
replace: import_methods.replace.bind(state),
|
|
113
115
|
quietReplace: import_methods.quietReplace.bind(state),
|
|
114
116
|
reset: import_methods.reset.bind(state),
|
|
115
|
-
parent: element.parent.state,
|
|
117
|
+
parent: element.parent.state || state,
|
|
116
118
|
__element: element,
|
|
117
119
|
__children: {},
|
|
118
120
|
root: ref.root ? ref.root.state : state
|
package/dist/cjs/ignore.js
CHANGED
package/dist/cjs/inherit.js
CHANGED
|
@@ -113,7 +113,7 @@ const checkIfInherits = (element) => {
|
|
|
113
113
|
const isState = function(state) {
|
|
114
114
|
if (!(0, import_utils.isObjectLike)(state))
|
|
115
115
|
return false;
|
|
116
|
-
return state.update && state.parse && state.clean && state.create && state.parent && state.destroy && state.rootUpdate && state.parentUpdate && state.toggle && state.replace && state.quietUpdate && state.quietReplace && state.add && state.apply && state.__element && state.__children;
|
|
116
|
+
return state.update && state.parse && state.clean && state.create && state.parent && state.destroy && state.rootUpdate && state.parentUpdate && state.toggle && state.replace && state.quietUpdate && state.quietReplace && state.add && state.apply && state.applyReplace && state.applyFunction && state.__element && state.__children;
|
|
117
117
|
};
|
|
118
118
|
const createNestedObjectByKeyPath = (path, value) => {
|
|
119
119
|
if (!path) {
|
package/dist/cjs/methods.js
CHANGED
|
@@ -20,6 +20,8 @@ var methods_exports = {};
|
|
|
20
20
|
__export(methods_exports, {
|
|
21
21
|
add: () => add,
|
|
22
22
|
apply: () => apply,
|
|
23
|
+
applyFunction: () => applyFunction,
|
|
24
|
+
applyReplace: () => applyReplace,
|
|
23
25
|
clean: () => clean,
|
|
24
26
|
destroy: () => destroy,
|
|
25
27
|
parentUpdate: () => parentUpdate,
|
|
@@ -141,6 +143,20 @@ const reset = function(options = {}) {
|
|
|
141
143
|
return state.set(value, { replace: true, ...options });
|
|
142
144
|
};
|
|
143
145
|
const apply = function(func, options = {}) {
|
|
146
|
+
const state = this;
|
|
147
|
+
if ((0, import_utils.isFunction)(func)) {
|
|
148
|
+
const value = func(state);
|
|
149
|
+
return state.update(value, { replace: true, ...options });
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
const applyReplace = function(func, options = {}) {
|
|
153
|
+
const state = this;
|
|
154
|
+
if ((0, import_utils.isFunction)(func)) {
|
|
155
|
+
const value = func(state);
|
|
156
|
+
return state.replace(value, options);
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
const applyFunction = function(func, options = {}) {
|
|
144
160
|
const state = this;
|
|
145
161
|
if ((0, import_utils.isFunction)(func)) {
|
|
146
162
|
func(state);
|
package/ignore.js
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
export const IGNORE_STATE_PARAMS = [
|
|
4
4
|
'update', 'parse', 'clean', 'create', 'destroy', 'add', 'toggle', 'remove', 'apply', 'set', 'reset',
|
|
5
|
-
'replace', 'quietReplace', 'quietUpdate',
|
|
5
|
+
'replace', 'quietReplace', 'quietUpdate', 'applyReplace', 'applyFunction',
|
|
6
6
|
'rootUpdate', 'parentUpdate', 'parent', '__element', '__depends', '__ref', '__children', 'root'
|
|
7
7
|
]
|
package/inherit.js
CHANGED
|
@@ -102,6 +102,8 @@ export const isState = function (state) {
|
|
|
102
102
|
state.quietReplace &&
|
|
103
103
|
state.add &&
|
|
104
104
|
state.apply &&
|
|
105
|
+
state.applyReplace &&
|
|
106
|
+
state.applyFunction &&
|
|
105
107
|
state.__element &&
|
|
106
108
|
state.__children
|
|
107
109
|
// return arrayContainsOtherArray(keys, ['update', 'parse', 'clean', 'create', 'parent', 'rootUpdate'])
|
package/methods.js
CHANGED
|
@@ -122,6 +122,22 @@ export const reset = function (options = {}) {
|
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
export const apply = function (func, options = {}) {
|
|
125
|
+
const state = this
|
|
126
|
+
if (isFunction(func)) {
|
|
127
|
+
const value = func(state)
|
|
128
|
+
return state.update(value, { replace: true, ...options })
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export const applyReplace = function (func, options = {}) {
|
|
133
|
+
const state = this
|
|
134
|
+
if (isFunction(func)) {
|
|
135
|
+
const value = func(state)
|
|
136
|
+
return state.replace(value, options)
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export const applyFunction = function (func, options = {}) {
|
|
125
141
|
const state = this
|
|
126
142
|
if (isFunction(func)) {
|
|
127
143
|
func(state)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/state",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.90",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"@domql/report": "latest",
|
|
32
32
|
"@domql/utils": "latest"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "01113bfc2fb3bc1f4fc3b694a45cb397ee65ae68"
|
|
35
35
|
}
|