@domql/utils 2.3.7 → 2.3.9

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.
Files changed (3) hide show
  1. package/object.js +17 -0
  2. package/package.json +2 -2
  3. package/types.js +24 -0
package/object.js CHANGED
@@ -176,3 +176,20 @@ export const flattenRecursive = (param, prop, stack = []) => {
176
176
 
177
177
  return stack
178
178
  }
179
+
180
+ export const isEqualDeep = (param, element) => {
181
+ if (param === element) return true
182
+ if (!param || !element) return false
183
+ for (const prop in param) {
184
+ const paramProp = param[prop]
185
+ const elementProp = element[prop]
186
+ if (isObjectLike(paramProp)) {
187
+ const isEqual = isEqualDeep(paramProp, elementProp)
188
+ if (!isEqual) return false
189
+ } else {
190
+ const isEqual = paramProp === elementProp
191
+ if (!isEqual) return false
192
+ }
193
+ }
194
+ return true
195
+ }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.3.7",
3
+ "version": "2.3.9",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
7
7
  "@domql/tags": "latest"
8
8
  },
9
- "gitHead": "c8dcd776f492f22109580cc44aa5db7e13d43bde",
9
+ "gitHead": "1f42c9b0de8b052b99e587f58ed1ec0b886053aa",
10
10
  "source": "index.js"
11
11
  }
package/types.js CHANGED
@@ -48,3 +48,27 @@ export const isDefined = arg => {
48
48
  isArray(arg) ||
49
49
  isObjectLike(arg)
50
50
  }
51
+
52
+ export const TYPES = {
53
+ array: isArray,
54
+ object: isObject,
55
+ string: isString,
56
+ number: isNumber,
57
+ function: isFunction,
58
+ objectLike: isObjectLike,
59
+ node: isNode,
60
+ htmlElement: isHtmlElement,
61
+ defined: isDefined
62
+ }
63
+
64
+ export const is = (arg) => {
65
+ return (...args) => {
66
+ return args.map(val => TYPES[val](arg)).filter(v => v).length > 0
67
+ }
68
+ }
69
+
70
+ export const isNot = (arg) => {
71
+ return (...args) => {
72
+ return args.map(val => TYPES[val](arg)).filter(v => v).length === 0
73
+ }
74
+ }