@webdeveric/utils 0.55.0 → 0.57.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/cjs/predicate/factory/shape.js +3 -2
- package/dist/cjs/predicate/index.js +8 -0
- package/dist/cjs/predicate/isAny.js +5 -0
- package/dist/cjs/predicate/isAnyObjectWith.js +1 -2
- package/dist/cjs/predicate/isAnyObjectWithOwn.js +1 -2
- package/dist/cjs/predicate/isArray.js +5 -0
- package/dist/cjs/predicate/isBinaryNumberString.js +5 -0
- package/dist/cjs/predicate/isHexNumberString.js +5 -0
- package/dist/cjs/predicate/isNumericValue.js +1 -1
- package/dist/cjs/predicate/isObjectWith.js +1 -4
- package/dist/cjs/predicate/isOctalNumberString.js +5 -0
- package/dist/cjs/predicate/isOptionalArray.js +6 -0
- package/dist/cjs/predicate/isOptionalObject.js +6 -0
- package/dist/cjs/predicate/isPrimitive.js +7 -14
- package/dist/cjs/predicate/isPromiseFulfilledResult.js +6 -5
- package/dist/cjs/predicate/isPromiseRejectedResult.js +6 -5
- package/dist/cjs/predicate/isUnknown.js +5 -0
- package/dist/mjs/predicate/factory/shape.js +3 -2
- package/dist/mjs/predicate/index.js +8 -0
- package/dist/mjs/predicate/isAny.js +1 -0
- package/dist/mjs/predicate/isAnyObjectWith.js +1 -2
- package/dist/mjs/predicate/isAnyObjectWithOwn.js +1 -2
- package/dist/mjs/predicate/isArray.js +1 -0
- package/dist/mjs/predicate/isBinaryNumberString.js +2 -0
- package/dist/mjs/predicate/isHexNumberString.js +2 -0
- package/dist/mjs/predicate/isNumericValue.js +1 -1
- package/dist/mjs/predicate/isObjectWith.js +1 -4
- package/dist/mjs/predicate/isOctalNumberString.js +2 -0
- package/dist/mjs/predicate/isOptionalArray.js +3 -0
- package/dist/mjs/predicate/isOptionalObject.js +3 -0
- package/dist/mjs/predicate/isPrimitive.js +7 -14
- package/dist/mjs/predicate/isPromiseFulfilledResult.js +6 -4
- package/dist/mjs/predicate/isPromiseRejectedResult.js +6 -4
- package/dist/mjs/predicate/isUnknown.js +1 -0
- package/dist/types/assertion/assertIsObject.d.ts +2 -1
- package/dist/types/predicate/index.d.ts +8 -0
- package/dist/types/predicate/isAny.d.ts +1 -0
- package/dist/types/predicate/isAnyObject.d.ts +1 -2
- package/dist/types/predicate/isAnyObjectWith.d.ts +1 -1
- package/dist/types/predicate/isAnyObjectWithOwn.d.ts +1 -1
- package/dist/types/predicate/isArray.d.ts +1 -0
- package/dist/types/predicate/isAsyncIterable.d.ts +1 -1
- package/dist/types/predicate/isBinaryNumberString.d.ts +1 -0
- package/dist/types/predicate/isDigitsString.d.ts +1 -1
- package/dist/types/predicate/isHexNumberString.d.ts +1 -0
- package/dist/types/predicate/isIntString.d.ts +1 -1
- package/dist/types/predicate/isNumericString.d.ts +1 -1
- package/dist/types/predicate/isObject.d.ts +1 -1
- package/dist/types/predicate/isObjectWith.d.ts +1 -1
- package/dist/types/predicate/isOctalNumberString.d.ts +1 -0
- package/dist/types/predicate/isOptionalArray.d.ts +1 -0
- package/dist/types/predicate/isOptionalObject.d.ts +1 -0
- package/dist/types/predicate/isPromiseFulfilledResult.d.ts +4 -1
- package/dist/types/predicate/isPromiseRejectedResult.d.ts +4 -1
- package/dist/types/predicate/isUnknown.d.ts +1 -0
- package/dist/types/types/common.d.ts +1 -1
- package/dist/types/types/numbers.d.ts +6 -0
- package/dist/types/types/strings.d.ts +2 -1
- package/package.json +4 -4
|
@@ -5,7 +5,8 @@ const isAnyObject_js_1 = require("../isAnyObject.js");
|
|
|
5
5
|
const literal_js_1 = require("./literal.js");
|
|
6
6
|
const matching_js_1 = require("./matching.js");
|
|
7
7
|
const shape = (objectShape) => {
|
|
8
|
-
const entries =
|
|
8
|
+
const entries = Reflect.ownKeys(objectShape).map((key) => {
|
|
9
|
+
const value = Reflect.get(objectShape, key);
|
|
9
10
|
const predicate = typeof value === 'function'
|
|
10
11
|
? value
|
|
11
12
|
: value instanceof RegExp
|
|
@@ -15,6 +16,6 @@ const shape = (objectShape) => {
|
|
|
15
16
|
: (0, literal_js_1.literal)(value);
|
|
16
17
|
return [key, predicate];
|
|
17
18
|
});
|
|
18
|
-
return (input) => (0, isAnyObject_js_1.isAnyObject)(input) && entries.every(([key, predicate]) => predicate(input
|
|
19
|
+
return (input) => (0, isAnyObject_js_1.isAnyObject)(input) && entries.every(([key, predicate]) => predicate(Reflect.get(input, key)));
|
|
19
20
|
};
|
|
20
21
|
exports.shape = shape;
|
|
@@ -14,17 +14,21 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./isAny.js"), exports);
|
|
17
18
|
__exportStar(require("./isAnyObject.js"), exports);
|
|
18
19
|
__exportStar(require("./isAnyObjectWith.js"), exports);
|
|
19
20
|
__exportStar(require("./isAnyObjectWithOwn.js"), exports);
|
|
21
|
+
__exportStar(require("./isArray.js"), exports);
|
|
20
22
|
__exportStar(require("./isAsyncIterable.js"), exports);
|
|
21
23
|
__exportStar(require("./isBigInt.js"), exports);
|
|
22
24
|
__exportStar(require("./isBigIntArray.js"), exports);
|
|
25
|
+
__exportStar(require("./isBinaryNumberString.js"), exports);
|
|
23
26
|
__exportStar(require("./isBoolean.js"), exports);
|
|
24
27
|
__exportStar(require("./isBooleanArray.js"), exports);
|
|
25
28
|
__exportStar(require("./isDigitsString.js"), exports);
|
|
26
29
|
__exportStar(require("./isFiniteNumber.js"), exports);
|
|
27
30
|
__exportStar(require("./isFunction.js"), exports);
|
|
31
|
+
__exportStar(require("./isHexNumberString.js"), exports);
|
|
28
32
|
__exportStar(require("./isInt32.js"), exports);
|
|
29
33
|
__exportStar(require("./isInteger.js"), exports);
|
|
30
34
|
__exportStar(require("./isIntString.js"), exports);
|
|
@@ -41,11 +45,14 @@ __exportStar(require("./isNumericValue.js"), exports);
|
|
|
41
45
|
__exportStar(require("./isNumericValueArray.js"), exports);
|
|
42
46
|
__exportStar(require("./isObject.js"), exports);
|
|
43
47
|
__exportStar(require("./isObjectWith.js"), exports);
|
|
48
|
+
__exportStar(require("./isOctalNumberString.js"), exports);
|
|
49
|
+
__exportStar(require("./isOptionalArray.js"), exports);
|
|
44
50
|
__exportStar(require("./isOptionalBigInt.js"), exports);
|
|
45
51
|
__exportStar(require("./isOptionalBoolean.js"), exports);
|
|
46
52
|
__exportStar(require("./isOptionalISODateString.js"), exports);
|
|
47
53
|
__exportStar(require("./isOptionalNull.js"), exports);
|
|
48
54
|
__exportStar(require("./isOptionalNumber.js"), exports);
|
|
55
|
+
__exportStar(require("./isOptionalObject.js"), exports);
|
|
49
56
|
__exportStar(require("./isOptionalString.js"), exports);
|
|
50
57
|
__exportStar(require("./isOptionalSymbol.js"), exports);
|
|
51
58
|
__exportStar(require("./isPositiveFiniteNumber.js"), exports);
|
|
@@ -64,3 +71,4 @@ __exportStar(require("./isSymbol.js"), exports);
|
|
|
64
71
|
__exportStar(require("./isSymbolArray.js"), exports);
|
|
65
72
|
__exportStar(require("./isUndefined.js"), exports);
|
|
66
73
|
__exportStar(require("./isUndefinedArray.js"), exports);
|
|
74
|
+
__exportStar(require("./isUnknown.js"), exports);
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isAnyObjectWith = void 0;
|
|
4
|
-
const asArray_js_1 = require("../asArray.js");
|
|
5
4
|
const isAnyObject_js_1 = require("./isAnyObject.js");
|
|
6
5
|
const isAnyObjectWith = (input, properties) => {
|
|
7
|
-
return (0, isAnyObject_js_1.isAnyObject)(input) &&
|
|
6
|
+
return (0, isAnyObject_js_1.isAnyObject)(input) && properties.every((property) => property in input);
|
|
8
7
|
};
|
|
9
8
|
exports.isAnyObjectWith = isAnyObjectWith;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isAnyObjectWithOwn = void 0;
|
|
4
|
-
const asArray_js_1 = require("../asArray.js");
|
|
5
4
|
const isAnyObject_js_1 = require("./isAnyObject.js");
|
|
6
5
|
const isAnyObjectWithOwn = (input, properties) => {
|
|
7
|
-
return (0, isAnyObject_js_1.isAnyObject)(input) &&
|
|
6
|
+
return (0, isAnyObject_js_1.isAnyObject)(input) && properties.every((property) => Object.hasOwn(input, property));
|
|
8
7
|
};
|
|
9
8
|
exports.isAnyObjectWithOwn = isAnyObjectWithOwn;
|
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isNumericValue = void 0;
|
|
4
4
|
const isNumericString_js_1 = require("./isNumericString.js");
|
|
5
|
-
const isNumericValue = (input) => typeof input === 'number' || typeof input === 'bigint' || (0, isNumericString_js_1.isNumericString)(input);
|
|
5
|
+
const isNumericValue = (input) => (typeof input === 'number' && !Number.isNaN(input)) || typeof input === 'bigint' || (0, isNumericString_js_1.isNumericString)(input);
|
|
6
6
|
exports.isNumericValue = isNumericValue;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isObjectWith = void 0;
|
|
4
|
-
const asArray_js_1 = require("../asArray.js");
|
|
5
4
|
const isObject_js_1 = require("./isObject.js");
|
|
6
|
-
const isObjectWith = (input, properties) =>
|
|
7
|
-
return (0, isObject_js_1.isObject)(input) && (0, asArray_js_1.asArray)(properties).every((property) => property in input);
|
|
8
|
-
};
|
|
5
|
+
const isObjectWith = (input, properties) => (0, isObject_js_1.isObject)(input) && properties.every((property) => property in input);
|
|
9
6
|
exports.isObjectWith = isObjectWith;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isOptionalArray = void 0;
|
|
4
|
+
const optional_js_1 = require("./factory/optional.js");
|
|
5
|
+
const isArray_js_1 = require("./isArray.js");
|
|
6
|
+
exports.isOptionalArray = (0, optional_js_1.optional)(isArray_js_1.isArray);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isOptionalObject = void 0;
|
|
4
|
+
const optional_js_1 = require("./factory/optional.js");
|
|
5
|
+
const isObject_js_1 = require("./isObject.js");
|
|
6
|
+
exports.isOptionalObject = (0, optional_js_1.optional)(isObject_js_1.isObject);
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isPrimitive = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const isPrimitive = (input) => (0, isString_js_1.isString)(input) ||
|
|
12
|
-
(0, isNumber_js_1.isNumber)(input) ||
|
|
13
|
-
(0, isBigInt_js_1.isBigInt)(input) ||
|
|
14
|
-
(0, isBoolean_js_1.isBoolean)(input) ||
|
|
15
|
-
(0, isUndefined_js_1.isUndefined)(input) ||
|
|
16
|
-
(0, isSymbol_js_1.isSymbol)(input) ||
|
|
17
|
-
(0, isNull_js_1.isNull)(input);
|
|
4
|
+
const isPrimitive = (input) => input === null ||
|
|
5
|
+
typeof input === 'string' ||
|
|
6
|
+
typeof input === 'number' ||
|
|
7
|
+
typeof input === 'bigint' ||
|
|
8
|
+
typeof input === 'boolean' ||
|
|
9
|
+
typeof input === 'undefined' ||
|
|
10
|
+
typeof input === 'symbol';
|
|
18
11
|
exports.isPrimitive = isPrimitive;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isPromiseFulfilledResult = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const shape_js_1 = require("./factory/shape.js");
|
|
5
|
+
const isUnknown_js_1 = require("./isUnknown.js");
|
|
6
|
+
exports.isPromiseFulfilledResult = (0, shape_js_1.shape)({
|
|
7
|
+
status: 'fulfilled',
|
|
8
|
+
value: isUnknown_js_1.isUnknown,
|
|
9
|
+
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.isPromiseRejectedResult = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const shape_js_1 = require("./factory/shape.js");
|
|
5
|
+
const isAny_js_1 = require("./isAny.js");
|
|
6
|
+
exports.isPromiseRejectedResult = (0, shape_js_1.shape)({
|
|
7
|
+
status: 'rejected',
|
|
8
|
+
reason: isAny_js_1.isAny,
|
|
9
|
+
});
|
|
@@ -2,7 +2,8 @@ import { isAnyObject } from '../isAnyObject.js';
|
|
|
2
2
|
import { literal } from './literal.js';
|
|
3
3
|
import { matching } from './matching.js';
|
|
4
4
|
export const shape = (objectShape) => {
|
|
5
|
-
const entries =
|
|
5
|
+
const entries = Reflect.ownKeys(objectShape).map((key) => {
|
|
6
|
+
const value = Reflect.get(objectShape, key);
|
|
6
7
|
const predicate = typeof value === 'function'
|
|
7
8
|
? value
|
|
8
9
|
: value instanceof RegExp
|
|
@@ -12,5 +13,5 @@ export const shape = (objectShape) => {
|
|
|
12
13
|
: literal(value);
|
|
13
14
|
return [key, predicate];
|
|
14
15
|
});
|
|
15
|
-
return (input) => isAnyObject(input) && entries.every(([key, predicate]) => predicate(input
|
|
16
|
+
return (input) => isAnyObject(input) && entries.every(([key, predicate]) => predicate(Reflect.get(input, key)));
|
|
16
17
|
};
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
export * from './isAny.js';
|
|
1
2
|
export * from './isAnyObject.js';
|
|
2
3
|
export * from './isAnyObjectWith.js';
|
|
3
4
|
export * from './isAnyObjectWithOwn.js';
|
|
5
|
+
export * from './isArray.js';
|
|
4
6
|
export * from './isAsyncIterable.js';
|
|
5
7
|
export * from './isBigInt.js';
|
|
6
8
|
export * from './isBigIntArray.js';
|
|
9
|
+
export * from './isBinaryNumberString.js';
|
|
7
10
|
export * from './isBoolean.js';
|
|
8
11
|
export * from './isBooleanArray.js';
|
|
9
12
|
export * from './isDigitsString.js';
|
|
10
13
|
export * from './isFiniteNumber.js';
|
|
11
14
|
export * from './isFunction.js';
|
|
15
|
+
export * from './isHexNumberString.js';
|
|
12
16
|
export * from './isInt32.js';
|
|
13
17
|
export * from './isInteger.js';
|
|
14
18
|
export * from './isIntString.js';
|
|
@@ -25,11 +29,14 @@ export * from './isNumericValue.js';
|
|
|
25
29
|
export * from './isNumericValueArray.js';
|
|
26
30
|
export * from './isObject.js';
|
|
27
31
|
export * from './isObjectWith.js';
|
|
32
|
+
export * from './isOctalNumberString.js';
|
|
33
|
+
export * from './isOptionalArray.js';
|
|
28
34
|
export * from './isOptionalBigInt.js';
|
|
29
35
|
export * from './isOptionalBoolean.js';
|
|
30
36
|
export * from './isOptionalISODateString.js';
|
|
31
37
|
export * from './isOptionalNull.js';
|
|
32
38
|
export * from './isOptionalNumber.js';
|
|
39
|
+
export * from './isOptionalObject.js';
|
|
33
40
|
export * from './isOptionalString.js';
|
|
34
41
|
export * from './isOptionalSymbol.js';
|
|
35
42
|
export * from './isPositiveFiniteNumber.js';
|
|
@@ -48,3 +55,4 @@ export * from './isSymbol.js';
|
|
|
48
55
|
export * from './isSymbolArray.js';
|
|
49
56
|
export * from './isUndefined.js';
|
|
50
57
|
export * from './isUndefinedArray.js';
|
|
58
|
+
export * from './isUnknown.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const isAny = (_input) => true;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { asArray } from '../asArray.js';
|
|
2
1
|
import { isAnyObject } from './isAnyObject.js';
|
|
3
2
|
export const isAnyObjectWith = (input, properties) => {
|
|
4
|
-
return isAnyObject(input) &&
|
|
3
|
+
return isAnyObject(input) && properties.every((property) => property in input);
|
|
5
4
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { asArray } from '../asArray.js';
|
|
2
1
|
import { isAnyObject } from './isAnyObject.js';
|
|
3
2
|
export const isAnyObjectWithOwn = (input, properties) => {
|
|
4
|
-
return isAnyObject(input) &&
|
|
3
|
+
return isAnyObject(input) && properties.every((property) => Object.hasOwn(input, property));
|
|
5
4
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const isArray = (input) => Array.isArray(input);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { isNumericString } from './isNumericString.js';
|
|
2
|
-
export const isNumericValue = (input) => typeof input === 'number' || typeof input === 'bigint' || isNumericString(input);
|
|
2
|
+
export const isNumericValue = (input) => (typeof input === 'number' && !Number.isNaN(input)) || typeof input === 'bigint' || isNumericString(input);
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
import { asArray } from '../asArray.js';
|
|
2
1
|
import { isObject } from './isObject.js';
|
|
3
|
-
export const isObjectWith = (input, properties) =>
|
|
4
|
-
return isObject(input) && asArray(properties).every((property) => property in input);
|
|
5
|
-
};
|
|
2
|
+
export const isObjectWith = (input, properties) => isObject(input) && properties.every((property) => property in input);
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export const isPrimitive = (input) => isString(input) ||
|
|
9
|
-
isNumber(input) ||
|
|
10
|
-
isBigInt(input) ||
|
|
11
|
-
isBoolean(input) ||
|
|
12
|
-
isUndefined(input) ||
|
|
13
|
-
isSymbol(input) ||
|
|
14
|
-
isNull(input);
|
|
1
|
+
export const isPrimitive = (input) => input === null ||
|
|
2
|
+
typeof input === 'string' ||
|
|
3
|
+
typeof input === 'number' ||
|
|
4
|
+
typeof input === 'bigint' ||
|
|
5
|
+
typeof input === 'boolean' ||
|
|
6
|
+
typeof input === 'undefined' ||
|
|
7
|
+
typeof input === 'symbol';
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { shape } from './factory/shape.js';
|
|
2
|
+
import { isUnknown } from './isUnknown.js';
|
|
3
|
+
export const isPromiseFulfilledResult = shape({
|
|
4
|
+
status: 'fulfilled',
|
|
5
|
+
value: isUnknown,
|
|
6
|
+
});
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { shape } from './factory/shape.js';
|
|
2
|
+
import { isAny } from './isAny.js';
|
|
3
|
+
export const isPromiseRejectedResult = shape({
|
|
4
|
+
status: 'rejected',
|
|
5
|
+
reason: isAny,
|
|
6
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const isUnknown = (_input) => true;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { UnknownRecord } from '../types/records.js';
|
|
2
|
+
export declare function assertIsObject(input: unknown, error?: string | Error): asserts input is UnknownRecord;
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
+
export * from './isAny.js';
|
|
1
2
|
export * from './isAnyObject.js';
|
|
2
3
|
export * from './isAnyObjectWith.js';
|
|
3
4
|
export * from './isAnyObjectWithOwn.js';
|
|
5
|
+
export * from './isArray.js';
|
|
4
6
|
export * from './isAsyncIterable.js';
|
|
5
7
|
export * from './isBigInt.js';
|
|
6
8
|
export * from './isBigIntArray.js';
|
|
9
|
+
export * from './isBinaryNumberString.js';
|
|
7
10
|
export * from './isBoolean.js';
|
|
8
11
|
export * from './isBooleanArray.js';
|
|
9
12
|
export * from './isDigitsString.js';
|
|
10
13
|
export * from './isFiniteNumber.js';
|
|
11
14
|
export * from './isFunction.js';
|
|
15
|
+
export * from './isHexNumberString.js';
|
|
12
16
|
export * from './isInt32.js';
|
|
13
17
|
export * from './isInteger.js';
|
|
14
18
|
export * from './isIntString.js';
|
|
@@ -25,11 +29,14 @@ export * from './isNumericValue.js';
|
|
|
25
29
|
export * from './isNumericValueArray.js';
|
|
26
30
|
export * from './isObject.js';
|
|
27
31
|
export * from './isObjectWith.js';
|
|
32
|
+
export * from './isOctalNumberString.js';
|
|
33
|
+
export * from './isOptionalArray.js';
|
|
28
34
|
export * from './isOptionalBigInt.js';
|
|
29
35
|
export * from './isOptionalBoolean.js';
|
|
30
36
|
export * from './isOptionalISODateString.js';
|
|
31
37
|
export * from './isOptionalNull.js';
|
|
32
38
|
export * from './isOptionalNumber.js';
|
|
39
|
+
export * from './isOptionalObject.js';
|
|
33
40
|
export * from './isOptionalString.js';
|
|
34
41
|
export * from './isOptionalSymbol.js';
|
|
35
42
|
export * from './isPositiveFiniteNumber.js';
|
|
@@ -48,3 +55,4 @@ export * from './isSymbol.js';
|
|
|
48
55
|
export * from './isSymbolArray.js';
|
|
49
56
|
export * from './isUndefined.js';
|
|
50
57
|
export * from './isUndefinedArray.js';
|
|
58
|
+
export * from './isUnknown.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isAny: (_input: unknown) => _input is any;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const isAnyObject: <T>(input: T) => input is T & UnknownRecord;
|
|
1
|
+
export declare const isAnyObject: (input: unknown) => input is object;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const isAnyObjectWith: <T, P extends PropertyKey>(input: T, properties: P
|
|
1
|
+
export declare const isAnyObjectWith: <T, P extends PropertyKey>(input: T, properties: P[]) => input is T & Record<P, unknown>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const isAnyObjectWithOwn: <T, P extends PropertyKey>(input: T, properties: P
|
|
1
|
+
export declare const isAnyObjectWithOwn: <T, P extends PropertyKey>(input: T, properties: P[]) => input is T & Record<P, unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isArray: (input: unknown) => input is unknown[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const isAsyncIterable:
|
|
1
|
+
export declare const isAsyncIterable: (input: unknown) => input is AsyncIterable<unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isBinaryNumberString: import("../index.js").TypePredicateFn<`0b${number}` | `0B${number}`>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const isDigitsString: import("../index.js").TypePredicateFn<`${number}`>;
|
|
1
|
+
export declare const isDigitsString: import("../index.js").TypePredicateFn<`${number}` | `${bigint}`>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isHexNumberString: import("../index.js").TypePredicateFn<`0x${string}` | `0X${string}`>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const isIntString: import("../index.js").TypePredicateFn<`${number}`>;
|
|
1
|
+
export declare const isIntString: import("../index.js").TypePredicateFn<`${number}` | `${bigint}`>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const isNumericString: import("../index.js").TypePredicateFn<`${number}`>;
|
|
1
|
+
export declare const isNumericString: import("../index.js").TypePredicateFn<`${number}` | `${bigint}`>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { UnknownRecord } from '../types/records.js';
|
|
2
|
-
export declare const isObject:
|
|
2
|
+
export declare const isObject: (input: unknown) => input is UnknownRecord;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const isObjectWith: <T, P extends PropertyKey>(input: T, properties: P
|
|
1
|
+
export declare const isObjectWith: <T, P extends PropertyKey>(input: T, properties: P[]) => input is T & Record<P, unknown>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isOctalNumberString: import("../index.js").TypePredicateFn<`0o${number}` | `0O${number}`>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isOptionalArray: import("../index.js").TypePredicateFn<unknown[] | undefined>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isOptionalObject: import("../index.js").TypePredicateFn<import("../index.js").UnknownRecord | undefined>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isUnknown: (_input: unknown) => _input is unknown;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NotPromise } from './utils.js';
|
|
2
2
|
export type Primitive = string | number | boolean | bigint | symbol | undefined | null;
|
|
3
|
-
export type NumericString<T extends string | number = number> = `${T}` extends `${number}` ? `${T}` : never;
|
|
3
|
+
export type NumericString<T extends string | number | bigint = number | bigint> = `${T}` extends `${number | bigint}` ? `${T}` : never;
|
|
4
4
|
export type NumericValue = number | bigint | NumericString;
|
|
5
5
|
export type JsonObject = {
|
|
6
6
|
[key: string]: JsonValue;
|
|
@@ -1,3 +1,9 @@
|
|
|
1
1
|
import type { Branded } from './branded.js';
|
|
2
|
+
export type Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
3
|
+
export type DecimalNumberString = `${'-' | '+' | ''}${Digit}${number}`;
|
|
4
|
+
export type HexNumberString = `0${'x' | 'X'}${string}`;
|
|
5
|
+
export type OctalNumberString = `0${'o' | 'O'}${number}`;
|
|
6
|
+
export type BinaryNumberString = `0${'b' | 'B'}${number}`;
|
|
7
|
+
export type ExponentiationString = `${number}${'e' | 'E'}${number}`;
|
|
2
8
|
export type Int32 = Branded<number, 'Int32'>;
|
|
3
9
|
export type NumberRange = [min: number] | [min: number, max: undefined] | [min: number, max: number] | [min: undefined, max: number];
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { Digit } from './numbers.js';
|
|
1
2
|
export type EmptyString = '';
|
|
2
3
|
export type Space = ' ';
|
|
3
4
|
export type AlphaCharacter = 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z';
|
|
4
|
-
export type NumericCharacter =
|
|
5
|
+
export type NumericCharacter = `${Digit}`;
|
|
5
6
|
export type AlphanumericCharacter = AlphaCharacter | Capitalize<AlphaCharacter> | NumericCharacter;
|
|
6
7
|
export type MaybePlural<T extends string> = T | `${T}s`;
|
|
7
8
|
export type StripWhitespace<Type extends string> = string extends Type ? Type : Type extends `${infer First}${infer Rest}` ? First extends Space ? StripWhitespace<Rest> : `${First}${StripWhitespace<Rest>}` : EmptyString;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webdeveric/utils",
|
|
3
3
|
"description": "Just another collection of utilities.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.57.0",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"url": "https://github.com/webdeveric/utils/issues"
|
|
67
67
|
},
|
|
68
68
|
"homepage": "https://github.com/webdeveric/utils/#readme",
|
|
69
|
-
"packageManager": "pnpm@10.6.
|
|
69
|
+
"packageManager": "pnpm@10.6.5+sha512.cdf928fca20832cd59ec53826492b7dc25dc524d4370b6b4adbf65803d32efaa6c1c88147c0ae4e8d579a6c9eec715757b50d4fa35eea179d868eada4ed043af",
|
|
70
70
|
"scripts": {
|
|
71
71
|
"clean": "rimraf ./dist/",
|
|
72
72
|
"prebuild": "pnpm clean",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@commitlint/config-conventional": "^19.8.0",
|
|
89
89
|
"@commitlint/types": "^19.8.0",
|
|
90
|
-
"@types/node": "^22.13.
|
|
90
|
+
"@types/node": "^22.13.13",
|
|
91
91
|
"@vitest/coverage-v8": "^3.0.9",
|
|
92
92
|
"@webdeveric/eslint-config-ts": "^0.11.0",
|
|
93
93
|
"@webdeveric/prettier-config": "^0.3.0",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"rimraf": "^6.0.1",
|
|
107
107
|
"semantic-release": "^24.2.3",
|
|
108
108
|
"typescript": "^5.8.2",
|
|
109
|
-
"validate-package-exports": "^0.
|
|
109
|
+
"validate-package-exports": "^0.9.0",
|
|
110
110
|
"vitest": "^3.0.9"
|
|
111
111
|
},
|
|
112
112
|
"pnpm": {
|