is-what 5.1.0 → 5.2.0

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/README.md CHANGED
@@ -51,6 +51,8 @@ isNull(null) // true
51
51
  isString('') // true
52
52
  isEmptyString('') // true
53
53
  isFullString('') // false
54
+ isHexDecimal('60adf084f0fbdcab42de841e') // true
55
+ isHexDecimal('60adf084f0fbdcab42de841e', 24) // check specific length of 24 (eg. MongoDB ObjectId)
54
56
 
55
57
  // numbers
56
58
  isNumber(0) // true
@@ -95,7 +97,16 @@ isPromise(new Promise((resolve) => {})) // true
95
97
 
96
98
  // primitives
97
99
  isPrimitive('') // true
98
- // true for any of: boolean, null, undefined, number, string, symbol
100
+ // true for any of: boolean, null, undefined, number, string, symbol
101
+
102
+ // iterables
103
+ isIterable([1, 2, 3]) // true
104
+ isIterable('hello') // true
105
+ isIterable(new Map()) // true
106
+ isIterable(new Set()) // true
107
+ isIterable(function* generator() {
108
+ yield 1
109
+ }) // true
99
110
  ```
100
111
 
101
112
  ### Let's talk about NaN
package/dist/index.d.ts CHANGED
@@ -15,6 +15,7 @@ export { isFullObject } from './isFullObject.js';
15
15
  export { isFullString } from './isFullString.js';
16
16
  export { isFunction } from './isFunction.js';
17
17
  export type { AnyFunction } from './isFunction.js';
18
+ export { isHexDecimal } from './isHexDecimal.js';
18
19
  export { isInstanceOf } from './isInstanceOf.js';
19
20
  export { isIterable } from './isIterable.js';
20
21
  export { isMap } from './isMap.js';
package/dist/index.js CHANGED
@@ -13,6 +13,7 @@ export { isFullArray } from './isFullArray.js';
13
13
  export { isFullObject } from './isFullObject.js';
14
14
  export { isFullString } from './isFullString.js';
15
15
  export { isFunction } from './isFunction.js';
16
+ export { isHexDecimal } from './isHexDecimal.js';
16
17
  export { isInstanceOf } from './isInstanceOf.js';
17
18
  export { isIterable } from './isIterable.js';
18
19
  export { isMap } from './isMap.js';
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Checks if a string is a valid hexadecimal string. If a length is provided, it also checks that
3
+ * the string has that length.
4
+ */
5
+ export declare function isHexDecimal(payload: unknown, length?: number): payload is string;
@@ -0,0 +1,12 @@
1
+ import { isString } from './isString.js';
2
+ /**
3
+ * Checks if a string is a valid hexadecimal string. If a length is provided, it also checks that
4
+ * the string has that length.
5
+ */
6
+ export function isHexDecimal(payload, length) {
7
+ if (!isString(payload))
8
+ return false;
9
+ if (!/^[0-9a-fA-F]+$/.test(payload))
10
+ return false;
11
+ return length === undefined || payload.length === length;
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "is-what",
3
- "version": "5.1.0",
3
+ "version": "5.2.0",
4
4
  "description": "JS type check (TypeScript supported) functions like `isPlainObject() isArray()` etc. A simple & small integration.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -16,10 +16,10 @@
16
16
  "lint": "tsc --noEmit && eslint ./src",
17
17
  "build": "del-cli dist && tsc",
18
18
  "build:docs": "typedoc",
19
- "release": "npm run lint && npm run build && np"
19
+ "release": "npm run lint && npm run build && np --no-publish"
20
20
  },
21
21
  "devDependencies": {
22
- "@cycraft/eslint": "^0.4.1",
22
+ "@cycraft/eslint": "^0.4.3",
23
23
  "@cycraft/tsconfig": "^0.1.2",
24
24
  "del-cli": "^6.0.0",
25
25
  "np": "^10.2.0",