is-what 5.2.1 → 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 +1 -0
- package/dist/index.js +1 -0
- package/dist/isAnyObject.d.ts +1 -1
- package/dist/isBigInt.d.ts +2 -0
- package/dist/isBigInt.js +5 -0
- package/dist/isDate.js +1 -1
- package/dist/isFullObject.d.ts +1 -1
- package/dist/isInstanceOf.d.ts +1 -1
- package/dist/isInstanceOf.js +1 -2
- package/dist/isIterable.js +3 -1
- package/dist/isNaNValue.d.ts +1 -1
- package/dist/isNaNValue.js +1 -1
- package/dist/isNumber.js +1 -1
- package/dist/isObject.d.ts +1 -1
- package/dist/isObjectLike.d.ts +1 -1
- package/dist/isPrimitive.d.ts +1 -1
- package/dist/isPrimitive.js +3 -1
- package/dist/isType.d.ts +1 -1
- package/dist/isType.js +4 -3
- package/package.json +5 -4
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';
|
package/dist/isAnyObject.d.ts
CHANGED
package/dist/isBigInt.js
ADDED
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
|
}
|
package/dist/isFullObject.d.ts
CHANGED
package/dist/isInstanceOf.d.ts
CHANGED
package/dist/isInstanceOf.js
CHANGED
@@ -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
|
}
|
package/dist/isIterable.js
CHANGED
@@ -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
|
-
|
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')
|
package/dist/isNaNValue.d.ts
CHANGED
@@ -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;
|
package/dist/isNaNValue.js
CHANGED
@@ -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
package/dist/isObject.d.ts
CHANGED
package/dist/isObjectLike.d.ts
CHANGED
package/dist/isPrimitive.d.ts
CHANGED
@@ -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;
|
package/dist/isPrimitive.js
CHANGED
@@ -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
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
|
11
|
+
if (!isFunction(type)) {
|
11
12
|
throw new TypeError('Type must be a function');
|
12
13
|
}
|
13
|
-
if (!Object.
|
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
|
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.
|
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,7 +13,7 @@
|
|
13
13
|
},
|
14
14
|
"scripts": {
|
15
15
|
"test": "vitest run",
|
16
|
-
"lint": "tsc --noEmit &&
|
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"
|
@@ -23,8 +23,9 @@
|
|
23
23
|
"@cycraft/tsconfig": "^0.1.2",
|
24
24
|
"del-cli": "^6.0.0",
|
25
25
|
"np": "^10.2.0",
|
26
|
-
"
|
27
|
-
"
|
26
|
+
"oxlint": "^1.11.2",
|
27
|
+
"typedoc": "^0.28.10",
|
28
|
+
"vitest": "^3.2.4"
|
28
29
|
},
|
29
30
|
"files": [
|
30
31
|
"dist"
|