@domql/utils 2.3.65 → 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.65",
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,13 +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",
18
+ "build": "yarn build:cjs",
22
19
  "prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
23
20
  },
24
21
  "dependencies": {
25
22
  "@domql/globals": "latest",
26
23
  "@domql/tags": "latest"
27
24
  },
28
- "gitHead": "d6740b17c388380f26aaaa962a1e518324a90a66"
25
+ "gitHead": "7b43df6cfdae920a1602749f2cf29a9b44a40000"
29
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
- };