@domql/state 2.5.162 → 2.5.166

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 CHANGED
@@ -83,7 +83,7 @@ const checkForTypes = (element) => {
83
83
  return exec(state, element)
84
84
  } else if (is(state)('string', 'number')) {
85
85
  ref.__state = state
86
- return {}
86
+ return { value: state }
87
87
  } else if (state === true) {
88
88
  ref.__state = element.key
89
89
  return {}
@@ -75,7 +75,7 @@ const checkForTypes = (element) => {
75
75
  return (0, import_utils.exec)(state, element);
76
76
  } else if ((0, import_utils.is)(state)("string", "number")) {
77
77
  ref.__state = state;
78
- return {};
78
+ return { value: state };
79
79
  } else if (state === true) {
80
80
  ref.__state = element.key;
81
81
  return {};
@@ -131,8 +131,13 @@ const toggle = function(key, options = {}) {
131
131
  };
132
132
  const remove = function(key, options = {}) {
133
133
  const state = this;
134
- state[key] = null;
135
- return state.set(state.parse(), { replace: true, ...options });
134
+ if ((0, import_utils.isArray)(state))
135
+ (0, import_utils.removeFromArray)(state, key);
136
+ if ((0, import_utils.isObject)(state))
137
+ (0, import_utils.removeFromObject)(state, key);
138
+ if (options.applyReset)
139
+ return state.set(state.parse(), { replace: true, ...options });
140
+ return state.update();
136
141
  };
137
142
  const set = function(val, options = {}) {
138
143
  const state = this;
package/methods.js CHANGED
@@ -1,6 +1,14 @@
1
1
  'use strict'
2
2
 
3
- import { isArray, deepClone, isFunction, isObject, isString } from '@domql/utils'
3
+ import {
4
+ isArray,
5
+ deepClone,
6
+ isFunction,
7
+ isObject,
8
+ isString,
9
+ removeFromArray,
10
+ removeFromObject
11
+ } from '@domql/utils'
4
12
 
5
13
  import { IGNORE_STATE_PARAMS } from './ignore'
6
14
 
@@ -102,10 +110,10 @@ export const toggle = function (key, options = {}) {
102
110
 
103
111
  export const remove = function (key, options = {}) {
104
112
  const state = this
105
- // if (isArray(state)) removeFromArray(state, key)
106
- // if (isObject(state)) removeFromObject(state, key)
107
- state[key] = null
108
- return state.set(state.parse(), { replace: true, ...options })
113
+ if (isArray(state)) removeFromArray(state, key)
114
+ if (isObject(state)) removeFromObject(state, key)
115
+ if (options.applyReset) return state.set(state.parse(), { replace: true, ...options })
116
+ return state.update()
109
117
  }
110
118
 
111
119
  export const set = function (val, options = {}) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/state",
3
- "version": "2.5.162",
3
+ "version": "2.5.166",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "dist/esm/index.js",
@@ -27,9 +27,9 @@
27
27
  "prepublish": "rimraf -I dist && npm run build && npm run copy:package:cjs"
28
28
  },
29
29
  "dependencies": {
30
- "@domql/event": "^2.5.162",
30
+ "@domql/event": "^2.5.164",
31
31
  "@domql/report": "^2.5.162",
32
- "@domql/utils": "^2.5.162"
32
+ "@domql/utils": "^2.5.164"
33
33
  },
34
- "gitHead": "0aeb25f284d863a57821a0a74937c2b9babb7969"
34
+ "gitHead": "6b77938dcad768c95938a2264c009e30853a5a7a"
35
35
  }