@domql/utils 2.3.81 → 2.3.82

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.
@@ -24,6 +24,7 @@ __export(object_exports, {
24
24
  deepDestringify: () => deepDestringify,
25
25
  deepMerge: () => deepMerge,
26
26
  deepStringify: () => deepStringify,
27
+ detachFunctionsFromObject: () => detachFunctionsFromObject,
27
28
  diff: () => diff,
28
29
  exec: () => exec,
29
30
  flattenRecursive: () => flattenRecursive,
@@ -159,6 +160,22 @@ const deepStringify = (obj, stringified = {}) => {
159
160
  }
160
161
  return stringified;
161
162
  };
163
+ const detachFunctionsFromObject = (obj, detached = {}) => {
164
+ for (const prop in obj) {
165
+ const objProp = obj[prop];
166
+ if ((0, import_types.isFunction)(objProp))
167
+ continue;
168
+ else if ((0, import_types.isObject)(objProp)) {
169
+ detached[prop] = {};
170
+ deepStringify(objProp[prop], detached[prop]);
171
+ } else if ((0, import_types.isArray)(objProp)) {
172
+ detached[prop] = [];
173
+ objProp.map((v, i) => deepStringify(v, detached[prop][i]));
174
+ } else
175
+ detached[prop] = objProp;
176
+ }
177
+ return detached;
178
+ };
162
179
  const deepDestringify = (obj, stringified = {}) => {
163
180
  for (const prop in obj) {
164
181
  const objProp = obj[prop];
package/object.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  import { window } from '@domql/globals'
4
- import { isFunction, isObjectLike, isObject, isArray, isString, is } from './types.js'
4
+ import { isFunction, isObjectLike, isObject, isArray, isString } from './types.js'
5
5
 
6
6
  export const exec = (param, element, state, context) => {
7
7
  if (isFunction(param)) {
@@ -138,6 +138,24 @@ export const deepStringify = (obj, stringified = {}) => {
138
138
  return stringified
139
139
  }
140
140
 
141
+ /**
142
+ * Stringify object
143
+ */
144
+ export const detachFunctionsFromObject = (obj, detached = {}) => {
145
+ for (const prop in obj) {
146
+ const objProp = obj[prop]
147
+ if (isFunction(objProp)) continue
148
+ else if (isObject(objProp)) {
149
+ detached[prop] = {}
150
+ deepStringify(objProp[prop], detached[prop])
151
+ } else if (isArray(objProp)) {
152
+ detached[prop] = []
153
+ objProp.map((v, i) => deepStringify(v, detached[prop][i]))
154
+ } else detached[prop] = objProp
155
+ }
156
+ return detached
157
+ }
158
+
141
159
  /**
142
160
  * Detringify object
143
161
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.3.81",
3
+ "version": "2.3.82",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "module": "index.js",
@@ -22,5 +22,5 @@
22
22
  "@domql/globals": "latest",
23
23
  "@domql/tags": "latest"
24
24
  },
25
- "gitHead": "11597b3330a1e6a9148a0595c80ba79070dc5f85"
25
+ "gitHead": "6d358ffa05e6acdceacc1d053fdb00449610b43a"
26
26
  }