is-what 5.2.0 → 5.3.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/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export type AnyAsyncFunction = (...args: unknown[]) => Promise<unknown>;
2
2
  export { getType } from './getType.js';
3
3
  export { isAnyObject } from './isAnyObject.js';
4
4
  export { isArray } from './isArray.js';
5
+ export { isBigInt } from './isBigInt.js';
5
6
  export { isBlob } from './isBlob.js';
6
7
  export { isBoolean } from './isBoolean.js';
7
8
  export { isDate } from './isDate.js';
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  export { getType } from './getType.js';
2
2
  export { isAnyObject } from './isAnyObject.js';
3
3
  export { isArray } from './isArray.js';
4
+ export { isBigInt } from './isBigInt.js';
4
5
  export { isBlob } from './isBlob.js';
5
6
  export { isBoolean } from './isBoolean.js';
6
7
  export { isDate } from './isDate.js';
@@ -1,4 +1,4 @@
1
- import { PlainObject } from './isPlainObject.js';
1
+ import type { PlainObject } from './isPlainObject.js';
2
2
  /**
3
3
  * Returns whether the payload is an any kind of object (including special classes or objects with
4
4
  * different prototypes)
@@ -0,0 +1,2 @@
1
+ /** Returns whether the payload is a bigint */
2
+ export declare function isBigInt(payload: unknown): payload is bigint;
@@ -0,0 +1,5 @@
1
+ import { getType } from './getType.js';
2
+ /** Returns whether the payload is a bigint */
3
+ export function isBigInt(payload) {
4
+ return getType(payload) === 'BigInt';
5
+ }
package/dist/isDate.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { getType } from './getType.js';
2
2
  /** Returns whether the payload is a Date, and that the date is valid */
3
3
  export function isDate(payload) {
4
- return getType(payload) === 'Date' && !isNaN(payload);
4
+ return getType(payload) === 'Date' && !Number.isNaN(payload.valueOf());
5
5
  }
@@ -1,4 +1,4 @@
1
- import { PlainObject } from './isPlainObject.js';
1
+ import type { PlainObject } from './isPlainObject.js';
2
2
  /**
3
3
  * Returns whether the payload is a an empty object (excluding special classes or objects with other
4
4
  * prototypes)
@@ -1,4 +1,4 @@
1
- import { AnyClass } from './isType.js';
1
+ import type { AnyClass } from './isType.js';
2
2
  type GlobalClassName = {
3
3
  [K in keyof typeof globalThis]: (typeof globalThis)[K] extends AnyClass ? K : never;
4
4
  }[keyof typeof globalThis];
@@ -7,7 +7,6 @@ export function isInstanceOf(value, classOrClassName) {
7
7
  return true;
8
8
  }
9
9
  }
10
- return false;
11
10
  }
12
11
  else {
13
12
  for (let p = value; p; p = Object.getPrototypeOf(p)) {
@@ -15,6 +14,6 @@ export function isInstanceOf(value, classOrClassName) {
15
14
  return true;
16
15
  }
17
16
  }
18
- return false;
19
17
  }
18
+ return false;
20
19
  }
@@ -1,9 +1,11 @@
1
1
  /** Returns whether the payload is an iterable (regular or async) */
