@domql/utils 2.3.35 → 2.3.40

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 symbo.ls
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/array.js ADDED
@@ -0,0 +1 @@
1
+ 'use strict'
package/dist/array.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var function_exports = {};
20
+ __export(function_exports, {
21
+ debounce: () => debounce,
22
+ memoize: () => memoize
23
+ });
24
+ module.exports = __toCommonJS(function_exports);
25
+ const debounce = (element, func, timeout = 300) => {
26
+ let timer;
27
+ return (...args) => {
28
+ clearTimeout(timer);
29
+ timer = setTimeout(() => {
30
+ func.apply(element, args);
31
+ }, timeout);
32
+ };
33
+ };
34
+ const memoize = (fn) => {
35
+ const cache = {};
36
+ return (...args) => {
37
+ const n = args[0];
38
+ if (n in cache) {
39
+ return cache[n];
40
+ } else {
41
+ const result = fn(n);
42
+ cache[n] = result;
43
+ return result;
44
+ }
45
+ };
46
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../function.js"],
4
+ "sourcesContent": ["'use strict'\n\nexport const debounce = (element, func, timeout = 300) => {\n let timer\n return (...args) => {\n clearTimeout(timer)\n timer = setTimeout(() => { func.apply(element, args) }, timeout)\n }\n}\n\nexport const memoize = (fn) => {\n const cache = {}\n return (...args) => {\n const n = args[0]\n if (n in cache) {\n return cache[n]\n } else {\n const result = fn(n)\n cache[n] = result\n return result\n }\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,WAAW,CAAC,SAAS,MAAM,UAAU,QAAQ;AACxD,MAAI;AACJ,SAAO,IAAI,SAAS;AAClB,iBAAa,KAAK;AAClB,YAAQ,WAAW,MAAM;AAAE,WAAK,MAAM,SAAS,IAAI;AAAA,IAAE,GAAG,OAAO;AAAA,EACjE;AACF;AAEO,MAAM,UAAU,CAAC,OAAO;AAC7B,QAAM,QAAQ,CAAC;AACf,SAAO,IAAI,SAAS;AAClB,UAAM,IAAI,KAAK,CAAC;AAChB,QAAI,KAAK,OAAO;AACd,aAAO,MAAM,CAAC;AAAA,IAChB,OAAO;AACL,YAAM,SAAS,GAAG,CAAC;AACnB,YAAM,CAAC,IAAI;AACX,aAAO;AAAA,IACT;AAAA,EACF;AACF;",
6
+ "names": []
7
+ }
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var utils_exports = {};
17
+ module.exports = __toCommonJS(utils_exports);
18
+ __reExport(utils_exports, require("./types"), module.exports);
19
+ __reExport(utils_exports, require("./object"), module.exports);
20
+ __reExport(utils_exports, require("./function"), module.exports);
21
+ __reExport(utils_exports, require("./array"), module.exports);
22
+ __reExport(utils_exports, require("./node"), module.exports);
23
+ __reExport(utils_exports, require("./log"), module.exports);
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../index.js"],
4
+ "sourcesContent": ["'use strict'\n\nexport * from './types'\nexport * from './object'\nexport * from './function'\nexport * from './array'\nexport * from './node'\nexport * from './log'\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAEA,0BAAc,oBAFd;AAGA,0BAAc,qBAHd;AAIA,0BAAc,uBAJd;AAKA,0BAAc,oBALd;AAMA,0BAAc,mBANd;AAOA,0BAAc,kBAPd;",
6
+ "names": []
7
+ }
package/dist/log.js ADDED
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var log_exports = {};
20
+ __export(log_exports, {
21
+ logGroupIf: () => logGroupIf,
22
+ logIf: () => logIf
23
+ });
24
+ module.exports = __toCommonJS(log_exports);
25
+ const logIf = (bool, ...arg) => {
26
+ if (bool)
27
+ arg.map((v) => console.log(v));
28
+ };
29
+ const logGroupIf = (bool, key, ...arg) => {
30
+ if (bool) {
31
+ console.group(key);
32
+ arg.map((v) => console.log(v));
33
+ console.groupEnd(key);
34
+ }
35
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../log.js"],
4
+ "sourcesContent": ["'use strict'\n\nexport const logIf = (bool, ...arg) => { if (bool) arg.map(v => console.log(v)) }\nexport const logGroupIf = (bool, key, ...arg) => {\n if (bool) {\n console.group(key)\n arg.map(v => console.log(v))\n console.groupEnd(key)\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,QAAQ,CAAC,SAAS,QAAQ;AAAE,MAAI;AAAM,QAAI,IAAI,OAAK,QAAQ,IAAI,CAAC,CAAC;AAAE;AACzE,MAAM,aAAa,CAAC,MAAM,QAAQ,QAAQ;AAC/C,MAAI,MAAM;AACR,YAAQ,MAAM,GAAG;AACjB,QAAI,IAAI,OAAK,QAAQ,IAAI,CAAC,CAAC;AAC3B,YAAQ,SAAS,GAAG;AAAA,EACtB;AACF;",
6
+ "names": []
7
+ }
package/dist/node.js ADDED
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var node_exports = {};
20
+ __export(node_exports, {
21
+ cleanWithNode: () => cleanWithNode,
22
+ createID: () => createID,
23
+ createSnapshotId: () => createSnapshotId
24
+ });
25
+ module.exports = __toCommonJS(node_exports);
26
+ const cleanWithNode = (extend) => delete extend.node && extend;
27
+ const createID = function() {
28
+ let index = 0;
29
+ function newId() {
30
+ index++;
31
+ return index;
32
+ }
33
+ return newId;
34
+ }();
35
+ const createSnapshotId = createID;
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../node.js"],
4
+ "sourcesContent": ["'use strict'\n\nexport const cleanWithNode = extend => delete extend.node && extend\n\nexport const createID = (function () {\n let index = 0\n\n function newId () {\n index++\n return index\n }\n\n return newId\n})()\n\nexport const createSnapshotId = createID\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,MAAM,gBAAgB,YAAU,OAAO,OAAO,QAAQ;AAEtD,MAAM,WAAY,WAAY;AACnC,MAAI,QAAQ;AAEZ,WAAS,QAAS;AAChB;AACA,WAAO;AAAA,EACT;AAEA,SAAO;AACT,EAAG;AAEI,MAAM,mBAAmB;",
6
+ "names": []
7
+ }
package/dist/object.js ADDED
@@ -0,0 +1,258 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var object_exports = {};
20
+ __export(object_exports, {
21
+ clone: () => clone,
22
+ deepClone: () => deepClone,
23
+ deepCloneExclude: () => deepCloneExclude,
24
+ deepDestringify: () => deepDestringify,
25
+ deepMerge: () => deepMerge,
26
+ deepStringify: () => deepStringify,
27
+ diff: () => diff,
28
+ exec: () => exec,
29
+ flattenRecursive: () => flattenRecursive,
30
+ isEqualDeep: () => isEqualDeep,
31
+ map: () => map,
32
+ merge: () => merge,
33
+ mergeAndCloneIfArray: () => mergeAndCloneIfArray,
34
+ mergeArray: () => mergeArray,
35
+ mergeArrayExclude: () => mergeArrayExclude,
36
+ mergeIfExisted: () => mergeIfExisted,
37
+ overwrite: () => overwrite,
38
+ overwriteDeep: () => overwriteDeep,
39
+ overwriteObj: () => overwriteObj
40
+ });
41
+ module.exports = __toCommonJS(object_exports);
42
+ var import_types = require("./types");
43
+ const exec = (param, element, state) => {
44
+ if ((0, import_types.isFunction)(param))
45
+ return param(element, state || element.state);
46
+ return param;
47
+ };
48
+ const map = (obj2, extention, element) => {
49
+ for (const e in extention) {
50
+ obj2[e] = exec(extention[e], element);
51
+ }
52
+ };
53
+ const merge = (element, obj2) => {
54
+ for (const e in obj2) {
55
+ const elementProp = element[e];
56
+ const objProp2 = obj2[e];
57
+ if (elementProp === void 0) {
58
+ element[e] = objProp2;
59
+ }
60
+ }
61
+ return element;
62
+ };
63
+ const deepMerge = (element, extend) => {
64
+ for (const e in extend) {
65
+ const elementProp = element[e];
66
+ const extendProp = extend[e];
67
+ if (e === "parent" || e === "props")
68
+ continue;
69
+ if (elementProp === void 0) {
70
+ element[e] = extendProp;
71
+ } else if ((0, import_types.isObjectLike)(elementProp) && (0, import_types.isObject)(extendProp)) {
72
+ deepMerge(elementProp, extendProp);
73
+ }
74
+ }
75
+ return element;
76
+ };
77
+ const clone = (obj2) => {
78
+ const o = {};
79
+ for (const prop2 in obj2) {
80
+ if (prop2 === "node")
81
+ continue;
82
+ o[prop2] = obj2[prop2];
83
+ }
84
+ return o;
85
+ };
86
+ const deepCloneExclude = (obj2, exclude = []) => {
87
+ if ((0, import_types.isArray)(obj2)) {
88
+ return obj2.map((x) => deepCloneExclude(x, exclude));
89
+ }
90
+ const o = {};
91
+ for (const k in obj2) {
92
+ if (exclude.indexOf(k) > -1)
93
+ continue;
94
+ let v = obj2[k];
95
+ if (k === "extend" && (0, import_types.isArray)(v)) {
96
+ v = mergeArrayExclude(v, exclude);
97
+ }
98
+ if ((0, import_types.isArray)(v)) {
99
+ o[k] = v.map((x) => deepCloneExclude(x, exclude));
100
+ } else if ((0, import_types.isObject)(v)) {
101
+ o[k] = deepCloneExclude(v, exclude);
102
+ } else
103
+ o[k] = v;
104
+ }
105
+ return o;
106
+ };
107
+ const mergeArrayExclude = (arr, excl = []) => {
108
+ return arr.reduce((acc, curr) => deepMerge(acc, deepCloneExclude(curr, excl)), {});
109
+ };
110
+ const deepClone = (obj2) => {
111
+ if ((0, import_types.isArray)(obj2)) {
112
+ return obj2.map(deepClone);
113
+ }
114
+ const o = {};
115
+ for (const prop2 in obj2) {
116
+ let objProp2 = obj2[prop2];
117
+ if (prop2 === "extend" && (0, import_types.isArray)(objProp2)) {
118
+ objProp2 = mergeArray(objProp2);
119
+ }
120
+ if ((0, import_types.isArray)(objProp2)) {
121
+ o[prop2] = objProp2.map((v) => (0, import_types.isObject)(v) ? deepClone(v) : v);
122
+ } else if ((0, import_types.isObject)(objProp2)) {
123
+ o[prop2] = deepClone(objProp2);
124
+ } else
125
+ o[prop2] = objProp2;
126
+ }
127
+ return o;
128
+ };
129
+ const deepStringify = (obj2, stringified2 = {}) => {
130
+ for (const prop2 in obj2) {
131
+ const objProp2 = obj2[prop2];
132
+ if ((0, import_types.isFunction)(objProp2)) {
133
+ stringified2[prop2] = objProp2.toString();
134
+ } else if ((0, import_types.isObject)(objProp2)) {
135
+ stringified2[prop2] = {};
136
+ deepStringify(objProp2[prop2], stringified2[prop2]);
137
+ } else if ((0, import_types.isArray)(objProp2)) {
138
+ stringified2[prop2] = [];
139
+ objProp2.map((v, i) => deepStringify(v, stringified2[prop2][i]));
140
+ } else
141
+ stringified2[prop2] = objProp2;
142
+ }
143
+ return stringified2;
144
+ };
145
+ const deepDestringify = (obj, stringified = {}) => {
146
+ for (const prop in obj) {
147
+ const objProp = obj[prop];
148
+ if ((0, import_types.isString)(objProp)) {
149
+ if (objProp.includes("=>") || objProp.includes("function") || objProp[0] === "(") {
150
+ try {
151
+ const evalProp = eval(objProp);
152
+ stringified[prop] = evalProp;
153
+ } catch (e) {
154
+ if (e)
155
+ stringified[prop] = objProp;
156
+ }
157
+ }
158
+ } else
159
+ stringified[prop] = objProp;
160
+ if ((0, import_types.isObject)(objProp))
161
+ deepDestringify(stringified[prop], stringified[prop]);
162
+ }
163
+ return stringified;
164
+ };
165
+ const overwrite = (element, params, options) => {
166
+ const { ref } = element;
167
+ const changes = {};
168
+ for (const e in params) {
169
+ if (e === "props")
170
+ continue;
171
+ const elementProp = element[e];
172
+ const paramsProp = params[e];
173
+ if (paramsProp) {
174
+ ref.__cache[e] = changes[e] = elementProp;
175
+ ref[e] = paramsProp;
176
+ }
177
+ }
178
+ return changes;
179
+ };
180
+ const diff = (obj2, original, cache) => {
181
+ const changes = cache || {};
182
+ for (const e in obj2) {
183
+ if (e === "ref")
184
+ continue;
185
+ const originalProp = original[e];
186
+ const objProp2 = obj2[e];
187
+ if ((0, import_types.isObjectLike)(originalProp) && (0, import_types.isObjectLike)(objProp2)) {
188
+ changes[e] = {};
189
+ diff(originalProp, objProp2, changes[e]);
190
+ } else if (objProp2 !== void 0) {
191
+ changes[e] = objProp2;
192
+ }
193
+ }
194
+ return changes;
195
+ };
196
+ const overwriteObj = (params, obj2) => {
197
+ const changes = {};
198
+ for (const e in params) {
199
+ const objProp2 = obj2[e];
200
+ const paramsProp = params[e];
201
+ if (paramsProp) {
202
+ obj2[e] = changes[e] = objProp2;
203
+ }
204
+ }
205
+ return changes;
206
+ };
207
+ const overwriteDeep = (params, obj2) => {
208
+ for (const e in params) {
209
+ const objProp2 = obj2[e];
210
+ const paramsProp = params[e];
211
+ if ((0, import_types.isObjectLike)(objProp2) && (0, import_types.isObjectLike)(paramsProp)) {
212
+ overwriteDeep(objProp2, paramsProp);
213
+ } else if (paramsProp !== void 0) {
214
+ obj2[e] = paramsProp;
215
+ }
216
+ }
217
+ return obj2;
218
+ };
219
+ const mergeIfExisted = (a, b) => {
220
+ if ((0, import_types.isObjectLike)(a) && (0, import_types.isObjectLike)(b))
221
+ return deepMerge(a, b);
222
+ return a || b;
223
+ };
224
+ const mergeArray = (arr) => {
225
+ return arr.reduce((a, c) => deepMerge(a, deepClone(c)), {});
226
+ };
227
+ const mergeAndCloneIfArray = (obj2) => {
228
+ return (0, import_types.isArray)(obj2) ? mergeArray(obj2) : deepClone(obj2);
229
+ };
230
+ const flattenRecursive = (param, prop2, stack = []) => {
231
+ const objectized = mergeAndCloneIfArray(param);
232
+ stack.push(objectized);
233
+ const extendOfExtend = objectized[prop2];
234
+ if (extendOfExtend)
235
+ flattenRecursive(extendOfExtend, prop2, stack);
236
+ delete objectized[prop2];
237
+ return stack;
238
+ };
239
+ const isEqualDeep = (param, element) => {
240
+ if (param === element)
241
+ return true;
242
+ if (!param || !element)
243
+ return false;
244
+ for (const prop2 in param) {
245
+ const paramProp = param[prop2];
246
+ const elementProp = element[prop2];
247
+ if ((0, import_types.isObjectLike)(paramProp)) {
248
+ const isEqual = isEqualDeep(paramProp, elementProp);
249
+ if (!isEqual)
250
+ return false;
251
+ } else {
252
+ const isEqual = paramProp === elementProp;
253
+ if (!isEqual)
254
+ return false;
255
+ }
256
+ }
257
+ return true;
258
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../object.js"],
4
+ "sourcesContent": ["'use strict'\n\nimport { isFunction, isObjectLike, isObject, isArray, isString } from './types'\n\nexport const exec = (param, element, state) => {\n if (isFunction(param)) return param(element, state || element.state)\n return param\n}\n\nexport const map = (obj, extention, element) => {\n for (const e in extention) {\n obj[e] = exec(extention[e], element)\n }\n}\n\nexport const merge = (element, obj) => {\n for (const e in obj) {\n const elementProp = element[e]\n const objProp = obj[e]\n if (elementProp === undefined) {\n element[e] = objProp\n }\n }\n return element\n}\n\nexport const deepMerge = (element, extend) => {\n for (const e in extend) {\n const elementProp = element[e]\n const extendProp = extend[e]\n // const cachedProps = cache.props\n if (e === 'parent' || e === 'props') continue\n if (elementProp === undefined) {\n element[e] = extendProp\n } else if (isObjectLike(elementProp) && isObject(extendProp)) {\n deepMerge(elementProp, extendProp)\n }\n }\n return element\n}\n\nexport const clone = obj => {\n const o = {}\n for (const prop in obj) {\n if (prop === 'node') continue\n o[prop] = obj[prop]\n }\n return o\n}\n\n// Clone anything deeply but exclude keys given in 'exclude'\nexport const deepCloneExclude = (obj, exclude = []) => {\n if (isArray(obj)) {\n return obj.map(x => deepCloneExclude(x, exclude))\n }\n\n const o = {}\n for (const k in obj) {\n if (exclude.indexOf(k) > -1) continue\n\n let v = obj[k]\n\n if (k === 'extend' && isArray(v)) {\n v = mergeArrayExclude(v, exclude)\n }\n\n if (isArray(v)) {\n o[k] = v.map(x => deepCloneExclude(x, exclude))\n } else if (isObject(v)) {\n o[k] = deepCloneExclude(v, exclude)\n } else o[k] = v\n }\n\n return o\n}\n\n// Merge array, but exclude keys listed in 'excl'\nexport const mergeArrayExclude = (arr, excl = []) => {\n return arr.reduce((acc, curr) => deepMerge(acc, deepCloneExclude(curr, excl)), {})\n}\n\n/**\n * Deep cloning of object\n */\nexport const deepClone = (obj) => {\n if (isArray(obj)) {\n return obj.map(deepClone)\n }\n const o = {}\n for (const prop in obj) {\n let objProp = obj[prop]\n if (prop === 'extend' && isArray(objProp)) {\n objProp = mergeArray(objProp)\n }\n if (isArray(objProp)) {\n o[prop] = objProp.map(v => isObject(v) ? deepClone(v) : v)\n } else if (isObject(objProp)) {\n o[prop] = deepClone(objProp)\n } else o[prop] = objProp\n }\n return o\n}\n\n/**\n * Stringify object\n */\nexport const deepStringify = (obj, stringified = {}) => {\n for (const prop in obj) {\n const objProp = obj[prop]\n if (isFunction(objProp)) {\n stringified[prop] = objProp.toString()\n } else if (isObject(objProp)) {\n stringified[prop] = {}\n deepStringify(objProp[prop], stringified[prop])\n } else if (isArray(objProp)) {\n stringified[prop] = []\n objProp.map((v, i) => deepStringify(v, stringified[prop][i]))\n } else stringified[prop] = objProp\n }\n return stringified\n}\n\n/**\n * Detringify object\n */\nexport const deepDestringify = (obj, stringified = {}) => {\n for (const prop in obj) {\n const objProp = obj[prop]\n if (isString(objProp)) {\n if (objProp.includes('=>') || objProp.includes('function') || objProp[0] === '(') {\n try {\n const evalProp = eval(objProp) // eslint-disable-line\n stringified[prop] = evalProp\n } catch (e) { if (e) stringified[prop] = objProp }\n }\n } else stringified[prop] = objProp\n if (isObject(objProp)) deepDestringify(stringified[prop], stringified[prop])\n }\n return stringified\n}\n\n/**\n * Overwrites object properties with another\n */\nexport const overwrite = (element, params, options) => {\n const { ref } = element\n const changes = {}\n\n for (const e in params) {\n if (e === 'props') continue\n\n const elementProp = element[e]\n const paramsProp = params[e]\n\n if (paramsProp) {\n ref.__cache[e] = changes[e] = elementProp\n ref[e] = paramsProp\n }\n }\n\n return changes\n}\n\nexport const diff = (obj, original, cache) => {\n const changes = cache || {}\n for (const e in obj) {\n if (e === 'ref') continue\n const originalProp = original[e]\n const objProp = obj[e]\n if (isObjectLike(originalProp) && isObjectLike(objProp)) {\n changes[e] = {}\n diff(originalProp, objProp, changes[e])\n } else if (objProp !== undefined) {\n changes[e] = objProp\n }\n }\n return changes\n}\n\n/**\n * Overwrites object properties with another\n */\nexport const overwriteObj = (params, obj) => {\n const changes = {}\n\n for (const e in params) {\n const objProp = obj[e]\n const paramsProp = params[e]\n\n if (paramsProp) {\n obj[e] = changes[e] = objProp\n }\n }\n\n return changes\n}\n\n/**\n * Overwrites DEEPly object properties with another\n */\nexport const overwriteDeep = (params, obj) => {\n for (const e in params) {\n const objProp = obj[e]\n const paramsProp = params[e]\n if (isObjectLike(objProp) && isObjectLike(paramsProp)) {\n overwriteDeep(objProp, paramsProp)\n } else if (paramsProp !== undefined) {\n obj[e] = paramsProp\n }\n }\n return obj\n}\n\n/**\n * Overwrites object properties with another\n */\nexport const mergeIfExisted = (a, b) => {\n if (isObjectLike(a) && isObjectLike(b)) return deepMerge(a, b)\n return a || b\n}\n\n/**\n * Merges array extendtypes\n */\nexport const mergeArray = (arr) => {\n return arr.reduce((a, c) => deepMerge(a, deepClone(c)), {})\n}\n\n/**\n * Merges array extendtypes\n */\nexport const mergeAndCloneIfArray = obj => {\n return isArray(obj) ? mergeArray(obj) : deepClone(obj)\n}\n\n/**\n * Overwrites object properties with another\n */\nexport const flattenRecursive = (param, prop, stack = []) => {\n const objectized = mergeAndCloneIfArray(param)\n stack.push(objectized)\n\n const extendOfExtend = objectized[prop]\n if (extendOfExtend) flattenRecursive(extendOfExtend, prop, stack)\n\n delete objectized[prop]\n\n return stack\n}\n\nexport const isEqualDeep = (param, element) => {\n if (param === element) return true\n if (!param || !element) return false\n for (const prop in param) {\n const paramProp = param[prop]\n const elementProp = element[prop]\n if (isObjectLike(paramProp)) {\n const isEqual = isEqualDeep(paramProp, elementProp)\n if (!isEqual) return false\n } else {\n const isEqual = paramProp === elementProp\n if (!isEqual) return false\n }\n }\n return true\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAsE;AAE/D,MAAM,OAAO,CAAC,OAAO,SAAS,UAAU;AAC7C,UAAI,yBAAW,KAAK;AAAG,WAAO,MAAM,SAAS,SAAS,QAAQ,KAAK;AACnE,SAAO;AACT;AAEO,MAAM,MAAM,CAACA,MAAK,WAAW,YAAY;AAC9C,aAAW,KAAK,WAAW;AACzB,IAAAA,KAAI,CAAC,IAAI,KAAK,UAAU,CAAC,GAAG,OAAO;AAAA,EACrC;AACF;AAEO,MAAM,QAAQ,CAAC,SAASA,SAAQ;AACrC,aAAW,KAAKA,MAAK;AACnB,UAAM,cAAc,QAAQ,CAAC;AAC7B,UAAMC,WAAUD,KAAI,CAAC;AACrB,QAAI,gBAAgB,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AACT;AAEO,MAAM,cAAc,CAAC,OAAO,YAAY;AAC7C,MAAI,UAAU;AAAS,WAAO;AAC9B,MAAI,CAAC,SAAS,CAAC;AAAS,WAAO;AAC/B,aAAWA,SAAQ,OAAO;AACxB,UAAM,YAAY,MAAMA,KAAI;AAC5B,UAAM,cAAc,QAAQA,KAAI;AAChC,YAAI,2BAAa,SAAS,GAAG;AAC3B,YAAM,UAAU,YAAY,WAAW,WAAW;AAClD,UAAI,CAAC;AAAS,eAAO;AAAA,IACvB,OAAO;AACL,YAAM,UAAU,cAAc;AAC9B,UAAI,CAAC;AAAS,eAAO;AAAA,IACvB;AAAA,EACF;AACA,SAAO;AACT;",
6
+ "names": ["obj", "objProp", "prop", "stringified"]
7
+ }
package/dist/types.js ADDED
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var types_exports = {};
20
+ __export(types_exports, {
21
+ TYPES: () => TYPES,
22
+ is: () => is,
23
+ isArray: () => isArray,
24
+ isBoolean: () => isBoolean,
25
+ isDefined: () => isDefined,
26
+ isFunction: () => isFunction,
27
+ isHtmlElement: () => isHtmlElement,
28
+ isNode: () => isNode,
29
+ isNot: () => isNot,
30
+ isNull: () => isNull,
31
+ isNumber: () => isNumber,
32
+ isObject: () => isObject,
33
+ isObjectLike: () => isObjectLike,
34
+ isString: () => isString,
35
+ isUndefined: () => isUndefined,
36
+ isValidHtmlTag: () => isValidHtmlTag
37
+ });
38
+ module.exports = __toCommonJS(types_exports);
39
+ var import_globals = require("@domql/globals");
40
+ var import_tags = require("@domql/tags");
41
+ const isValidHtmlTag = (arg) => import_tags.HTML_TAGS.body.indexOf(arg);
42
+ const isObject = (arg) => {
43
+ if (arg === null)
44
+ return false;
45
+ return typeof arg === "object" && arg.constructor === Object;
46
+ };
47
+ const isString = (arg) => typeof arg === "string";
48
+ const isNumber = (arg) => typeof arg === "number";
49
+ const isFunction = (arg) => typeof arg === "function";
50
+ const isBoolean = (arg) => arg === true || arg === false;
51
+ const isNull = (arg) => arg === null;
52
+ const isArray = (arg) => Array.isArray(arg);
53
+ const isObjectLike = (arg) => {
54
+ if (arg === null)
55
+ return false;
56
+ return typeof arg === "object";
57
+ };
58
+ const isNode = (obj) => {
59
+ 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";
60
+ };
61
+ const isHtmlElement = (obj) => {
62
+ 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";
63
+ };
64
+ const isDefined = (arg) => {
65
+ return isObject(arg) || isObjectLike(arg) || isString(arg) || isNumber(arg) || isFunction(arg) || isArray(arg) || isObjectLike(arg) || isBoolean(arg) || isNull(arg);
66
+ };
67
+ const isUndefined = (arg) => {
68
+ return arg === void 0;
69
+ };
70
+ const TYPES = {
71
+ boolean: isBoolean,
72
+ array: isArray,
73
+ object: isObject,
74
+ string: isString,
75
+ number: isNumber,
76
+ null: isNull,
77
+ function: isFunction,
78
+ objectLike: isObjectLike,
79
+ node: isNode,
80
+ htmlElement: isHtmlElement,
81
+ defined: isDefined
82
+ };
83
+ const is = (arg) => {
84
+ return (...args) => {
85
+ return args.map((val) => TYPES[val](arg)).filter((v) => v).length > 0;
86
+ };
87
+ };
88
+ const isNot = (arg) => {
89
+ return (...args) => {
90
+ return args.map((val) => TYPES[val](arg)).filter((v) => v).length === 0;
91
+ };
92
+ };
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../types.js"],
4
+ "sourcesContent": ["'use strict'\n\nimport { window } from '@domql/globals'\nimport { HTML_TAGS } from '@domql/tags'\n\nexport const isValidHtmlTag = arg => HTML_TAGS.body.indexOf(arg)\n\nexport const isObject = arg => {\n if (arg === null) return false\n return (typeof arg === 'object') && (arg.constructor === Object)\n}\n\nexport const isString = arg => typeof arg === 'string'\n\nexport const isNumber = arg => typeof arg === 'number'\n\nexport const isFunction = arg => typeof arg === 'function'\n\nexport const isBoolean = arg => arg === true || arg === false\n\nexport const isNull = arg => arg === null\n\nexport const isArray = arg => Array.isArray(arg)\n\nexport const isObjectLike = arg => {\n if (arg === null) return false\n // if (isArray(arg)) return false\n return (typeof arg === 'object')\n}\n\nexport const isNode = obj => {\n return (\n typeof window.Node === 'object'\n ? obj instanceof window.Node\n : obj && typeof obj === 'object' && typeof obj.nodeType === 'number' && typeof obj.nodeName === 'string'\n )\n}\n\nexport const isHtmlElement = obj => {\n return (\n typeof window.HTMLElement === 'object'\n ? obj instanceof window.HTMLElement // DOM2\n : obj && typeof obj === 'object' && obj !== null && obj.nodeType === 1 && typeof obj.nodeName === 'string'\n )\n}\n\nexport const isDefined = arg => {\n return isObject(arg) ||\n isObjectLike(arg) ||\n isString(arg) ||\n isNumber(arg) ||\n isFunction(arg) ||\n isArray(arg) ||\n isObjectLike(arg) ||\n isBoolean(arg) ||\n isNull(arg)\n}\n\nexport const isUndefined = arg => {\n return arg === undefined\n}\n\nexport const TYPES = {\n boolean: isBoolean,\n array: isArray,\n object: isObject,\n string: isString,\n number: isNumber,\n null: isNull,\n function: isFunction,\n objectLike: isObjectLike,\n node: isNode,\n htmlElement: isHtmlElement,\n defined: isDefined\n}\n\nexport const is = (arg) => {\n return (...args) => {\n return args.map(val => TYPES[val](arg)).filter(v => v).length > 0\n }\n}\n\nexport const isNot = (arg) => {\n return (...args) => {\n return args.map(val => TYPES[val](arg)).filter(v => v).length === 0\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,qBAAuB;AACvB,kBAA0B;AAEnB,MAAM,iBAAiB,SAAO,sBAAU,KAAK,QAAQ,GAAG;AAExD,MAAM,WAAW,SAAO;AAC7B,MAAI,QAAQ;AAAM,WAAO;AACzB,SAAQ,OAAO,QAAQ,YAAc,IAAI,gBAAgB;AAC3D;AAEO,MAAM,WAAW,SAAO,OAAO,QAAQ;AAEvC,MAAM,WAAW,SAAO,OAAO,QAAQ;AAEvC,MAAM,aAAa,SAAO,OAAO,QAAQ;AAEzC,MAAM,YAAY,SAAO,QAAQ,QAAQ,QAAQ;AAEjD,MAAM,SAAS,SAAO,QAAQ;AAE9B,MAAM,UAAU,SAAO,MAAM,QAAQ,GAAG;AAExC,MAAM,eAAe,SAAO;AACjC,MAAI,QAAQ;AAAM,WAAO;AAEzB,SAAQ,OAAO,QAAQ;AACzB;AAEO,MAAM,SAAS,SAAO;AAC3B,SACE,OAAO,sBAAO,SAAS,WACnB,eAAe,sBAAO,OACtB,OAAO,OAAO,QAAQ,YAAY,OAAO,IAAI,aAAa,YAAY,OAAO,IAAI,aAAa;AAEtG;AAEO,MAAM,gBAAgB,SAAO;AAClC,SACE,OAAO,sBAAO,gBAAgB,WAC1B,eAAe,sBAAO,cACtB,OAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,IAAI,aAAa,KAAK,OAAO,IAAI,aAAa;AAExG;AAEO,MAAM,YAAY,SAAO;AAC9B,SAAO,SAAS,GAAG,KACjB,aAAa,GAAG,KAChB,SAAS,GAAG,KACZ,SAAS,GAAG,KACZ,WAAW,GAAG,KACd,QAAQ,GAAG,KACX,aAAa,GAAG,KAChB,UAAU,GAAG,KACb,OAAO,GAAG;AACd;AAEO,MAAM,cAAc,SAAO;AAChC,SAAO,QAAQ;AACjB;AAEO,MAAM,QAAQ;AAAA,EACnB,SAAS;AAAA,EACT,OAAO;AAAA,EACP,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,MAAM;AAAA,EACN,aAAa;AAAA,EACb,SAAS;AACX;AAEO,MAAM,KAAK,CAAC,QAAQ;AACzB,SAAO,IAAI,SAAS;AAClB,WAAO,KAAK,IAAI,SAAO,MAAM,GAAG,EAAE,GAAG,CAAC,EAAE,OAAO,OAAK,CAAC,EAAE,SAAS;AAAA,EAClE;AACF;AAEO,MAAM,QAAQ,CAAC,QAAQ;AAC5B,SAAO,IAAI,SAAS;AAClB,WAAO,KAAK,IAAI,SAAO,MAAM,GAAG,EAAE,GAAG,CAAC,EAAE,OAAO,OAAK,CAAC,EAAE,WAAW;AAAA,EACpE;AACF;",
6
+ "names": []
7
+ }
package/function.js ADDED
@@ -0,0 +1,23 @@
1
+ 'use strict'
2
+
3
+ export const debounce = (element, func, timeout = 300) => {
4
+ let timer
5
+ return (...args) => {
6
+ clearTimeout(timer)
7
+ timer = setTimeout(() => { func.apply(element, args) }, timeout)
8
+ }
9
+ }
10
+
11
+ export const memoize = (fn) => {
12
+ const cache = {}
13
+ return (...args) => {
14
+ const n = args[0]
15
+ if (n in cache) {
16
+ return cache[n]
17
+ } else {
18
+ const result = fn(n)
19
+ cache[n] = result
20
+ return result
21
+ }
22
+ }
23
+ }
package/index.js ADDED
@@ -0,0 +1,8 @@
1
+ 'use strict'
2
+
3
+ export * from './types'
4
+ export * from './object'
5
+ export * from './function'
6
+ export * from './array'
7
+ export * from './node'
8
+ export * from './log'
package/log.js ADDED
@@ -0,0 +1,10 @@
1
+ 'use strict'
2
+
3
+ export const logIf = (bool, ...arg) => { if (bool) arg.map(v => console.log(v)) }
4
+ export const logGroupIf = (bool, key, ...arg) => {
5
+ if (bool) {
6
+ console.group(key)
7
+ arg.map(v => console.log(v))
8
+ console.groupEnd(key)
9
+ }
10
+ }