@webdeveric/utils 0.46.0 → 0.47.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/assertion/assertIsInt32.js +10 -0
- package/dist/cjs/assertion/index.js +1 -0
- package/dist/cjs/index.js +1 -0
- package/dist/cjs/jsonParse.js +8 -0
- package/dist/cjs/predicate/index.js +1 -0
- package/dist/cjs/predicate/isInt32.js +8 -0
- package/dist/cjs/types/index.js +1 -0
- package/dist/cjs/types/numbers.js +2 -0
- package/dist/mjs/assertion/assertIsInt32.js +7 -0
- package/dist/mjs/assertion/index.js +1 -0
- package/dist/mjs/index.js +1 -0
- package/dist/mjs/jsonParse.js +5 -0
- package/dist/mjs/predicate/index.js +1 -0
- package/dist/mjs/predicate/isInt32.js +5 -0
- package/dist/mjs/types/index.js +1 -0
- package/dist/mjs/types/numbers.js +1 -0
- package/dist/types/assertion/assertIsInt32.d.ts +2 -0
- package/dist/types/assertion/index.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/jsonParse.d.ts +5 -0
- package/dist/types/predicate/index.d.ts +1 -0
- package/dist/types/predicate/isInt32.d.ts +2 -0
- package/dist/types/types/branded.d.ts +6 -1
- package/dist/types/types/index.d.ts +1 -0
- package/dist/types/types/numbers.d.ts +2 -0
- package/package.json +7 -7
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assertIsInt32 = assertIsInt32;
|
|
4
|
+
const isInt32_js_1 = require("../predicate/isInt32.js");
|
|
5
|
+
const getError_js_1 = require("./getError.js");
|
|
6
|
+
function assertIsInt32(input, error = 'input is not an Int32') {
|
|
7
|
+
if (!(0, isInt32_js_1.isInt32)(input)) {
|
|
8
|
+
throw (0, getError_js_1.getError)(error);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
@@ -23,6 +23,7 @@ __exportStar(require("./assertIsBooleanArray.js"), exports);
|
|
|
23
23
|
__exportStar(require("./assertIsDigitsString.js"), exports);
|
|
24
24
|
__exportStar(require("./assertIsFiniteNumber.js"), exports);
|
|
25
25
|
__exportStar(require("./assertIsFunction.js"), exports);
|
|
26
|
+
__exportStar(require("./assertIsInt32.js"), exports);
|
|
26
27
|
__exportStar(require("./assertIsInteger.js"), exports);
|
|
27
28
|
__exportStar(require("./assertIsIntString.js"), exports);
|
|
28
29
|
__exportStar(require("./assertIsIterable.js"), exports);
|
package/dist/cjs/index.js
CHANGED
|
@@ -49,6 +49,7 @@ __exportStar(require("./inRange.js"), exports);
|
|
|
49
49
|
__exportStar(require("./isEmpty.js"), exports);
|
|
50
50
|
__exportStar(require("./iterateForever.js"), exports);
|
|
51
51
|
__exportStar(require("./joinStrings.js"), exports);
|
|
52
|
+
__exportStar(require("./jsonParse.js"), exports);
|
|
52
53
|
__exportStar(require("./looksLikeURL.js"), exports);
|
|
53
54
|
__exportStar(require("./normalize.js"), exports);
|
|
54
55
|
__exportStar(require("./parseNumber.js"), exports);
|
|
@@ -25,6 +25,7 @@ __exportStar(require("./isBooleanArray.js"), exports);
|
|
|
25
25
|
__exportStar(require("./isDigitsString.js"), exports);
|
|
26
26
|
__exportStar(require("./isFiniteNumber.js"), exports);
|
|
27
27
|
__exportStar(require("./isFunction.js"), exports);
|
|
28
|
+
__exportStar(require("./isInt32.js"), exports);
|
|
28
29
|
__exportStar(require("./isInteger.js"), exports);
|
|
29
30
|
__exportStar(require("./isIntString.js"), exports);
|
|
30
31
|
__exportStar(require("./isISODateString.js"), exports);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isInt32 = isInt32;
|
|
4
|
+
function isInt32(input) {
|
|
5
|
+
const int32Min = -2_147_483_648;
|
|
6
|
+
const int32Max = 2_147_483_647;
|
|
7
|
+
return typeof input === 'number' && Number.isInteger(input) && input >= int32Min && input <= int32Max;
|
|
8
|
+
}
|
package/dist/cjs/types/index.js
CHANGED
|
@@ -19,6 +19,7 @@ __exportStar(require("./branded.js"), exports);
|
|
|
19
19
|
__exportStar(require("./common.js"), exports);
|
|
20
20
|
__exportStar(require("./date-time.js"), exports);
|
|
21
21
|
__exportStar(require("./functions.js"), exports);
|
|
22
|
+
__exportStar(require("./numbers.js"), exports);
|
|
22
23
|
__exportStar(require("./objects.js"), exports);
|
|
23
24
|
__exportStar(require("./records.js"), exports);
|
|
24
25
|
__exportStar(require("./strings.js"), exports);
|
|
@@ -7,6 +7,7 @@ export * from './assertIsBooleanArray.js';
|
|
|
7
7
|
export * from './assertIsDigitsString.js';
|
|
8
8
|
export * from './assertIsFiniteNumber.js';
|
|
9
9
|
export * from './assertIsFunction.js';
|
|
10
|
+
export * from './assertIsInt32.js';
|
|
10
11
|
export * from './assertIsInteger.js';
|
|
11
12
|
export * from './assertIsIntString.js';
|
|
12
13
|
export * from './assertIsIterable.js';
|
package/dist/mjs/index.js
CHANGED
|
@@ -33,6 +33,7 @@ export * from './inRange.js';
|
|
|
33
33
|
export * from './isEmpty.js';
|
|
34
34
|
export * from './iterateForever.js';
|
|
35
35
|
export * from './joinStrings.js';
|
|
36
|
+
export * from './jsonParse.js';
|
|
36
37
|
export * from './looksLikeURL.js';
|
|
37
38
|
export * from './normalize.js';
|
|
38
39
|
export * from './parseNumber.js';
|
|
@@ -9,6 +9,7 @@ export * from './isBooleanArray.js';
|
|
|
9
9
|
export * from './isDigitsString.js';
|
|
10
10
|
export * from './isFiniteNumber.js';
|
|
11
11
|
export * from './isFunction.js';
|
|
12
|
+
export * from './isInt32.js';
|
|
12
13
|
export * from './isInteger.js';
|
|
13
14
|
export * from './isIntString.js';
|
|
14
15
|
export * from './isISODateString.js';
|
package/dist/mjs/types/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -7,6 +7,7 @@ export * from './assertIsBooleanArray.js';
|
|
|
7
7
|
export * from './assertIsDigitsString.js';
|
|
8
8
|
export * from './assertIsFiniteNumber.js';
|
|
9
9
|
export * from './assertIsFunction.js';
|
|
10
|
+
export * from './assertIsInt32.js';
|
|
10
11
|
export * from './assertIsInteger.js';
|
|
11
12
|
export * from './assertIsIntString.js';
|
|
12
13
|
export * from './assertIsIterable.js';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -33,6 +33,7 @@ export * from './inRange.js';
|
|
|
33
33
|
export * from './isEmpty.js';
|
|
34
34
|
export * from './iterateForever.js';
|
|
35
35
|
export * from './joinStrings.js';
|
|
36
|
+
export * from './jsonParse.js';
|
|
36
37
|
export * from './looksLikeURL.js';
|
|
37
38
|
export * from './normalize.js';
|
|
38
39
|
export * from './parseNumber.js';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { TypeAssertionFn } from './types/functions.js';
|
|
2
|
+
export type JsonReviver = Parameters<JSON['parse']>[1];
|
|
3
|
+
export declare function jsonParse(input: string): unknown;
|
|
4
|
+
export declare function jsonParse(input: string, reviver?: JsonReviver): unknown;
|
|
5
|
+
export declare function jsonParse<T>(input: string, reviver: JsonReviver | undefined, assertionFn: TypeAssertionFn<T>): T;
|
|
@@ -9,6 +9,7 @@ export * from './isBooleanArray.js';
|
|
|
9
9
|
export * from './isDigitsString.js';
|
|
10
10
|
export * from './isFiniteNumber.js';
|
|
11
11
|
export * from './isFunction.js';
|
|
12
|
+
export * from './isInt32.js';
|
|
12
13
|
export * from './isInteger.js';
|
|
13
14
|
export * from './isIntString.js';
|
|
14
15
|
export * from './isISODateString.js';
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
+
import type { Primitive } from './common.js';
|
|
1
2
|
declare const brand: unique symbol;
|
|
2
|
-
type Brand<Id> = {
|
|
3
|
+
export type Brand<Id> = {
|
|
3
4
|
[brand]: Id;
|
|
4
5
|
};
|
|
5
6
|
export type Branded<Type, Id> = Type & Brand<Id>;
|
|
7
|
+
export type Unbranded<Type> = Type extends Branded<infer Inner, unknown> ? Omit<Inner, typeof brand> : Type;
|
|
8
|
+
export type RemoveBranding<Type> = Type extends Primitive ? Unbranded<Type> : {
|
|
9
|
+
[Property in keyof Type]: Type extends Primitive ? Unbranded<Type[Property]> : RemoveBranding<Type[Property]>;
|
|
10
|
+
};
|
|
6
11
|
export {};
|
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.47.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@
|
|
69
|
+
"packageManager": "pnpm@10.2.0+sha512.0d27364e0139c6aadeed65ada153135e0ca96c8da42123bd50047f961339dc7a758fc2e944b428f52be570d1bd3372455c1c65fa2e7aa0bfbf931190f9552001",
|
|
70
70
|
"scripts": {
|
|
71
71
|
"clean": "rimraf ./dist/",
|
|
72
72
|
"prebuild": "pnpm clean",
|
|
@@ -85,13 +85,13 @@
|
|
|
85
85
|
},
|
|
86
86
|
"prettier": "@webdeveric/prettier-config",
|
|
87
87
|
"devDependencies": {
|
|
88
|
-
"@commitlint/config-conventional": "^19.
|
|
88
|
+
"@commitlint/config-conventional": "^19.7.1",
|
|
89
89
|
"@commitlint/types": "^19.5.0",
|
|
90
|
-
"@types/node": "^22.
|
|
91
|
-
"@vitest/coverage-v8": "^3.0.
|
|
90
|
+
"@types/node": "^22.13.1",
|
|
91
|
+
"@vitest/coverage-v8": "^3.0.5",
|
|
92
92
|
"@webdeveric/eslint-config-ts": "^0.11.0",
|
|
93
93
|
"@webdeveric/prettier-config": "^0.3.0",
|
|
94
|
-
"commitlint": "^19.
|
|
94
|
+
"commitlint": "^19.7.1",
|
|
95
95
|
"commitlint-plugin-cspell": "^0.1.1",
|
|
96
96
|
"conventional-changelog-conventionalcommits": "^8.0.0",
|
|
97
97
|
"cspell": "^8.17.3",
|
|
@@ -107,6 +107,6 @@
|
|
|
107
107
|
"semantic-release": "^24.2.1",
|
|
108
108
|
"typescript": "^5.7.3",
|
|
109
109
|
"validate-package-exports": "^0.8.0",
|
|
110
|
-
"vitest": "^3.0.
|
|
110
|
+
"vitest": "^3.0.5"
|
|
111
111
|
}
|
|
112
112
|
}
|