@alwatr/is-number 5.7.26 → 6.0.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/main.js ADDED
@@ -0,0 +1,5 @@
1
+ /* 📦 @alwatr/is-number v6.0.0 */
2
+ function z(j){if(typeof Number.isFinite==="function")return Number.isFinite(j);return typeof j==="number"&&isFinite(j)}function A(j){if(typeof j==="number")return j-j===0;if(typeof j==="string"){let k=j.trim();if(k==="")return!1;let q=+k;return z(q)}return!1}function B(j){if(typeof j==="number")return j-j===0?j:null;if(typeof j==="string"){let k=j.trim();if(k==="")return null;let q=+k;return z(q)?q:null}return null}export{B as toNumber,A as isNumber,z as isFiniteNumber};
3
+
4
+ //# debugId=3E48F7672698F36164756E2164756E21
5
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/main.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * Polyfill for Number.isFinite - properly checks if a value is a finite number\n * without type coercion.\n *\n * @param value - The value to check\n * @returns true if the value is a finite number, false otherwise\n */\nexport function isFiniteNumber(value: unknown): value is number {\n // Use native implementation if available\n if (typeof Number.isFinite === 'function') {\n return Number.isFinite(value);\n }\n // Fallback implementation\n return typeof value === 'number' && isFinite(value);\n}\n\n/**\n * Check if the value is a number or can be converted to a number.\n *\n * @param value - The value to check.\n * @returns `true` if the value is a number or can be converted to a number, otherwise `false`.\n *\n * @example\n * ```ts\n * isNumber(123); // true\n * isNumber('123'); // true\n * isNumber(' 123 '); // true\n * isNumber('0xff'); // true\n * isNumber('-1.1'); // true\n * isNumber(''); // false\n * isNumber(' '); // false\n * isNumber(' 123a '); // false\n * isNumber(NaN); // false\n * isNumber(Infinity); // false\n * isNumber({}); // false\n * isNumber([]); // false\n * isNumber(null); // false\n * isNumber(undefined); // false\n * ```\n */\nexport function isNumber(value: unknown): value is number {\n // Handle number type\n if (typeof value === 'number') {\n return value - value === 0;\n }\n\n // Handle string type\n if (typeof value === 'string') {\n const trimmed = value.trim();\n if (trimmed === '') return false;\n\n // Use unary plus for fastest string-to-number conversion\n const num = +trimmed;\n return isFiniteNumber(num);\n }\n\n return false;\n}\n\n/**\n * Convert a value to a number if possible.\n *\n * @param value - The value to convert.\n * @returns The converted number if valid, otherwise `null`.\n *\n * @example\n * ```ts\n * toNumber(123); // 123\n * toNumber('123'); // 123\n * toNumber(' 123 '); // 123\n * toNumber('0xff'); // 255\n * toNumber('-1.1'); // -1.1\n * toNumber(''); // null\n * toNumber(' '); // null\n * toNumber('123a'); // null\n * toNumber(NaN); // null\n * toNumber(Infinity); // null\n * toNumber({}); // null\n * toNumber([]); // null\n * toNumber(null); // null\n * toNumber(undefined); // null\n * ```\n */\nexport function toNumber(value: unknown): number | null {\n // Handle number type\n if (typeof value === 'number') {\n return value - value === 0 ? value : null;\n }\n\n // Handle string type\n if (typeof value === 'string') {\n const trimmed = value.trim();\n if (trimmed === '') return null;\n\n const num = +trimmed;\n return isFiniteNumber(num) ? num : null;\n }\n\n return null;\n}\n"
6
+ ],
7
+ "mappings": ";AAOO,SAAS,CAAc,CAAC,EAAiC,CAE9D,GAAI,OAAO,OAAO,WAAa,WAC7B,OAAO,OAAO,SAAS,CAAK,EAG9B,OAAO,OAAO,IAAU,UAAY,SAAS,CAAK,EA2B7C,SAAS,CAAQ,CAAC,EAAiC,CAExD,GAAI,OAAO,IAAU,SACnB,OAAO,EAAQ,IAAU,EAI3B,GAAI,OAAO,IAAU,SAAU,CAC7B,IAAM,EAAU,EAAM,KAAK,EAC3B,GAAI,IAAY,GAAI,MAAO,GAG3B,IAAM,EAAM,CAAC,EACb,OAAO,EAAe,CAAG,EAG3B,MAAO,GA2BF,SAAS,CAAQ,CAAC,EAA+B,CAEtD,GAAI,OAAO,IAAU,SACnB,OAAO,EAAQ,IAAU,EAAI,EAAQ,KAIvC,GAAI,OAAO,IAAU,SAAU,CAC7B,IAAM,EAAU,EAAM,KAAK,EAC3B,GAAI,IAAY,GAAI,OAAO,KAE3B,IAAM,EAAM,CAAC,EACb,OAAO,EAAe,CAAG,EAAI,EAAM,KAGrC,OAAO",
8
+ "debugId": "3E48F7672698F36164756E2164756E21",
9
+ "names": []
10
+ }
package/package.json CHANGED
@@ -1,24 +1,24 @@
1
1
  {
2
2
  "name": "@alwatr/is-number",
3
3
  "description": "A simple utility to Check the value is number or can convert to a number, for example string ' 123 ' can be converted to 123.",
4
- "version": "5.7.26",
4
+ "version": "6.0.0",
5
5
  "author": "S. Ali Mihandoost <ali.mihandoost@gmail.com>",
6
6
  "bugs": "https://github.com/Alwatr/nanolib/issues",
7
7
  "devDependencies": {
8
- "@alwatr/nano-build": "6.4.2",
9
- "@alwatr/prettier-config": "6.0.2",
10
- "@alwatr/tsconfig-base": "6.0.4",
8
+ "@alwatr/nano-build": "7.0.0",
9
+ "@alwatr/prettier-config": "7.0.0",
10
+ "@alwatr/tsconfig-base": "7.0.0",
11
11
  "typescript": "^5.9.3"
12
12
  },
13
13
  "exports": {
14
14
  ".": {
15
15
  "types": "./dist/main.d.ts",
16
- "import": "./dist/main.mjs",
17
- "require": "./dist/main.cjs"
16
+ "default": "./dist/main.js"
18
17
  }
19
18
  },
20
19
  "files": [
21
- "**/*.{js,mjs,cjs,map,d.ts,html,md,LEGAL.txt}",
20
+ "**/*.{js,mjs,cjs,ts,map,d.ts,html,LEGAL.txt}",
21
+ "README.md",
22
22
  "LICENSE",
23
23
  "!demo/**/*",
24
24
  "!**/*.test.js"
@@ -61,8 +61,6 @@
61
61
  "utils"
62
62
  ],
63
63
  "license": "MPL-2.0",
64
- "main": "./dist/main.cjs",
65
- "module": "./dist/main.mjs",
66
64
  "prettier": "@alwatr/prettier-config",
67
65
  "publishConfig": {
68
66
  "access": "public"
@@ -75,14 +73,14 @@
75
73
  "scripts": {
76
74
  "b": "bun run build",
77
75
  "build": "bun run build:ts && bun run build:es",
78
- "build:es": "nano-build --preset=module",
76
+ "build:es": "nano-build --preset=module src/main.ts",
79
77
  "build:ts": "tsc --build",
80
78
  "c": "bun run clean",
81
79
  "cb": "bun run clean && bun run build",
82
80
  "clean": "rm -rfv dist *.tsbuildinfo",
83
- "d": "bun run build:es && bun --enable-source-maps --trace-warnings",
81
+ "d": "bun run build:es && bun",
84
82
  "t": "bun run test",
85
- "test": "echo test-skipped",
83
+ "test": "bun test",
86
84
  "w": "bun run watch",
87
85
  "watch": "bun run watch:ts & bun run watch:es",
88
86
  "watch:es": "bun run build:es --watch",
@@ -91,5 +89,5 @@
91
89
  "sideEffects": false,
92
90
  "type": "module",
93
91
  "types": "./dist/main.d.ts",
94
- "gitHead": "c3889e3756b0a0f9b935a1b702a1373ac52cb379"
92
+ "gitHead": "056102a1c8a563bbae8a290b6830450f467322a3"
95
93
  }
package/src/main.ts ADDED
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Polyfill for Number.isFinite - properly checks if a value is a finite number
3
+ * without type coercion.
4
+ *
5
+ * @param value - The value to check
6
+ * @returns true if the value is a finite number, false otherwise
7
+ */
8
+ export function isFiniteNumber(value: unknown): value is number {
9
+ // Use native implementation if available
10
+ if (typeof Number.isFinite === 'function') {
11
+ return Number.isFinite(value);
12
+ }
13
+ // Fallback implementation
14
+ return typeof value === 'number' && isFinite(value);
15
+ }
16
+
17
+ /**
18
+ * Check if the value is a number or can be converted to a number.
19
+ *
20
+ * @param value - The value to check.
21
+ * @returns `true` if the value is a number or can be converted to a number, otherwise `false`.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * isNumber(123); // true
26
+ * isNumber('123'); // true
27
+ * isNumber(' 123 '); // true
28
+ * isNumber('0xff'); // true
29
+ * isNumber('-1.1'); // true
30
+ * isNumber(''); // false
31
+ * isNumber(' '); // false
32
+ * isNumber(' 123a '); // false
33
+ * isNumber(NaN); // false
34
+ * isNumber(Infinity); // false
35
+ * isNumber({}); // false
36
+ * isNumber([]); // false
37
+ * isNumber(null); // false
38
+ * isNumber(undefined); // false
39
+ * ```
40
+ */
41
+ export function isNumber(value: unknown): value is number {
42
+ // Handle number type
43
+ if (typeof value === 'number') {
44
+ return value - value === 0;
45
+ }
46
+
47
+ // Handle string type
48
+ if (typeof value === 'string') {
49
+ const trimmed = value.trim();
50
+ if (trimmed === '') return false;
51
+
52
+ // Use unary plus for fastest string-to-number conversion
53
+ const num = +trimmed;
54
+ return isFiniteNumber(num);
55
+ }
56
+
57
+ return false;
58
+ }
59
+
60
+ /**
61
+ * Convert a value to a number if possible.
62
+ *
63
+ * @param value - The value to convert.
64
+ * @returns The converted number if valid, otherwise `null`.
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * toNumber(123); // 123
69
+ * toNumber('123'); // 123
70
+ * toNumber(' 123 '); // 123
71
+ * toNumber('0xff'); // 255
72
+ * toNumber('-1.1'); // -1.1
73
+ * toNumber(''); // null
74
+ * toNumber(' '); // null
75
+ * toNumber('123a'); // null
76
+ * toNumber(NaN); // null
77
+ * toNumber(Infinity); // null
78
+ * toNumber({}); // null
79
+ * toNumber([]); // null
80
+ * toNumber(null); // null
81
+ * toNumber(undefined); // null
82
+ * ```
83
+ */
84
+ export function toNumber(value: unknown): number | null {
85
+ // Handle number type
86
+ if (typeof value === 'number') {
87
+ return value - value === 0 ? value : null;
88
+ }
89
+
90
+ // Handle string type
91
+ if (typeof value === 'string') {
92
+ const trimmed = value.trim();
93
+ if (trimmed === '') return null;
94
+
95
+ const num = +trimmed;
96
+ return isFiniteNumber(num) ? num : null;
97
+ }
98
+
99
+ return null;
100
+ }
package/CHANGELOG.md DELETED
@@ -1,394 +0,0 @@
1
- # Change Log
2
-
3
- All notable changes to this project will be documented in this file.
4
- See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
-
6
- ## [5.7.26](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.25...@alwatr/is-number@5.7.26) (2026-03-16)
7
-
8
- ### 🔨 Code Refactoring
9
-
10
- * migrate build scripts from yarn to bun across multiple packages ([d90e962](https://github.com/Alwatr/nanolib/commit/d90e962f15e5c951e191d5f02341279b6472abc3))
11
-
12
- ## [5.7.25](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.24...@alwatr/is-number@5.7.25) (2026-02-18)
13
-
14
- **Note:** Version bump only for package @alwatr/is-number
15
-
16
- ## [5.7.24](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.23...@alwatr/is-number@5.7.24) (2025-12-23)
17
-
18
- **Note:** Version bump only for package @alwatr/is-number
19
-
20
- ## [5.7.23](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.22...@alwatr/is-number@5.7.23) (2025-12-13)
21
-
22
- **Note:** Version bump only for package @alwatr/is-number
23
-
24
- ## [5.7.22](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.21...@alwatr/is-number@5.7.22) (2025-12-10)
25
-
26
- **Note:** Version bump only for package @alwatr/is-number
27
-
28
- ## [5.7.21](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.20...@alwatr/is-number@5.7.21) (2025-11-18)
29
-
30
- ### 🔨 Code Refactoring
31
-
32
- * remove unnecessary type declarations from tsconfig.json files ([89bcc7d](https://github.com/Alwatr/nanolib/commit/89bcc7db839807110b80f8ba34414ea9734d9c75))
33
-
34
- ## [5.7.20](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.19...@alwatr/is-number@5.7.20) (2025-11-15)
35
-
36
- **Note:** Version bump only for package @alwatr/is-number
37
-
38
- ## [5.7.19](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.18...@alwatr/is-number@5.7.19) (2025-11-15)
39
-
40
- **Note:** Version bump only for package @alwatr/is-number
41
-
42
- ## [5.7.18](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.17...@alwatr/is-number@5.7.18) (2025-11-04)
43
-
44
- **Note:** Version bump only for package @alwatr/is-number
45
-
46
- ## [5.7.17](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.16...@alwatr/is-number@5.7.17) (2025-10-06)
47
-
48
- ### 🔗 Dependencies update
49
-
50
- * bump the npm-dependencies group with 4 updates ([9825815](https://github.com/Alwatr/nanolib/commit/982581552bbb4b97dca52af5e93a80937f0c3109))
51
-
52
- ## [5.7.16](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.15...@alwatr/is-number@5.7.16) (2025-09-27)
53
-
54
- ### 🧹 Miscellaneous Chores
55
-
56
- * exclude test files from package distribution ([86f4f2f](https://github.com/Alwatr/nanolib/commit/86f4f2f5985845c5cf3a3a9398de7b2f98ce53e7))
57
-
58
- ## [5.7.15](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.14...@alwatr/is-number@5.7.15) (2025-09-22)
59
-
60
- **Note:** Version bump only for package @alwatr/is-number
61
-
62
- ## [5.7.14](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.13...@alwatr/is-number@5.7.14) (2025-09-22)
63
-
64
- **Note:** Version bump only for package @alwatr/is-number
65
-
66
- ## [5.7.13](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.12...@alwatr/is-number@5.7.13) (2025-09-21)
67
-
68
- **Note:** Version bump only for package @alwatr/is-number
69
-
70
- ## [5.7.12](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.11...@alwatr/is-number@5.7.12) (2025-09-20)
71
-
72
- ### 🐛 Bug Fixes
73
-
74
- * add sideEffects property to package.json files for better tree-shaking ([c7b9e74](https://github.com/Alwatr/nanolib/commit/c7b9e74e1920c8e35b438742de61883ca62da58c))
75
- * add sideEffects property to package.json files for better tree-shaking ([e8402c4](https://github.com/Alwatr/nanolib/commit/e8402c481a14a1f807a37aaa862a936713d26176))
76
-
77
- ### 🧹 Miscellaneous Chores
78
-
79
- * remove duplicate sideEffects property from multiple package.json files ([b123f86](https://github.com/Alwatr/nanolib/commit/b123f86be81481de2314aae9bb2eeb629743d24c))
80
-
81
- ## [5.7.11](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.10...@alwatr/is-number@5.7.11) (2025-09-19)
82
-
83
- **Note:** Version bump only for package @alwatr/is-number
84
-
85
- ## [5.7.10](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.9...@alwatr/is-number@5.7.10) (2025-09-15)
86
-
87
- **Note:** Version bump only for package @alwatr/is-number
88
-
89
- ## [5.7.9](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.8...@alwatr/is-number@5.7.9) (2025-09-13)
90
-
91
- **Note:** Version bump only for package @alwatr/is-number
92
-
93
- ## [5.7.8](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.7...@alwatr/is-number@5.7.8) (2025-09-13)
94
-
95
- ### 🧹 Miscellaneous Chores
96
-
97
- * remove package-tracer dependency and related code from fetch package ([96fe4e9](https://github.com/Alwatr/nanolib/commit/96fe4e9552a205f218ceed187c55e4e904a07089))
98
-
99
- ## [5.7.7](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.6...@alwatr/is-number@5.7.7) (2025-09-09)
100
-
101
- ### 🐛 Bug Fixes
102
-
103
- * update isFiniteNumber return type to indicate it checks for finite numbers ([2ed06c4](https://github.com/Alwatr/nanolib/commit/2ed06c43ce97a1c04cdc5779e1866fc6445b1ca2))
104
-
105
- ### 🧹 Miscellaneous Chores
106
-
107
- * remove trailing newlines from contributing sections in README files ([e8ab1bc](https://github.com/Alwatr/nanolib/commit/e8ab1bc43e0addea5ccd4c897c2cec597cb9e15f))
108
-
109
- ## [5.7.6](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.5...@alwatr/is-number@5.7.6) (2025-09-06)
110
-
111
- **Note:** Version bump only for package @alwatr/is-number
112
-
113
- ## [5.7.5](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.4...@alwatr/is-number@5.7.5) (2025-09-05)
114
-
115
- ### 🔗 Dependencies update
116
-
117
- * update jest to version 30.1.3 and @types/node to version 22.18.1 ([754212b](https://github.com/Alwatr/nanolib/commit/754212b1523cfc4cfe26c9e9f6d634aa8311e0b7))
118
-
119
- ## [5.7.4](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.3...@alwatr/is-number@5.7.4) (2025-09-01)
120
-
121
- ### 🔗 Dependencies update
122
-
123
- * update lerna-lite dependencies to version 4.7.3 and jest to 30.1.2 ([95d7870](https://github.com/Alwatr/nanolib/commit/95d7870ec7ad1e6ed2688bafddcabf46857f6981))
124
-
125
- ## [5.7.3](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.2...@alwatr/is-number@5.7.3) (2025-08-23)
126
-
127
- **Note:** Version bump only for package @alwatr/is-number
128
-
129
- ## [5.7.2](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.0...@alwatr/is-number@5.7.2) (2025-08-23)
130
-
131
- ### 🐛 Bug Fixes
132
-
133
- * update license from AGPL-3.0-only to MPL-2.0 ([d20968e](https://github.com/Alwatr/nanolib/commit/d20968e60cc89b1dcdf9b96507178da6ed562f55))
134
- * update package versions in multiple package.json files ([7638b1c](https://github.com/Alwatr/nanolib/commit/7638b1cafee2b4e0f97db7a89ac9fba6384b9b10))
135
-
136
- ### 🔨 Code Refactoring
137
-
138
- * Updated all package.json files in the project to change dependency version specifiers from "workspace:^" to "workspace:*" for consistency and to allow for more flexible version resolution. ([db6a4f7](https://github.com/Alwatr/nanolib/commit/db6a4f76deec2d1d8039978144e4bc51b6f1a0e3))
139
-
140
- ### 🧹 Miscellaneous Chores
141
-
142
- * reformat all package.json files ([ceda45d](https://github.com/Alwatr/nanolib/commit/ceda45de186667790474f729cb4b161a5148ce19))
143
-
144
- ### 🔗 Dependencies update
145
-
146
- * update TypeScript and Jest versions across all packages to improve compatibility and performance ([31baf36](https://github.com/Alwatr/nanolib/commit/31baf366101e92e27db66a21c849fb101f19be47))
147
-
148
- ## [5.7.1](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.0...@alwatr/is-number@5.7.1) (2025-08-23)
149
-
150
- ### Code Refactoring
151
-
152
- * Updated all package.json files in the project to change dependency version specifiers from "workspace:^" to "workspace:*" for consistency and to allow for more flexible version resolution. ([db6a4f7](https://github.com/Alwatr/nanolib/commit/db6a4f76deec2d1d8039978144e4bc51b6f1a0e3)) by @alimd
153
-
154
- ## [5.7.0](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.6.2...@alwatr/is-number@5.7.0) (2025-04-20)
155
-
156
- ### Features
157
-
158
- * **is-number:** update isNumber function return type to use type predicate ([f489dec](https://github.com/Alwatr/nanolib/commit/f489decf9cce1473a3d87a4aeb65ff07965832e8)) by @alimd
159
-
160
- ## <small>5.6.2 (2025-04-15)</small>
161
-
162
- **Note:** Version bump only for package @alwatr/is-number
163
-
164
- ## [5.6.1](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.6.0...@alwatr/is-number@5.6.1) (2025-04-01)
165
-
166
- **Note:** Version bump only for package @alwatr/is-number
167
-
168
- ## [5.6.0](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.5.0...@alwatr/is-number@5.6.0) (2025-03-18)
169
-
170
- ### Features
171
-
172
- * **is-number:** add polyfill for Number.isFinite to check finite numbers ([27c60b1](https://github.com/Alwatr/nanolib/commit/27c60b16e69e87fd62dee25ee21012651b9ba7ca)) by @alimd
173
- * **is-number:** add toNumber function to convert various values to numbers ([3f4a9d1](https://github.com/Alwatr/nanolib/commit/3f4a9d1d316ba685c47cafdee031e231ef0d40c5)) by @alimd
174
-
175
- ### Code Refactoring
176
-
177
- * **is-number:** enhance isNumber function to handle additional cases and improve documentation ([16f16b4](https://github.com/Alwatr/nanolib/commit/16f16b41c487f874f94dd64aaa778c618879db82)) by @alimd
178
-
179
- ## [5.5.0](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.4.0...@alwatr/is-number@5.5.0) (2025-03-06)
180
-
181
- ### Miscellaneous Chores
182
-
183
- * update username casing in changelog entries ([9722ac9](https://github.com/Alwatr/nanolib/commit/9722ac9a078438a4e8ebfa5826ea70e0e3a52ca6)) by @
184
-
185
- ### Dependencies update
186
-
187
- * bump the development-dependencies group across 1 directory with 11 updates ([720c395](https://github.com/Alwatr/nanolib/commit/720c3954da55c929fe8fb16957121f4c51fb7f0c)) by @dependabot[bot]
188
-
189
- ## [5.4.0](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.1.8...@alwatr/is-number@5.4.0) (2025-02-18)
190
-
191
- ## 5.3.0 (2025-02-03)
192
-
193
- ### Miscellaneous Chores
194
-
195
- * edit README ([3860b3d](https://github.com/Alwatr/nanolib/commit/3860b3df48ab82dc479d5236c2e8579df614aabf)) by @
196
-
197
- ### Dependencies update
198
-
199
- * bump the development-dependencies group across 1 directory with 11 updates ([cb79d07](https://github.com/Alwatr/nanolib/commit/cb79d072a57c79e1c01abff1a293d6757bb65350)) by @
200
- * update typescript and @types/node to version 5.7.3 and 22.13.0 respectively across multiple packages ([ddab05b](https://github.com/Alwatr/nanolib/commit/ddab05b5d767c30191f36a065e4bc88744e8e3fe)) by @
201
-
202
- ## 5.0.0 (2024-11-02)
203
-
204
- ### ⚠ BREAKING CHANGES
205
-
206
- * To simplify version management and ensure consistency, all nanolib packages now use the same version as @alwatr/nanolib. This may require updates to your project's dependencies.
207
-
208
- ### Code Refactoring
209
-
210
- * use the same version as @alwatr/nanolib ([60eb860](https://github.com/Alwatr/nanolib/commit/60eb860a0e33dfffe2d1d95e63ce54c60876be06)) by @
211
-
212
- ## [5.3.0](https://github.com/Alwatr/nanolib/compare/v5.2.1...v5.3.0) (2025-02-03)
213
-
214
- ### Miscellaneous Chores
215
-
216
- * edit README ([3860b3d](https://github.com/Alwatr/nanolib/commit/3860b3df48ab82dc479d5236c2e8579df614aabf)) by @ArmanAsadian
217
-
218
- ### Dependencies update
219
-
220
- * bump the development-dependencies group across 1 directory with 11 updates ([cb79d07](https://github.com/Alwatr/nanolib/commit/cb79d072a57c79e1c01abff1a293d6757bb65350)) by @dependabot[bot]
221
- * update typescript and @types/node to version 5.7.3 and 22.13.0 respectively across multiple packages ([ddab05b](https://github.com/Alwatr/nanolib/commit/ddab05b5d767c30191f36a065e4bc88744e8e3fe)) by @alimd
222
-
223
- ## 5.0.0 (2024-11-02)
224
-
225
- ### ⚠ BREAKING CHANGES
226
-
227
- * To simplify version management and ensure consistency, all nanolib packages now use the same version as @alwatr/nanolib. This may require updates to your project's dependencies.
228
-
229
- ### Features
230
-
231
- * **is-number:** extract from @alwatr/util ([1c8a676](https://github.com/Alwatr/nanolib/commit/1c8a676ccefcad12436f41b96eeb39c60cc09040)) by @
232
- * **is-number:** Update is-number package description and add Number.isFinite polyfill ([a7c8e38](https://github.com/Alwatr/nanolib/commit/a7c8e38eb3e939199cf5637feaf08ac0ed98e2e6)) by @
233
- * use `package-tracer` ([cc3c5f9](https://github.com/Alwatr/nanolib/commit/cc3c5f9c1a3d03f0d81b46835665f16a0426fd0d)) by @
234
-
235
- ### Bug Fixes
236
-
237
- * all dependeny topology ([1c17f34](https://github.com/Alwatr/nanolib/commit/1c17f349adf3e98e2a80ab2da4f0f81028dc9c5f)) by @
238
- * **is-number:** Remove Number.isFinite polyfill ([aa149f3](https://github.com/Alwatr/nanolib/commit/aa149f302f96d961b058fc3a9d70399c1023cbe3)) by @
239
-
240
- ### Code Refactoring
241
-
242
- * prevent side-effects ([01e00e1](https://github.com/Alwatr/nanolib/commit/01e00e191385cc92b28677df0c01a085916ae677)) by @
243
- * use the same version as @alwatr/nanolib ([60eb860](https://github.com/Alwatr/nanolib/commit/60eb860a0e33dfffe2d1d95e63ce54c60876be06)) by @
244
-
245
- ### Miscellaneous Chores
246
-
247
- * **deps:** update ([1a45030](https://github.com/Alwatr/nanolib/commit/1a450305440b710a300787d4ca24b1ed8c6a39d7)) by @
248
- * **deps:** update ([8e70dff](https://github.com/Alwatr/nanolib/commit/8e70dffb1e751496ef2e72d6cffd685f1fea44e3)) by @
249
- * include LICENSE and LEGAL files to publish ([09f366f](https://github.com/Alwatr/nanolib/commit/09f366f680bfa9fb26acb2cd1ccbc68c5a9e9ad8)) by @
250
- * **is-number:** Add additional keywords to is-number package.json ([048b734](https://github.com/Alwatr/nanolib/commit/048b734bffc65d61876f692f69dab55a829ea0c8)) by @
251
- * **is-number:** Add additional keywords to is-number package.json ([7ba726c](https://github.com/Alwatr/nanolib/commit/7ba726cb53a784ccc1dd37dab92b27ff833b3881)) by @
252
- * **is-number:** change the license to AGPL-3.0 ([3ad68cb](https://github.com/Alwatr/nanolib/commit/3ad68cb43659fe2af8358ff1393e0085e85b8857)) by @
253
- * **is-number:** Update version to 1.0.0-alpha.0 in package.json ([d20bcad](https://github.com/Alwatr/nanolib/commit/d20bcad4fe9f997d7e8153a99955576d9fa59ee9)) by @
254
- * Update build and lint scripts ([392d0b7](https://github.com/Alwatr/nanolib/commit/392d0b71f446bce336b0256119a80f07aff794ba)) by @
255
- * Update package.json exports for [@alwatr](https://github.com/alwatr) packages ([dacb362](https://github.com/Alwatr/nanolib/commit/dacb362b145e3c51b4aba00ff643687a3fac11d2)) by @
256
- * Update test scripts and dependencies ([93d2fe6](https://github.com/Alwatr/nanolib/commit/93d2fe6d7ce9c38a300e0c7ed75874916767a14b)) by @
257
-
258
- ### Dependencies update
259
-
260
- * bump @types/node ([3d80fed](https://github.com/Alwatr/nanolib/commit/3d80fedaf720af792feb060c2f81c737ebb84e11)) by @
261
- * bump the development-dependencies group across 1 directory with 10 updates ([9ed98ff](https://github.com/Alwatr/nanolib/commit/9ed98ffd0668d5a36e255c82edab3af53bffda8f)) by @
262
- * bump the development-dependencies group with 10 updates ([fa4aaf0](https://github.com/Alwatr/nanolib/commit/fa4aaf04c907ecae06aa14000ce35216170c15ad)) by @
263
- * bump the development-dependencies group with 2 updates ([be5d6c2](https://github.com/Alwatr/nanolib/commit/be5d6c2d86b937f32cebc6848aaff85af07055dd)) by @
264
- * upd ([451d025](https://github.com/Alwatr/nanolib/commit/451d0255ba96ed55f897a6f44f62cf4e6d2b12be)) by @
265
- * update ([c36ed50](https://github.com/Alwatr/nanolib/commit/c36ed50f68da2f5608ccd96119963a16cfacb4ce)) by @
266
- * update all ([53342f6](https://github.com/Alwatr/nanolib/commit/53342f67a8a013127f073540bc11929f1813c05c)) by @
267
- * update all dependencies ([1e0c30e](https://github.com/Alwatr/nanolib/commit/1e0c30e6a3a8e19deb5185814e24ab6c08dca573)) by @
268
- * update all dependencies ([0e908b4](https://github.com/Alwatr/nanolib/commit/0e908b476a6b976ec2447f864c8cafcbb8a0f099)) by @
269
- * upgrade ([6dbd300](https://github.com/Alwatr/nanolib/commit/6dbd300642c9bcc9e7d0b281e244bf1b06eb1c38)) by @
270
-
271
- ## [1.1.8](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.1.7...@alwatr/is-number@1.1.8) (2024-11-02)
272
-
273
- **Note:** Version bump only for package @alwatr/is-number
274
-
275
- ## [1.1.7](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.1.6...@alwatr/is-number@1.1.7) (2024-10-25)
276
-
277
- **Note:** Version bump only for package @alwatr/is-number
278
-
279
- ## [1.1.6](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.1.5...@alwatr/is-number@1.1.6) (2024-10-12)
280
-
281
- **Note:** Version bump only for package @alwatr/is-number
282
-
283
- ## [1.1.5](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.1.4...@alwatr/is-number@1.1.5) (2024-10-11)
284
-
285
- ### Code Refactoring
286
-
287
- - prevent side-effects ([01e00e1](https://github.com/Alwatr/nanolib/commit/01e00e191385cc92b28677df0c01a085916ae677)) by @mohammadhonarvar
288
-
289
- ## [1.1.4](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.1.3...@alwatr/is-number@1.1.4) (2024-10-11)
290
-
291
- ### Miscellaneous Chores
292
-
293
- - include LICENSE and LEGAL files to publish ([09f366f](https://github.com/Alwatr/nanolib/commit/09f366f680bfa9fb26acb2cd1ccbc68c5a9e9ad8)) by @alimd
294
-
295
- ## [1.1.3](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.1.2...@alwatr/is-number@1.1.3) (2024-10-11)
296
-
297
- **Note:** Version bump only for package @alwatr/is-number
298
-
299
- ## [1.1.2](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.1.1...@alwatr/is-number@1.1.2) (2024-10-10)
300
-
301
- ### Dependencies update
302
-
303
- - bump the development-dependencies group with 10 updates ([fa4aaf0](https://github.com/Alwatr/nanolib/commit/fa4aaf04c907ecae06aa14000ce35216170c15ad)) by @dependabot[bot]
304
-
305
- ## [1.1.1](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.1.0...@alwatr/is-number@1.1.1) (2024-10-08)
306
-
307
- **Note:** Version bump only for package @alwatr/is-number
308
-
309
- ## [1.1.0](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.11...@alwatr/is-number@1.1.0) (2024-09-29)
310
-
311
- ### Features
312
-
313
- - use `package-tracer` ([cc3c5f9](https://github.com/Alwatr/nanolib/commit/cc3c5f9c1a3d03f0d81b46835665f16a0426fd0d)) by @mohammadhonarvar
314
-
315
- ### Bug Fixes
316
-
317
- - all dependeny topology ([1c17f34](https://github.com/Alwatr/nanolib/commit/1c17f349adf3e98e2a80ab2da4f0f81028dc9c5f)) by @mohammadhonarvar
318
-
319
- ### Miscellaneous Chores
320
-
321
- - **is-number:** change the license to AGPL-3.0 ([3ad68cb](https://github.com/Alwatr/nanolib/commit/3ad68cb43659fe2af8358ff1393e0085e85b8857)) by @ArmanAsadian
322
- - Update build and lint scripts ([392d0b7](https://github.com/Alwatr/nanolib/commit/392d0b71f446bce336b0256119a80f07aff794ba)) by @alimd
323
-
324
- ### Dependencies update
325
-
326
- - bump @types/node ([3d80fed](https://github.com/Alwatr/nanolib/commit/3d80fedaf720af792feb060c2f81c737ebb84e11)) by @dependabot[bot]
327
-
328
- ## [1.0.11](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.10...@alwatr/is-number@1.0.11) (2024-09-21)
329
-
330
- **Note:** Version bump only for package @alwatr/is-number
331
-
332
- ## [1.0.10](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.9...@alwatr/is-number@1.0.10) (2024-09-15)
333
-
334
- ### Dependencies update
335
-
336
- - bump the development-dependencies group across 1 directory with 10 updates ([9ed98ff](https://github.com/Alwatr/nanolib/commit/9ed98ffd0668d5a36e255c82edab3af53bffda8f)) by @dependabot[bot]
337
- - update ([c36ed50](https://github.com/Alwatr/nanolib/commit/c36ed50f68da2f5608ccd96119963a16cfacb4ce)) by @alimd
338
-
339
- ## [1.0.9](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.8...@alwatr/is-number@1.0.9) (2024-08-31)
340
-
341
- ### Miscellaneous Chores
342
-
343
- - Update package.json exports for [@alwatr](https://github.com/alwatr) packages ([dacb362](https://github.com/Alwatr/nanolib/commit/dacb362b145e3c51b4aba00ff643687a3fac11d2)) by @
344
-
345
- ## [1.0.8](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.7...@alwatr/is-number@1.0.8) (2024-08-31)
346
-
347
- ### Dependencies update
348
-
349
- - update all dependencies ([1e0c30e](https://github.com/Alwatr/nanolib/commit/1e0c30e6a3a8e19deb5185814e24ab6c08dca573)) by @alimd
350
-
351
- ## [1.0.7](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.6...@alwatr/is-number@1.0.7) (2024-07-04)
352
-
353
- ### Dependencies update
354
-
355
- - update all dependencies ([0e908b4](https://github.com/Alwatr/nanolib/commit/0e908b476a6b976ec2447f864c8cafcbb8a0f099)) by @
356
-
357
- ## [1.0.6](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.5...@alwatr/is-number@1.0.6) (2024-05-12)
358
-
359
- ### Dependencies update
360
-
361
- - upgrade ([6dbd300](https://github.com/Alwatr/nanolib/commit/6dbd300642c9bcc9e7d0b281e244bf1b06eb1c38)) by @alimd
362
-
363
- ## [1.0.5](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.4...@alwatr/is-number@1.0.5) (2024-04-25)
364
-
365
- **Note:** Version bump only for package @alwatr/is-number
366
-
367
- ## [1.0.4](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.3...@alwatr/is-number@1.0.4) (2024-03-28)
368
-
369
- **Note:** Version bump only for package @alwatr/is-number
370
-
371
- ## [1.0.3](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.2...@alwatr/is-number@1.0.3) (2024-01-31)
372
-
373
- ### Miscellaneous Chores
374
-
375
- - **deps:** update ([1a45030](https://github.com/Alwatr/nanolib/commit/1a450305440b710a300787d4ca24b1ed8c6a39d7)) by @alimd
376
-
377
- ## [1.0.2](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.1...@alwatr/is-number@1.0.2) (2024-01-24)
378
-
379
- **Note:** Version bump only for package @alwatr/is-number
380
-
381
- ## [1.0.1](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.0...@alwatr/is-number@1.0.1) (2024-01-20)
382
-
383
- **Note:** Version bump only for package @alwatr/is-number
384
-
385
- # 1.0.0 (2024-01-16)
386
-
387
- ### Bug Fixes
388
-
389
- - **is-number:** Remove Number.isFinite polyfill ([aa149f3](https://github.com/Alwatr/nanolib/commit/aa149f302f96d961b058fc3a9d70399c1023cbe3)) by @alimd
390
-
391
- ### Features
392
-
393
- - **is-number:** extract from @alwatr/util ([1c8a676](https://github.com/Alwatr/nanolib/commit/1c8a676ccefcad12436f41b96eeb39c60cc09040)) by @njfamirm
394
- - **is-number:** Update is-number package description and add Number.isFinite polyfill ([a7c8e38](https://github.com/Alwatr/nanolib/commit/a7c8e38eb3e939199cf5637feaf08ac0ed98e2e6)) by @alimd
package/dist/main.cjs DELETED
@@ -1,3 +0,0 @@
1
- /** 📦 @alwatr/is-number v5.7.26 */
2
- "use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:true})};var __copyProps=(to,from,except,desc)=>{if(from&&typeof from==="object"||typeof from==="function"){for(let key of __getOwnPropNames(from))if(!__hasOwnProp.call(to,key)&&key!==except)__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable})}return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:true}),mod);var main_exports={};__export(main_exports,{isFiniteNumber:()=>isFiniteNumber,isNumber:()=>isNumber,toNumber:()=>toNumber});module.exports=__toCommonJS(main_exports);function isFiniteNumber(value){if(typeof Number.isFinite==="function"){return Number.isFinite(value)}return typeof value==="number"&&isFinite(value)}function isNumber(value){if(typeof value==="number"){return value-value===0}if(typeof value==="string"){const trimmed=value.trim();if(trimmed==="")return false;const num=+trimmed;return isFiniteNumber(num)}return false}function toNumber(value){if(typeof value==="number"){return value-value===0?value:null}if(typeof value==="string"){const trimmed=value.trim();if(trimmed==="")return null;const num=+trimmed;return isFiniteNumber(num)?num:null}return null}0&&(module.exports={isFiniteNumber,isNumber,toNumber});
3
- //# sourceMappingURL=main.cjs.map
package/dist/main.cjs.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/main.ts"],
4
- "sourcesContent": ["/**\n * Polyfill for Number.isFinite - properly checks if a value is a finite number\n * without type coercion.\n *\n * @param value - The value to check\n * @returns true if the value is a finite number, false otherwise\n */\nexport function isFiniteNumber(value: unknown): value is number {\n // Use native implementation if available\n if (typeof Number.isFinite === 'function') {\n return Number.isFinite(value);\n }\n // Fallback implementation\n return typeof value === 'number' && isFinite(value);\n}\n\n/**\n * Check if the value is a number or can be converted to a number.\n *\n * @param value - The value to check.\n * @returns `true` if the value is a number or can be converted to a number, otherwise `false`.\n *\n * @example\n * ```ts\n * isNumber(123); // true\n * isNumber('123'); // true\n * isNumber(' 123 '); // true\n * isNumber('0xff'); // true\n * isNumber('-1.1'); // true\n * isNumber(''); // false\n * isNumber(' '); // false\n * isNumber(' 123a '); // false\n * isNumber(NaN); // false\n * isNumber(Infinity); // false\n * isNumber({}); // false\n * isNumber([]); // false\n * isNumber(null); // false\n * isNumber(undefined); // false\n * ```\n */\nexport function isNumber(value: unknown): value is number {\n // Handle number type\n if (typeof value === 'number') {\n return value - value === 0;\n }\n\n // Handle string type\n if (typeof value === 'string') {\n const trimmed = value.trim();\n if (trimmed === '') return false;\n\n // Use unary plus for fastest string-to-number conversion\n const num = +trimmed;\n return isFiniteNumber(num);\n }\n\n return false;\n}\n\n/**\n * Convert a value to a number if possible.\n *\n * @param value - The value to convert.\n * @returns The converted number if valid, otherwise `null`.\n *\n * @example\n * ```ts\n * toNumber(123); // 123\n * toNumber('123'); // 123\n * toNumber(' 123 '); // 123\n * toNumber('0xff'); // 255\n * toNumber('-1.1'); // -1.1\n * toNumber(''); // null\n * toNumber(' '); // null\n * toNumber('123a'); // null\n * toNumber(NaN); // null\n * toNumber(Infinity); // null\n * toNumber({}); // null\n * toNumber([]); // null\n * toNumber(null); // null\n * toNumber(undefined); // null\n * ```\n */\nexport function toNumber(value: unknown): number | null {\n // Handle number type\n if (typeof value === 'number') {\n return value - value === 0 ? value : null;\n }\n\n // Handle string type\n if (typeof value === 'string') {\n const trimmed = value.trim();\n if (trimmed === '') return null;\n\n const num = +trimmed;\n return isFiniteNumber(num) ? num : null;\n }\n\n return null;\n}\n"],
5
- "mappings": ";qqBAAA,qKAOO,SAAS,eAAe,MAAiC,CAE9D,GAAI,OAAO,OAAO,WAAa,WAAY,CACzC,OAAO,OAAO,SAAS,KAAK,CAC9B,CAEA,OAAO,OAAO,QAAU,UAAY,SAAS,KAAK,CACpD,CA0BO,SAAS,SAAS,MAAiC,CAExD,GAAI,OAAO,QAAU,SAAU,CAC7B,OAAO,MAAQ,QAAU,CAC3B,CAGA,GAAI,OAAO,QAAU,SAAU,CAC7B,MAAM,QAAU,MAAM,KAAK,EAC3B,GAAI,UAAY,GAAI,MAAO,OAG3B,MAAM,IAAM,CAAC,QACb,OAAO,eAAe,GAAG,CAC3B,CAEA,MAAO,MACT,CA0BO,SAAS,SAAS,MAA+B,CAEtD,GAAI,OAAO,QAAU,SAAU,CAC7B,OAAO,MAAQ,QAAU,EAAI,MAAQ,IACvC,CAGA,GAAI,OAAO,QAAU,SAAU,CAC7B,MAAM,QAAU,MAAM,KAAK,EAC3B,GAAI,UAAY,GAAI,OAAO,KAE3B,MAAM,IAAM,CAAC,QACb,OAAO,eAAe,GAAG,EAAI,IAAM,IACrC,CAEA,OAAO,IACT",
6
- "names": []
7
- }
package/dist/main.mjs DELETED
@@ -1,3 +0,0 @@
1
- /** 📦 @alwatr/is-number v5.7.26 */
2
- function isFiniteNumber(value){if(typeof Number.isFinite==="function"){return Number.isFinite(value)}return typeof value==="number"&&isFinite(value)}function isNumber(value){if(typeof value==="number"){return value-value===0}if(typeof value==="string"){const trimmed=value.trim();if(trimmed==="")return false;const num=+trimmed;return isFiniteNumber(num)}return false}function toNumber(value){if(typeof value==="number"){return value-value===0?value:null}if(typeof value==="string"){const trimmed=value.trim();if(trimmed==="")return null;const num=+trimmed;return isFiniteNumber(num)?num:null}return null}export{isFiniteNumber,isNumber,toNumber};
3
- //# sourceMappingURL=main.mjs.map
package/dist/main.mjs.map DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../src/main.ts"],
4
- "sourcesContent": ["/**\n * Polyfill for Number.isFinite - properly checks if a value is a finite number\n * without type coercion.\n *\n * @param value - The value to check\n * @returns true if the value is a finite number, false otherwise\n */\nexport function isFiniteNumber(value: unknown): value is number {\n // Use native implementation if available\n if (typeof Number.isFinite === 'function') {\n return Number.isFinite(value);\n }\n // Fallback implementation\n return typeof value === 'number' && isFinite(value);\n}\n\n/**\n * Check if the value is a number or can be converted to a number.\n *\n * @param value - The value to check.\n * @returns `true` if the value is a number or can be converted to a number, otherwise `false`.\n *\n * @example\n * ```ts\n * isNumber(123); // true\n * isNumber('123'); // true\n * isNumber(' 123 '); // true\n * isNumber('0xff'); // true\n * isNumber('-1.1'); // true\n * isNumber(''); // false\n * isNumber(' '); // false\n * isNumber(' 123a '); // false\n * isNumber(NaN); // false\n * isNumber(Infinity); // false\n * isNumber({}); // false\n * isNumber([]); // false\n * isNumber(null); // false\n * isNumber(undefined); // false\n * ```\n */\nexport function isNumber(value: unknown): value is number {\n // Handle number type\n if (typeof value === 'number') {\n return value - value === 0;\n }\n\n // Handle string type\n if (typeof value === 'string') {\n const trimmed = value.trim();\n if (trimmed === '') return false;\n\n // Use unary plus for fastest string-to-number conversion\n const num = +trimmed;\n return isFiniteNumber(num);\n }\n\n return false;\n}\n\n/**\n * Convert a value to a number if possible.\n *\n * @param value - The value to convert.\n * @returns The converted number if valid, otherwise `null`.\n *\n * @example\n * ```ts\n * toNumber(123); // 123\n * toNumber('123'); // 123\n * toNumber(' 123 '); // 123\n * toNumber('0xff'); // 255\n * toNumber('-1.1'); // -1.1\n * toNumber(''); // null\n * toNumber(' '); // null\n * toNumber('123a'); // null\n * toNumber(NaN); // null\n * toNumber(Infinity); // null\n * toNumber({}); // null\n * toNumber([]); // null\n * toNumber(null); // null\n * toNumber(undefined); // null\n * ```\n */\nexport function toNumber(value: unknown): number | null {\n // Handle number type\n if (typeof value === 'number') {\n return value - value === 0 ? value : null;\n }\n\n // Handle string type\n if (typeof value === 'string') {\n const trimmed = value.trim();\n if (trimmed === '') return null;\n\n const num = +trimmed;\n return isFiniteNumber(num) ? num : null;\n }\n\n return null;\n}\n"],
5
- "mappings": ";AAOO,SAAS,eAAe,MAAiC,CAE9D,GAAI,OAAO,OAAO,WAAa,WAAY,CACzC,OAAO,OAAO,SAAS,KAAK,CAC9B,CAEA,OAAO,OAAO,QAAU,UAAY,SAAS,KAAK,CACpD,CA0BO,SAAS,SAAS,MAAiC,CAExD,GAAI,OAAO,QAAU,SAAU,CAC7B,OAAO,MAAQ,QAAU,CAC3B,CAGA,GAAI,OAAO,QAAU,SAAU,CAC7B,MAAM,QAAU,MAAM,KAAK,EAC3B,GAAI,UAAY,GAAI,MAAO,OAG3B,MAAM,IAAM,CAAC,QACb,OAAO,eAAe,GAAG,CAC3B,CAEA,MAAO,MACT,CA0BO,SAAS,SAAS,MAA+B,CAEtD,GAAI,OAAO,QAAU,SAAU,CAC7B,OAAO,MAAQ,QAAU,EAAI,MAAQ,IACvC,CAGA,GAAI,OAAO,QAAU,SAAU,CAC7B,MAAM,QAAU,MAAM,KAAK,EAC3B,GAAI,UAAY,GAAI,OAAO,KAE3B,MAAM,IAAM,CAAC,QACb,OAAO,eAAe,GAAG,EAAI,IAAM,IACrC,CAEA,OAAO,IACT",
6
- "names": []
7
- }