@domql/utils 2.3.63 → 2.3.69

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.
@@ -140,6 +140,7 @@ const deepStringify = (obj2, stringified2 = {}) => {
140
140
  } else
141
141
  stringified2[prop2] = objProp2;
142
142
  }
143
+ console.log(obj2, stringified2);
143
144
  return stringified2;
144
145
  };
145
146
  const deepDestringify = (obj, stringified = {}) => {
package/object.js CHANGED
@@ -117,6 +117,7 @@ export const deepStringify = (obj, stringified = {}) => {
117
117
  objProp.map((v, i) => deepStringify(v, stringified[prop][i]))
118
118
  } else stringified[prop] = objProp
119
119
  }
120
+ console.log(obj, stringified)
120
121
  return stringified
121
122
  }
122
123
 
package/package.json CHANGED
@@ -1,12 +1,10 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.3.63",
3
+ "version": "2.3.69",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
- "module": "dist/esm/index.js",
7
- "unpkg": "dist/iife/index.js",
8
- "jsdelivr": "dist/iife/index.js",
9
- "main": "dist/esm/index.js",
6
+ "module": "index.js",
7
+ "main": "index.js",
10
8
  "exports": "./dist/cjs/index.js",
11
9
  "source": "index.js",
12
10
  "files": [
@@ -17,14 +15,12 @@
17
15
  "copy:package:cjs": "cp ../../.build/package-cjs.json dist/cjs/package.json",
18
16
  "build:esm": "npx esbuild *.js --target=es2020 --format=esm --outdir=dist/esm",
19
17
  "build:cjs": "npx esbuild *.js --target=node16 --format=cjs --outdir=dist/cjs",
20
- "build:iife": "npx esbuild *.js --target=node16 --format=iife --outdir=dist/iife",
21
- "build": "yarn build:esm && yarn build:cjs && yarn build:iife",
22
- "postinstall": "yarn build",
18
+ "build": "yarn build:cjs",
23
19
  "prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
24
20
  },
25
21
  "dependencies": {
26
22
  "@domql/globals": "latest",
27
23
  "@domql/tags": "latest"
28
24
  },
29
- "gitHead": "285ed7de47df088045ea478552edc99c5bc77c16"
25
+ "gitHead": "7b43df6cfdae920a1602749f2cf29a9b44a40000"
30
26
  }