2
2
  export function isIterable(payload) {
3
+ // oxlint-disable-next-line no-typeof-undefined
3
4
  if (typeof Symbol === 'undefined' || typeof Symbol.iterator === 'undefined') {
4
5
  return false;
5
6
  }
6
- if (payload == null)
7
+ // oxlint-disable-next-line no-null
8
+ if (payload === null || payload === undefined)
7
9
  return false;
8
10
  // Strings are iterable, even though they're primitives.
9
11
  if (typeof payload === 'string')
@@ -1,2 +1,2 @@
1
1
  /** Returns whether the payload is literally the value `NaN` (it's `NaN` and also a `number`) */
2
- export declare function isNaNValue(payload: unknown): payload is typeof NaN;
2
+ export declare function isNaNValue(payload: unknown): payload is typeof Number.NaN;
@@ -1,5 +1,5 @@
1
1
  import { getType } from './getType.js';
2
2
  /** Returns whether the payload is literally the value `NaN` (it's `NaN` and also a `number`) */
3
3
  export function isNaNValue(payload) {
4
- return getType(payload) === 'Number' && isNaN(payload);
4
+ return getType(payload) === 'Number' && Number.isNaN(payload);
5
5
  }
package/dist/isNumber.js CHANGED
@@ -5,5 +5,5 @@ import { getType } from './getType.js';
5
5
  * This will return `false` for `NaN`!!
6
6
  */
7
7
  export function isNumber(payload) {
8
- return getType(payload) === 'Number' && !isNaN(payload);
8
+ return getType(payload) === 'Number' && !Number.isNaN(payload);
9
9
  }
@@ -1,4 +1,4 @@
1
- import { PlainObject } from './isPlainObject.js';
1
+ import type { PlainObject } from './isPlainObject.js';
2
2
  /**
3
3
  * Returns whether the payload is a plain JavaScript object (excluding special classes or objects
4
4
  * with other prototypes)
@@ -1,4 +1,4 @@
1
- import { PlainObject } from './isPlainObject.js';
1
+ import type { PlainObject } from './isPlainObject.js';
2
2
  /**
3
3
  * Returns whether the payload is an object like a type passed in < >
4
4
  *
@@ -3,4 +3,4 @@
3
3
  *
4
4
  * | Symbol)
5
5
  */
6
- export declare function isPrimitive(payload: unknown): payload is boolean | null | undefined | number | string | symbol;
6
+ export declare function isPrimitive(payload: unknown): payload is boolean | null | undefined | number | string | symbol | bigint;
@@ -1,3 +1,4 @@
1
+ import { isBigInt } from './isBigInt.js';
1
2
  import { isBoolean } from './isBoolean.js';
2
3
  import { isNull } from './isNull.js';
3
4
  import { isNumber } from './isNumber.js';
@@ -15,5 +16,6 @@ export function isPrimitive(payload) {
15
16
  isUndefined(payload) ||
16
17
  isNumber(payload) ||
17
18
  isString(payload) ||
18
- isSymbol(payload));
19
+ isSymbol(payload) ||
20
+ isBigInt(payload));
19
21
  }
package/dist/isType.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AnyFunction } from './isFunction.js';
1
+ import type { AnyFunction } from './isFunction.js';
2
2
  export type AnyClass = new (...args: unknown[]) => unknown;
3
3
  /**
4
4
  * Does a generic check to check that the given payload is of a given type. In cases like Number, it
package/dist/isType.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { getType } from './getType.js';
2
+ import { isFunction } from './isFunction.js';
2
3
  /**
3
4
  * Does a generic check to check that the given payload is of a given type. In cases like Number, it
4
5
  * will return true for NaN as NaN is a Number (thanks javascript!); It will, however, differentiate
@@ -7,13 +8,13 @@ import { getType } from './getType.js';
7
8
  * @throws {TypeError} Will throw type error if type is an invalid type
8
9
  */
9
10
  export function isType(payload, type) {
10
- if (!(type instanceof Function)) {
11
+ if (!isFunction(type)) {
11
12
  throw new TypeError('Type must be a function');
12
13
  }
13
- if (!Object.prototype.hasOwnProperty.call(type, 'prototype')) {
14
+ if (!Object.hasOwn(type, 'prototype')) {
14
15
  throw new TypeError('Type is not a class');
15
16
  }
16
17
  // Classes usually have names (as functions usually have names)
17
- const name = type.name;
18
+ const { name } = type;
18
19
  return getType(payload) === name || Boolean(payload && payload.constructor === type);
19
20
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "is-what",
3
- "version": "5.2.0",
3
+ "version": "5.3.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,
@@ -13,18 +13,19 @@
13
13
  },
14
14
  "scripts": {
15
15
  "test": "vitest run",
16
- "lint": "tsc --noEmit && eslint ./src",
16
+ "lint": "tsc --noEmit && oxlint",
17
17
  "build": "del-cli dist && tsc",
18
18
  "build:docs": "typedoc",
19
19
  "release": "npm run lint && npm run build && np --no-publish"
20
20
  },
21
21
  "devDependencies": {
22
- "@cycraft/eslint": "^0.4.3",
22
+ "@cycraft/eslint": "^0.4.4",
23
23
  "@cycraft/tsconfig": "^0.1.2",
24
24
  "del-cli": "^6.0.0",
25
25
  "np": "^10.2.0",
26
- "typedoc": "^0.27.7",
27
- "vitest": "^3.0.5"
26
+ "oxlint": "^1.11.2",
27
+ "typedoc": "^0.28.10",
28
+ "vitest": "^3.2.4"
28
29
  },
29
30
  "files": [
30
31
  "dist"