@domql/utils 2.3.8 → 2.3.11

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 (4) hide show
  1. package/index.js +1 -0
  2. package/log.js +10 -0
  3. package/package.json +2 -2
  4. package/types.js +24 -0
package/index.js CHANGED
@@ -5,3 +5,4 @@ export * from './object'
5
5
  export * from './function'
6
6
  export * from './array'
7
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
+ }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@domql/utils",
3
- "version": "2.3.8",
3
+ "version": "2.3.11",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "dependencies": {
7
7
  "@domql/tags": "latest"
8
8
  },
9
- "gitHead": "0806fd53e029721c87db84d21a3e46a8a23cef24",
9
+ "gitHead": "b68b909999a34649b9bc1679663442c3580ada3f",
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
+ }