package/dist/esm/array.js DELETED
File without changes
@@ -1,26 +0,0 @@
1
- const debounce = (element, func, timeout = 300) => {
2
- let timer;
3
- return (...args) => {
4
- clearTimeout(timer);
5
- timer = setTimeout(() => {
6
- func.apply(element, args);
7
- }, timeout);
8
- };
9
- };
10
- const memoize = (fn) => {
11
- const cache = {};
12
- return (...args) => {
13
- const n = args[0];
14
- if (n in cache) {
15
- return cache[n];
16
- } else {
17
- const result = fn(n);
18
- cache[n] = result;
19
- return result;
20
- }
21
- };
22
- };
23
- export {
24
- debounce,
25
- memoize
26
- };
package/dist/esm/index.js DELETED
@@ -1,6 +0,0 @@
1
- export * from "./types.js";
2
- export * from "./object.js";
3
- export * from "./function.js";
4
- export * from "./array.js";
5
- export * from "./node.js";
6
- export * from "./log.js";
package/dist/esm/log.js DELETED
@@ -1,15 +0,0 @@
1
- const logIf = (bool, ...arg) => {
2
- if (bool)
3
- arg.map((v) => console.log(v));
4
- };
5
- const logGroupIf = (bool, key, ...arg) => {
6
- if (bool) {
7
- console.group(key);
8
- arg.map((v) => console.log(v));
9
- console.groupEnd(key);
10
- }
11
- };
12
- export {
13
- logGroupIf,
14
- logIf
15
- };
package/dist/esm/node.js DELETED
@@ -1,15 +0,0 @@
1
- const cleanWithNode = (extend) => delete extend.node && extend;
2
- const createID = function() {
3
- let index = 0;
4
- function newId() {
5
- index++;
6
- return index;
7
- }
8
- return newId;
9
- }();
10
- const createSnapshotId = createID;
11
- export {
12
- cleanWithNode,
13
- createID,
14
- createSnapshotId
15
- };
@@ -1,238 +0,0 @@
1
- import { isFunction, isObjectLike, isObject, isArray, isString } from "./types.js";
2
- const exec = (param, element, state) => {
3
- if (isFunction(param))
4
- return param(element, state || element.state);
5
- return param;
6
- };
7
- const map = (obj2, extention, element) => {
8
- for (const e in extention) {
9
- obj2[e] = exec(extention[e], element);
10
- }
11
- };
12
- const merge = (element, obj2) => {
13
- for (const e in obj2) {
14
- const elementProp = element[e];
15
- const objProp2 = obj2[e];
16
- if (elementProp === void 0) {
17
- element[e] = objProp2;
18
- }
19
- }
20
- return element;
21
- };
22
- const deepMerge = (element, extend) => {
23
- for (const e in extend) {
24
- const elementProp = element[e];
25
- const extendProp = extend[e];
26
- if (e === "parent" || e === "props")
27
- continue;
28
- if (elementProp === void 0) {
29
- element[e] = extendProp;
30
- } else if (isObjectLike(elementProp) && isObject(extendProp)) {
31
- deepMerge(elementProp, extendProp);
32
- }
33
- }
34
- return element;
35
- };
36
- const clone = (obj2) => {
37
- const o = {};
38
- for (const prop2 in obj2) {
39
- if (prop2 === "node")
40
- continue;
41
- o[prop2] = obj2[prop2];
42
- }
43
- return o;
44
- };
45
- const deepCloneExclude = (obj2, exclude = []) => {
46
- if (isArray(obj2)) {
47
- return obj2.map((x) => deepCloneExclude(x, exclude));
48
- }
49
- const o = {};
50
- for (const k in obj2) {
51
- if (exclude.indexOf(k) > -1)
52
- continue;
53
- let v = obj2[k];
54
- if (k === "extend" && isArray(v)) {
55
- v = mergeArrayExclude(v, exclude);
56
- }
57
- if (isArray(v)) {
58
- o[k] = v.map((x) => deepCloneExclude(x, exclude));
59
- } else if (isObject(v)) {
60
- o[k] = deepCloneExclude(v, exclude);
61
- } else
62
- o[k] = v;
63
- }
64
- return o;
65
- };
66
- const mergeArrayExclude = (arr, excl = []) => {
67
- return arr.reduce((acc, curr) => deepMerge(acc, deepCloneExclude(curr, excl)), {});
68
- };
69
- const deepClone = (obj2) => {
70
- if (isArray(obj2)) {
71
- return obj2.map(deepClone);
72
- }
73
- const o = {};
74
- for (const prop2 in obj2) {
75
- let objProp2 = obj2[prop2];
76
- if (prop2 === "extend" && isArray(objProp2)) {
77
- objProp2 = mergeArray(objProp2);
78
- }
79
- if (isArray(objProp2)) {
80
- o[prop2] = objProp2.map((v) => isObject(v) ? deepClone(v) : v);
81
- } else if (isObject(objProp2)) {
82
- o[prop2] = deepClone(objProp2);
83
- } else
84
- o[prop2] = objProp2;
85
- }
86
- return o;
87
- };
88
- const deepStringify = (obj2, stringified2 = {}) => {
89
- for (const prop2 in obj2) {
90
- const objProp2 = obj2[prop2];
91
- if (isFunction(objProp2)) {
92
- stringified2[prop2] = objProp2.toString();
93
- } else if (isObject(objProp2)) {
94
- stringified2[prop2] = {};
95
- deepStringify(objProp2[prop2], stringified2[prop2]);
96
- } else if (isArray(objProp2)) {
97
- stringified2[prop2] = [];
98
- objProp2.map((v, i) => deepStringify(v, stringified2[prop2][i]));
99
- } else
100
- stringified2[prop2] = objProp2;
101
- }
102
- return stringified2;
103
- };
104
- const deepDestringify = (obj, stringified = {}) => {
105
- for (const prop in obj) {
106
- const objProp = obj[prop];
107
- if (isString(objProp)) {
108
- if (objProp.includes("=>") || objProp.includes("function") || objProp[0] === "(") {
109
- try {
110
- const evalProp = eval(objProp);
111
- stringified[prop] = evalProp;
112
- } catch (e) {
113
- if (e)
114
- stringified[prop] = objProp;
115
- }
116
- }
117
- } else
118
- stringified[prop] = objProp;
119
- if (isObject(objProp))
120
- deepDestringify(stringified[prop], stringified[prop]);
121
- }
122
- return stringified;
123
- };
124
- const overwrite = (element, params, options) => {
125
- const { ref } = element;
126
- const changes = {};
127
- for (const e in params) {
128
- if (e === "props")
129
- continue;
130
- const elementProp = element[e];
131
- const paramsProp = params[e];
132
- if (paramsProp) {
133
- ref.__cache[e] = changes[e] = elementProp;
134
- ref[e] = paramsProp;
135
- }
136
- }
137
- return changes;
138
- };
139
- const diff = (obj2, original, cache) => {
140
- const changes = cache || {};
141
- for (const e in obj2) {
142
- if (e === "ref")
143
- continue;
144
- const originalProp = original[e];
145
- const objProp2 = obj2[e];
146
- if (isObjectLike(originalProp) && isObjectLike(objProp2)) {
147
- changes[e] = {};
148
- diff(originalProp, objProp2, changes[e]);
149
- } else if (objProp2 !== void 0) {
150
- changes[e] = objProp2;
151
- }
152
- }
153
- return changes;
154
- };
155
- const overwriteObj = (params, obj2) => {
156
- const changes = {};
157
- for (const e in params) {
158
- const objProp2 = obj2[e];
159
- const paramsProp = params[e];
160
- if (paramsProp) {
161
- obj2[e] = changes[e] = objProp2;
162
- }
163
- }
164
- return changes;
165
- };
166
- const overwriteDeep = (params, obj2) => {
167
- for (const e in params) {
168
- const objProp2 = obj2[e];
169
- const paramsProp = params[e];
170
- if (isObjectLike(objProp2) && isObjectLike(paramsProp)) {
171
- overwriteDeep(objProp2, paramsProp);
172
- } else if (paramsProp !== void 0) {
173
- obj2[e] = paramsProp;
174
- }
175
- }
176
- return obj2;
177
- };
178
- const mergeIfExisted = (a, b) => {
179
- if (isObjectLike(a) && isObjectLike(b))
180
- return deepMerge(a, b);
181
- return a || b;
182
- };
183
- const mergeArray = (arr) => {
184
- return arr.reduce((a, c) => deepMerge(a, deepClone(c)), {});
185
- };
186
- const mergeAndCloneIfArray = (obj2) => {
187
- return isArray(obj2) ? mergeArray(obj2) : deepClone(obj2);
188
- };
189
- const flattenRecursive = (param, prop2, stack = []) => {
190
- const objectized = mergeAndCloneIfArray(param);
191
- stack.push(objectized);
192
- const extendOfExtend = objectized[prop2];
193
- if (extendOfExtend)
194
- flattenRecursive(extendOfExtend, prop2, stack);
195
- delete objectized[prop2];
196
- return stack;
197
- };
198
- const isEqualDeep = (param, element) => {
199
- if (param === element)
200
- return true;
201
- if (!param || !element)
202
- return false;
203
- for (const prop2 in param) {
204
- const paramProp = param[prop2];
205
- const elementProp = element[prop2];
206
- if (isObjectLike(paramProp)) {
207
- const isEqual = isEqualDeep(paramProp, elementProp);
208
- if (!isEqual)
209
- return false;
210
- } else {
211
- const isEqual = paramProp === elementProp;
212
- if (!isEqual)
213
- return false;
214
- }
215
- }
216
- return true;
217
- };
218
- export {
219
- clone,
220
- deepClone,
221
- deepCloneExclude,
222
- deepDestringify,
223
- deepMerge,
224
- deepStringify,
225
- diff,
226
- exec,
227
- flattenRecursive,
228
- isEqualDeep,
229
- map,
230
- merge,
231
- mergeAndCloneIfArray,
232
- mergeArray,
233
- mergeArrayExclude,
234
- mergeIfExisted,
235
- overwrite,
236
- overwriteDeep,
237
- overwriteObj
238
- };
package/dist/esm/types.js DELETED
@@ -1,72 +0,0 @@
1
- import { window } from "@domql/globals";
2
- import { HTML_TAGS } from "@domql/tags";
3
- const isValidHtmlTag = (arg) => HTML_TAGS.body.indexOf(arg);
4
- const isObject = (arg) => {
5
- if (arg === null)
6
- return false;
7
- return typeof arg === "object" && arg.constructor === Object;
8
- };
9
- const isString = (arg) => typeof arg === "string";
10
- const isNumber = (arg) => typeof arg === "number";
11
- const isFunction = (arg) => typeof arg === "function";
12
- const isBoolean = (arg) => arg === true || arg === false;
13
- const isNull = (arg) => arg === null;
14
- const isArray = (arg) => Array.isArray(arg);
15
- const isObjectLike = (arg) => {
16
- if (arg === null)
17
- return false;
18
- return typeof arg === "object";
19
- };
20
- const isNode = (obj) => {
21
- return typeof window.Node === "object" ? obj instanceof window.Node : obj && typeof obj === "object" && typeof obj.nodeType === "number" && typeof obj.nodeName === "string";
22
- };
23
- const isHtmlElement = (obj) => {
24
- return typeof window.HTMLElement === "object" ? obj instanceof window.HTMLElement : obj && typeof obj === "object" && obj !== null && obj.nodeType === 1 && typeof obj.nodeName === "string";
25
- };
26
- const isDefined = (arg) => {
27
- return isObject(arg) || isObjectLike(arg) || isString(arg) || isNumber(arg) || isFunction(arg) || isArray(arg) || isObjectLike(arg) || isBoolean(arg) || isNull(arg);
28
- };
29
- const isUndefined = (arg) => {
30
- return arg === void 0;
31
- };
32
- const TYPES = {
33
- boolean: isBoolean,
34
- array: isArray,
35
- object: isObject,
36
- string: isString,
37
- number: isNumber,
38
- null: isNull,
39
- function: isFunction,
40
- objectLike: isObjectLike,
41
- node: isNode,
42
- htmlElement: isHtmlElement,
43
- defined: isDefined
44
- };
45
- const is = (arg) => {
46
- return (...args) => {
47
- return args.map((val) => TYPES[val](arg)).filter((v) => v).length > 0;
48
- };
49
- };
50
- const isNot = (arg) => {
51
- return (...args) => {
52
- return args.map((val) => TYPES[val](arg)).filter((v) => v).length === 0;
53
- };
54
- };
55
- export {
56
- TYPES,
57
- is,
58
- isArray,
59
- isBoolean,
60
- isDefined,
61
- isFunction,
62
- isHtmlElement,
63
- isNode,
64
- isNot,
65
- isNull,
66
- isNumber,
67
- isObject,
68
- isObjectLike,
69
- isString,
70
- isUndefined,
71
- isValidHtmlTag
72
- };
@@ -1,3 +0,0 @@
1
- "use strict";
2
- (() => {
3
- })();
@@ -1,25 +0,0 @@
1
- "use strict";
2
- (() => {
3
- const debounce = (element, func, timeout = 300) => {
4
- let timer;
5
- return (...args) => {
6
- clearTimeout(timer);
7
- timer = setTimeout(() => {
8
- func.apply(element, args);
9
- }, timeout);
10
- };
11
- };
12
- const memoize = (fn) => {
13
- const cache = {};
14
- return (...args) => {
15
- const n = args[0];
16
- if (n in cache) {
17
- return cache[n];
18
- } else {
19
- const result = fn(n);
20
- cache[n] = result;
21
- return result;
22
- }
23
- };
24
- };
25
- })();
@@ -1,23 +0,0 @@
1
- "use strict";
2
- (() => {
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __copyProps = (to, from, except, desc) => {
8
- if (from && typeof from === "object" || typeof from === "function") {
9
- for (let key of __getOwnPropNames(from))
10
- if (!__hasOwnProp.call(to, key) && key !== except)
11
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
12
- }
13
- return to;
14
- };
15
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
16
- var utils_exports = {};
17
- __reExport(utils_exports, require("./types.js"));
18
- __reExport(utils_exports, require("./object.js"));
19
- __reExport(utils_exports, require("./function.js"));
20
- __reExport(utils_exports, require("./array.js"));
21
- __reExport(utils_exports, require("./node.js"));
22
- __reExport(utils_exports, require("./log.js"));
23
- })();
package/dist/iife/log.js DELETED
@@ -1,14 +0,0 @@
1
- "use strict";
2
- (() => {
3
- const logIf = (bool, ...arg) => {
4
- if (bool)
5
- arg.map((v) => console.log(v));
6
- };
7
- const logGroupIf = (bool, key, ...arg) => {
8
- if (bool) {
9
- console.group(key);
10
- arg.map((v) => console.log(v));
11
- console.groupEnd(key);
12
- }
13
- };
14
- })();
package/dist/iife/node.js DELETED
@@ -1,13 +0,0 @@
1
- "use strict";
2
- (() => {
3
- const cleanWithNode = (extend) => delete extend.node && extend;
4
- const createID = function() {
5
- let index = 0;
6
- function newId() {
7
- index++;
8
- return index;
9
- }
10
- return newId;
11
- }();
12
- const createSnapshotId = createID;
13
- })();
@@ -1,220 +0,0 @@
1
- "use strict";
2
- (() => {
3
- var import_types = require("./types.js");
4
- const exec = (param, element, state) => {
5
- if ((0, import_types.isFunction)(param))
6
- return param(element, state || element.state);
7
- return param;
8
- };
9
- const map = (obj2, extention, element) => {
10
- for (const e in extention) {
11
- obj2[e] = exec(extention[e], element);
12
- }
13
- };
14
- const merge = (element, obj2) => {
15
- for (const e in obj2) {
16
- const elementProp = element[e];
17
- const objProp2 = obj2[e];
18
- if (elementProp === void 0) {
19
- element[e] = objProp2;
20
- }
21
- }
22
- return element;
23
- };
24
- const deepMerge = (element, extend) => {
25
- for (const e in extend) {
26
- const elementProp = element[e];
27
- const extendProp = extend[e];
28
- if (e === "parent" || e === "props")
29
- continue;
30
- if (elementProp === void 0) {
31
- element[e] = extendProp;
32
- } else if ((0, import_types.isObjectLike)(elementProp) && (0, import_types.isObject)(extendProp)) {
33
- deepMerge(elementProp, extendProp);
34
- }
35
- }
36
- return element;
37
- };
38
- const clone = (obj2) => {
39
- const o = {};
40
- for (const prop2 in obj2) {
41
- if (prop2 === "node")
42
- continue;
43
- o[prop2] = obj2[prop2];
44
- }
45
- return o;
46
- };
47
- const deepCloneExclude = (obj2, exclude = []) => {
48
- if ((0, import_types.isArray)(obj2)) {
49
- return obj2.map((x) => deepCloneExclude(x, exclude));
50
- }
51
- const o = {};
52
- for (const k in obj2) {
53
- if (exclude.indexOf(k) > -1)
54
- continue;
55
- let v = obj2[k];
56
- if (k === "extend" && (0, import_types.isArray)(v)) {
57
- v = mergeArrayExclude(v, exclude);
58
- }
59
- if ((0, import_types.isArray)(v)) {
60
- o[k] = v.map((x) => deepCloneExclude(x, exclude));
61
- } else if ((0, import_types.isObject)(v)) {
62
- o[k] = deepCloneExclude(v, exclude);
63
- } else
64
- o[k] = v;
65
- }
66
- return o;
67
- };
68
- const mergeArrayExclude = (arr, excl = []) => {
69
- return arr.reduce((acc, curr) => deepMerge(acc, deepCloneExclude(curr, excl)), {});
70
- };
71
- const deepClone = (obj2) => {
72
- if ((0, import_types.isArray)(obj2)) {
73
- return obj2.map(deepClone);
74
- }
75
- const o = {};
76
- for (const prop2 in obj2) {
77
- let objProp2 = obj2[prop2];
78
- if (prop2 === "extend" && (0, import_types.isArray)(objProp2)) {
79
- objProp2 = mergeArray(objProp2);
80
- }
81
- if ((0, import_types.isArray)(objProp2)) {
82
- o[prop2] = objProp2.map((v) => (0, import_types.isObject)(v) ? deepClone(v) : v);
83
- } else if ((0, import_types.isObject)(objProp2)) {
84
- o[prop2] = deepClone(objProp2);
85
- } else
86
- o[prop2] = objProp2;
87
- }
88
- return o;
89
- };
90
- const deepStringify = (obj2, stringified2 = {}) => {
91
- for (const prop2 in obj2) {
92
- const objProp2 = obj2[prop2];
93
- if ((0, import_types.isFunction)(objProp2)) {
94
- stringified2[prop2] = objProp2.toString();
95
- } else if ((0, import_types.isObject)(objProp2)) {
96
- stringified2[prop2] = {};
97
- deepStringify(objProp2[prop2], stringified2[prop2]);
98
- } else if ((0, import_types.isArray)(objProp2)) {
99
- stringified2[prop2] = [];
100
- objProp2.map((v, i) => deepStringify(v, stringified2[prop2][i]));
101
- } else
102
- stringified2[prop2] = objProp2;
103
- }
104
- return stringified2;
105
- };
106
- const deepDestringify = (obj, stringified = {}) => {
107
- for (const prop in obj) {
108
- const objProp = obj[prop];
109
- if ((0, import_types.isString)(objProp)) {
110
- if (objProp.includes("=>") || objProp.includes("function") || objProp[0] === "(") {
111
- try {
112
- const evalProp = eval(objProp);
113
- stringified[prop] = evalProp;
114
- } catch (e) {
115
- if (e)
116
- stringified[prop] = objProp;
117
- }
118
- }
119
- } else
120
- stringified[prop] = objProp;
121
- if ((0, import_types.isObject)(objProp))
122
- deepDestringify(stringified[prop], stringified[prop]);
123
- }
124
- return stringified;
125
- };
126
- const overwrite = (element, params, options) => {
127
- const { ref } = element;
128
- const changes = {};
129
- for (const e in params) {
130
- if (e === "props")
131
- continue;
132
- const elementProp = element[e];
133
- const paramsProp = params[e];
134
- if (paramsProp) {
135
- ref.__cache[e] = changes[e] = elementProp;
136
- ref[e] = paramsProp;
137
- }
138
- }
139
- return changes;
140
- };
141
- const diff = (obj2, original, cache) => {
142
- const changes = cache || {};
143
- for (const e in obj2) {
144
- if (e === "ref")
145
- continue;
146
- const originalProp = original[e];
147
- const objProp2 = obj2[e];
148
- if ((0, import_types.isObjectLike)(originalProp) && (0, import_types.isObjectLike)(objProp2)) {
149
- changes[e] = {};
150
- diff(originalProp, objProp2, changes[e]);
151
- } else if (objProp2 !== void 0) {
152
- changes[e] = objProp2;
153
- }
154
- }
155
- return changes;
156
- };
157
- const overwriteObj = (params, obj2) => {
158
- const changes = {};
159
- for (const e in params) {
160
- const objProp2 = obj2[e];
161
- const paramsProp = params[e];
162
- if (paramsProp) {
163
- obj2[e] = changes[e] = objProp2;
164
- }
165
- }
166
- return changes;
167
- };
168
- const overwriteDeep = (params, obj2) => {
169
- for (const e in params) {
170
- const objProp2 = obj2[e];
171
- const paramsProp = params[e];
172
- if ((0, import_types.isObjectLike)(objProp2) && (0, import_types.isObjectLike)(paramsProp)) {
173
- overwriteDeep(objProp2, paramsProp);
174
- } else if (paramsProp !== void 0) {
175
- obj2[e] = paramsProp;
176
- }
177
- }
178
- return obj2;
179
- };
180
- const mergeIfExisted = (a, b) => {
181
- if ((0, import_types.isObjectLike)(a) && (0, import_types.isObjectLike)(b))
182
- return deepMerge(a, b);
183
- return a || b;
184
- };
185
- const mergeArray = (arr) => {
186
- return arr.reduce((a, c) => deepMerge(a, deepClone(c)), {});
187
- };
188
- const mergeAndCloneIfArray = (obj2) => {
189
- return (0, import_types.isArray)(obj2) ? mergeArray(obj2) : deepClone(obj2);
190
- };
191
- const flattenRecursive = (param, prop2, stack = []) => {
192
- const objectized = mergeAndCloneIfArray(param);
193
- stack.push(objectized);
194
- const extendOfExtend = objectized[prop2];
195
- if (extendOfExtend)
196
- flattenRecursive(extendOfExtend, prop2, stack);
197
- delete objectized[prop2];
198
- return stack;
199
- };
200
- const isEqualDeep = (param, element) => {
201
- if (param === element)
202
- return true;
203
- if (!param || !element)
204
- return false;
205
- for (const prop2 in param) {
206
- const paramProp = param[prop2];
207
- const elementProp = element[prop2];
208
- if ((0, import_types.isObjectLike)(paramProp)) {
209
- const isEqual = isEqualDeep(paramProp, elementProp);
210
- if (!isEqual)
211
- return false;
212
- } else {
213
- const isEqual = paramProp === elementProp;
214
- if (!isEqual)
215
- return false;
216
- }
217
- }
218
- return true;
219
- };
220
- })();
@@ -1,57 +0,0 @@
1
- "use strict";
2
- (() => {
3
- var import_globals = require("@domql/globals");
4
- var import_tags = require("@domql/tags");
5
- const isValidHtmlTag = (arg) => import_tags.HTML_TAGS.body.indexOf(arg);
6
- const isObject = (arg) => {
7
- if (arg === null)
8
- return false;
9
- return typeof arg === "object" && arg.constructor === Object;
10
- };
11
- const isString = (arg) => typeof arg === "string";
12
- const isNumber = (arg) => typeof arg === "number";
13
- const isFunction = (arg) => typeof arg === "function";
14
- const isBoolean = (arg) => arg === true || arg === false;
15
- const isNull = (arg) => arg === null;
16
- const isArray = (arg) => Array.isArray(arg);
17
- const isObjectLike = (arg) => {
18
- if (arg === null)
19
- return false;
20
- return typeof arg === "object";
21
- };
22
- const isNode = (obj) => {
23
- return typeof import_globals.window.Node === "object" ? obj instanceof import_globals.window.Node : obj && typeof obj === "object" && typeof obj.nodeType === "number" && typeof obj.nodeName === "string";
24
- };
25
- const isHtmlElement = (obj) => {
26
- return typeof import_globals.window.HTMLElement === "object" ? obj instanceof import_globals.window.HTMLElement : obj && typeof obj === "object" && obj !== null && obj.nodeType === 1 && typeof obj.nodeName === "string";
27
- };
28
- const isDefined = (arg) => {
29
- return isObject(arg) || isObjectLike(arg) || isString(arg) || isNumber(arg) || isFunction(arg) || isArray(arg) || isObjectLike(arg) || isBoolean(arg) || isNull(arg);
30
- };
31
- const isUndefined = (arg) => {
32
- return arg === void 0;
33
- };
34
- const TYPES = {
35
- boolean: isBoolean,
36
- array: isArray,
37
- object: isObject,
38
- string: isString,
39
- number: isNumber,
40
- null: isNull,
41
- function: isFunction,
42
- objectLike: isObjectLike,
43
- node: isNode,
44
- htmlElement: isHtmlElement,
45
- defined: isDefined
46
- };
47
- const is = (arg) => {
48
- return (...args) => {
49
- return args.map((val) => TYPES[val](arg)).filter((v) => v).length > 0;
50
- };
51
- };
52
- const isNot = (arg) => {
53
- return (...args) => {
54
- return args.map((val) => TYPES[val](arg)).filter((v) => v).length === 0;
55
- };
56
- };
57
- })();