@alwatr/is-number 5.7.27 → 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.27",
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,12 +73,12 @@
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
83
  "test": "bun test",
86
84
  "w": "bun run watch",
@@ -91,5 +89,5 @@
91
89
  "sideEffects": false,
92
90
  "type": "module",
93
91
  "types": "./dist/main.d.ts",
94
- "gitHead": "def1decf8f496f4b0d3d3ab952c346c689c30160"
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,398 +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.27](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.26...@alwatr/is-number@5.7.27) (2026-03-18)
7
-
8
- **Note:** Version bump only for package @alwatr/is-number
9
-
10
- ## [5.7.26](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.25...@alwatr/is-number@5.7.26) (2026-03-16)
11
-
12
- ### 🔨 Code Refactoring
13
-
14
- * migrate build scripts from yarn to bun across multiple packages ([d90e962](https://github.com/Alwatr/nanolib/commit/d90e962f15e5c951e191d5f02341279b6472abc3))
15
-
16
- ## [5.7.25](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.24...@alwatr/is-number@5.7.25) (2026-02-18)
17
-
18
- **Note:** Version bump only for package @alwatr/is-number
19
-
20
- ## [5.7.24](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.23...@alwatr/is-number@5.7.24) (2025-12-23)
21
-
22
- **Note:** Version bump only for package @alwatr/is-number
23
-
24
- ## [5.7.23](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.22...@alwatr/is-number@5.7.23) (2025-12-13)
25
-
26
- **Note:** Version bump only for package @alwatr/is-number
27
-
28
- ## [5.7.22](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.21...@alwatr/is-number@5.7.22) (2025-12-10)
29
-
30
- **Note:** Version bump only for package @alwatr/is-number
31
-
32
- ## [5.7.21](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.20...@alwatr/is-number@5.7.21) (2025-11-18)
33
-
34
- ### 🔨 Code Refactoring
35
-
36
- * remove unnecessary type declarations from tsconfig.json files ([89bcc7d](https://github.com/Alwatr/nanolib/commit/89bcc7db839807110b80f8ba34414ea9734d9c75))
37
-
38
- ## [5.7.20](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.19...@alwatr/is-number@5.7.20) (2025-11-15)
39
-
40
- **Note:** Version bump only for package @alwatr/is-number
41
-
42
- ## [5.7.19](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.18...@alwatr/is-number@5.7.19) (2025-11-15)
43
-
44
- **Note:** Version bump only for package @alwatr/is-number
45
-
46
- ## [5.7.18](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.17...@alwatr/is-number@5.7.18) (2025-11-04)
47
-
48
- **Note:** Version bump only for package @alwatr/is-number
49
-
50
- ## [5.7.17](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.16...@alwatr/is-number@5.7.17) (2025-10-06)
51
-
52
- ### 🔗 Dependencies update
53
-
54
- * bump the npm-dependencies group with 4 updates ([9825815](https://github.com/Alwatr/nanolib/commit/982581552bbb4b97dca52af5e93a80937f0c3109))
55
-
56
- ## [5.7.16](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.15...@alwatr/is-number@5.7.16) (2025-09-27)
57
-
58
- ### 🧹 Miscellaneous Chores
59
-
60
- * exclude test files from package distribution ([86f4f2f](https://github.com/Alwatr/nanolib/commit/86f4f2f5985845c5cf3a3a9398de7b2f98ce53e7))
61
-
62
- ## [5.7.15](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.14...@alwatr/is-number@5.7.15) (2025-09-22)
63
-
64
- **Note:** Version bump only for package @alwatr/is-number
65
-
66
- ## [5.7.14](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.13...@alwatr/is-number@5.7.14) (2025-09-22)
67
-
68
- **Note:** Version bump only for package @alwatr/is-number
69
-
70
- ## [5.7.13](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.12...@alwatr/is-number@5.7.13) (2025-09-21)
71
-
72
- **Note:** Version bump only for package @alwatr/is-number
73
-
74
- ## [5.7.12](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.11...@alwatr/is-number@5.7.12) (2025-09-20)
75
-
76
- ### 🐛 Bug Fixes
77
-
78
- * add sideEffects property to package.json files for better tree-shaking ([c7b9e74](https://github.com/Alwatr/nanolib/commit/c7b9e74e1920c8e35b438742de61883ca62da58c))
79
- * add sideEffects property to package.json files for better tree-shaking ([e8402c4](https://github.com/Alwatr/nanolib/commit/e8402c481a14a1f807a37aaa862a936713d26176))
80
-
81
- ### 🧹 Miscellaneous Chores
82
-
83
- * remove duplicate sideEffects property from multiple package.json files ([b123f86](https://github.com/Alwatr/nanolib/commit/b123f86be81481de2314aae9bb2eeb629743d24c))
84
-
85
- ## [5.7.11](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.10...@alwatr/is-number@5.7.11) (2025-09-19)
86
-
87
- **Note:** Version bump only for package @alwatr/is-number
88
-
89
- ## [5.7.10](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.9...@alwatr/is-number@5.7.10) (2025-09-15)
90
-
91
- **Note:** Version bump only for package @alwatr/is-number
92
-
93
- ## [5.7.9](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.8...@alwatr/is-number@5.7.9) (2025-09-13)
94
-
95
- **Note:** Version bump only for package @alwatr/is-number
96
-
97
- ## [5.7.8](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.7...@alwatr/is-number@5.7.8) (2025-09-13)
98
-
99
- ### 🧹 Miscellaneous Chores
100
-
101
- * remove package-tracer dependency and related code from fetch package ([96fe4e9](https://github.com/Alwatr/nanolib/commit/96fe4e9552a205f218ceed187c55e4e904a07089))
102
-
103
- ## [5.7.7](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.6...@alwatr/is-number@5.7.7) (2025-09-09)
104
-
105
- ### 🐛 Bug Fixes
106
-
107
- * update isFiniteNumber return type to indicate it checks for finite numbers ([2ed06c4](https://github.com/Alwatr/nanolib/commit/2ed06c43ce97a1c04cdc5779e1866fc6445b1ca2))
108
-
109
- ### 🧹 Miscellaneous Chores
110
-
111
- * remove trailing newlines from contributing sections in README files ([e8ab1bc](https://github.com/Alwatr/nanolib/commit/e8ab1bc43e0addea5ccd4c897c2cec597cb9e15f))
112
-
113
- ## [5.7.6](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.5...@alwatr/is-number@5.7.6) (2025-09-06)
114
-
115
- **Note:** Version bump only for package @alwatr/is-number
116
-
117
- ## [5.7.5](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.4...@alwatr/is-number@5.7.5) (2025-09-05)
118
-
119
- ### 🔗 Dependencies update
120
-
121
- * update jest to version 30.1.3 and @types/node to version 22.18.1 ([754212b](https://github.com/Alwatr/nanolib/commit/754212b1523cfc4cfe26c9e9f6d634aa8311e0b7))
122
-
123
- ## [5.7.4](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.3...@alwatr/is-number@5.7.4) (2025-09-01)
124
-
125
- ### 🔗 Dependencies update
126
-
127
- * update lerna-lite dependencies to version 4.7.3 and jest to 30.1.2 ([95d7870](https://github.com/Alwatr/nanolib/commit/95d7870ec7ad1e6ed2688bafddcabf46857f6981))
128
-
129
- ## [5.7.3](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.2...@alwatr/is-number@5.7.3) (2025-08-23)
130
-
131
- **Note:** Version bump only for package @alwatr/is-number
132
-
133
- ## [5.7.2](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.0...@alwatr/is-number@5.7.2) (2025-08-23)
134
-
135
- ### 🐛 Bug Fixes
136
-
137
- * update license from AGPL-3.0-only to MPL-2.0 ([d20968e](https://github.com/Alwatr/nanolib/commit/d20968e60cc89b1dcdf9b96507178da6ed562f55))
138
- * update package versions in multiple package.json files ([7638b1c](https://github.com/Alwatr/nanolib/commit/7638b1cafee2b4e0f97db7a89ac9fba6384b9b10))
139
-
140
- ### 🔨 Code Refactoring
141
-
142
- * 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))
143
-
144
- ### 🧹 Miscellaneous Chores
145
-
146
- * reformat all package.json files ([ceda45d](https://github.com/Alwatr/nanolib/commit/ceda45de186667790474f729cb4b161a5148ce19))
147
-
148
- ### 🔗 Dependencies update
149
-
150
- * update TypeScript and Jest versions across all packages to improve compatibility and performance ([31baf36](https://github.com/Alwatr/nanolib/commit/31baf366101e92e27db66a21c849fb101f19be47))
151
-
152
- ## [5.7.1](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.7.0...@alwatr/is-number@5.7.1) (2025-08-23)
153
-
154
- ### Code Refactoring
155
-
156
- * 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
157
-
158
- ## [5.7.0](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.6.2...@alwatr/is-number@5.7.0) (2025-04-20)
159
-
160
- ### Features
161
-
162
- * **is-number:** update isNumber function return type to use type predicate ([f489dec](https://github.com/Alwatr/nanolib/commit/f489decf9cce1473a3d87a4aeb65ff07965832e8)) by @alimd
163
-
164
- ## <small>5.6.2 (2025-04-15)</small>
165
-
166
- **Note:** Version bump only for package @alwatr/is-number
167
-
168
- ## [5.6.1](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.6.0...@alwatr/is-number@5.6.1) (2025-04-01)
169
-
170
- **Note:** Version bump only for package @alwatr/is-number
171
-
172
- ## [5.6.0](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.5.0...@alwatr/is-number@5.6.0) (2025-03-18)
173
-
174
- ### Features
175
-
176
- * **is-number:** add polyfill for Number.isFinite to check finite numbers ([27c60b1](https://github.com/Alwatr/nanolib/commit/27c60b16e69e87fd62dee25ee21012651b9ba7ca)) by @alimd
177
- * **is-number:** add toNumber function to convert various values to numbers ([3f4a9d1](https://github.com/Alwatr/nanolib/commit/3f4a9d1d316ba685c47cafdee031e231ef0d40c5)) by @alimd
178
-
179
- ### Code Refactoring
180
-
181
- * **is-number:** enhance isNumber function to handle additional cases and improve documentation ([16f16b4](https://github.com/Alwatr/nanolib/commit/16f16b41c487f874f94dd64aaa778c618879db82)) by @alimd
182
-
183
- ## [5.5.0](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@5.4.0...@alwatr/is-number@5.5.0) (2025-03-06)
184
-
185
- ### Miscellaneous Chores
186
-
187
- * update username casing in changelog entries ([9722ac9](https://github.com/Alwatr/nanolib/commit/9722ac9a078438a4e8ebfa5826ea70e0e3a52ca6)) by @
188
-
189
- ### Dependencies update
190
-
191
- * bump the development-dependencies group across 1 directory with 11 updates ([720c395](https://github.com/Alwatr/nanolib/commit/720c3954da55c929fe8fb16957121f4c51fb7f0c)) by @dependabot[bot]
192
-
193
- ## [5.4.0](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.1.8...@alwatr/is-number@5.4.0) (2025-02-18)
194
-
195
- ## 5.3.0 (2025-02-03)
196
-
197
- ### Miscellaneous Chores
198
-
199
- * edit README ([3860b3d](https://github.com/Alwatr/nanolib/commit/3860b3df48ab82dc479d5236c2e8579df614aabf)) by @
200
-
201
- ### Dependencies update
202
-
203
- * bump the development-dependencies group across 1 directory with 11 updates ([cb79d07](https://github.com/Alwatr/nanolib/commit/cb79d072a57c79e1c01abff1a293d6757bb65350)) by @
204
- * 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 @
205
-
206
- ## 5.0.0 (2024-11-02)
207
-
208
- ### ⚠ BREAKING CHANGES
209
-
210
- * 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.
211
-
212
- ### Code Refactoring
213
-
214
- * use the same version as @alwatr/nanolib ([60eb860](https://github.com/Alwatr/nanolib/commit/60eb860a0e33dfffe2d1d95e63ce54c60876be06)) by @
215
-
216
- ## [5.3.0](https://github.com/Alwatr/nanolib/compare/v5.2.1...v5.3.0) (2025-02-03)
217
-
218
- ### Miscellaneous Chores
219
-
220
- * edit README ([3860b3d](https://github.com/Alwatr/nanolib/commit/3860b3df48ab82dc479d5236c2e8579df614aabf)) by @ArmanAsadian
221
-
222
- ### Dependencies update
223
-
224
- * bump the development-dependencies group across 1 directory with 11 updates ([cb79d07](https://github.com/Alwatr/nanolib/commit/cb79d072a57c79e1c01abff1a293d6757bb65350)) by @dependabot[bot]
225
- * 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
226
-
227
- ## 5.0.0 (2024-11-02)
228
-
229
- ### ⚠ BREAKING CHANGES
230
-
231
- * 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.
232
-
233
- ### Features
234
-
235
- * **is-number:** extract from @alwatr/util ([1c8a676](https://github.com/Alwatr/nanolib/commit/1c8a676ccefcad12436f41b96eeb39c60cc09040)) by @
236
- * **is-number:** Update is-number package description and add Number.isFinite polyfill ([a7c8e38](https://github.com/Alwatr/nanolib/commit/a7c8e38eb3e939199cf5637feaf08ac0ed98e2e6)) by @
237
- * use `package-tracer` ([cc3c5f9](https://github.com/Alwatr/nanolib/commit/cc3c5f9c1a3d03f0d81b46835665f16a0426fd0d)) by @
238
-
239
- ### Bug Fixes
240
-
241
- * all dependeny topology ([1c17f34](https://github.com/Alwatr/nanolib/commit/1c17f349adf3e98e2a80ab2da4f0f81028dc9c5f)) by @
242
- * **is-number:** Remove Number.isFinite polyfill ([aa149f3](https://github.com/Alwatr/nanolib/commit/aa149f302f96d961b058fc3a9d70399c1023cbe3)) by @
243
-
244
- ### Code Refactoring
245
-
246
- * prevent side-effects ([01e00e1](https://github.com/Alwatr/nanolib/commit/01e00e191385cc92b28677df0c01a085916ae677)) by @
247
- * use the same version as @alwatr/nanolib ([60eb860](https://github.com/Alwatr/nanolib/commit/60eb860a0e33dfffe2d1d95e63ce54c60876be06)) by @
248
-
249
- ### Miscellaneous Chores
250
-
251
- * **deps:** update ([1a45030](https://github.com/Alwatr/nanolib/commit/1a450305440b710a300787d4ca24b1ed8c6a39d7)) by @
252
- * **deps:** update ([8e70dff](https://github.com/Alwatr/nanolib/commit/8e70dffb1e751496ef2e72d6cffd685f1fea44e3)) by @
253
- * include LICENSE and LEGAL files to publish ([09f366f](https://github.com/Alwatr/nanolib/commit/09f366f680bfa9fb26acb2cd1ccbc68c5a9e9ad8)) by @
254
- * **is-number:** Add additional keywords to is-number package.json ([048b734](https://github.com/Alwatr/nanolib/commit/048b734bffc65d61876f692f69dab55a829ea0c8)) by @
255
- * **is-number:** Add additional keywords to is-number package.json ([7ba726c](https://github.com/Alwatr/nanolib/commit/7ba726cb53a784ccc1dd37dab92b27ff833b3881)) by @
256
- * **is-number:** change the license to AGPL-3.0 ([3ad68cb](https://github.com/Alwatr/nanolib/commit/3ad68cb43659fe2af8358ff1393e0085e85b8857)) by @
257
- * **is-number:** Update version to 1.0.0-alpha.0 in package.json ([d20bcad](https://github.com/Alwatr/nanolib/commit/d20bcad4fe9f997d7e8153a99955576d9fa59ee9)) by @
258
- * Update build and lint scripts ([392d0b7](https://github.com/Alwatr/nanolib/commit/392d0b71f446bce336b0256119a80f07aff794ba)) by @
259
- * Update package.json exports for [@alwatr](https://github.com/alwatr) packages ([dacb362](https://github.com/Alwatr/nanolib/commit/dacb362b145e3c51b4aba00ff643687a3fac11d2)) by @
260
- * Update test scripts and dependencies ([93d2fe6](https://github.com/Alwatr/nanolib/commit/93d2fe6d7ce9c38a300e0c7ed75874916767a14b)) by @
261
-
262
- ### Dependencies update
263
-
264
- * bump @types/node ([3d80fed](https://github.com/Alwatr/nanolib/commit/3d80fedaf720af792feb060c2f81c737ebb84e11)) by @
265
- * bump the development-dependencies group across 1 directory with 10 updates ([9ed98ff](https://github.com/Alwatr/nanolib/commit/9ed98ffd0668d5a36e255c82edab3af53bffda8f)) by @
266
- * bump the development-dependencies group with 10 updates ([fa4aaf0](https://github.com/Alwatr/nanolib/commit/fa4aaf04c907ecae06aa14000ce35216170c15ad)) by @
267
- * bump the development-dependencies group with 2 updates ([be5d6c2](https://github.com/Alwatr/nanolib/commit/be5d6c2d86b937f32cebc6848aaff85af07055dd)) by @
268
- * upd ([451d025](https://github.com/Alwatr/nanolib/commit/451d0255ba96ed55f897a6f44f62cf4e6d2b12be)) by @
269
- * update ([c36ed50](https://github.com/Alwatr/nanolib/commit/c36ed50f68da2f5608ccd96119963a16cfacb4ce)) by @
270
- * update all ([53342f6](https://github.com/Alwatr/nanolib/commit/53342f67a8a013127f073540bc11929f1813c05c)) by @
271
- * update all dependencies ([1e0c30e](https://github.com/Alwatr/nanolib/commit/1e0c30e6a3a8e19deb5185814e24ab6c08dca573)) by @
272
- * update all dependencies ([0e908b4](https://github.com/Alwatr/nanolib/commit/0e908b476a6b976ec2447f864c8cafcbb8a0f099)) by @
273
- * upgrade ([6dbd300](https://github.com/Alwatr/nanolib/commit/6dbd300642c9bcc9e7d0b281e244bf1b06eb1c38)) by @
274
-
275
- ## [1.1.8](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.1.7...@alwatr/is-number@1.1.8) (2024-11-02)
276
-
277
- **Note:** Version bump only for package @alwatr/is-number
278
-
279
- ## [1.1.7](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.1.6...@alwatr/is-number@1.1.7) (2024-10-25)
280
-
281
- **Note:** Version bump only for package @alwatr/is-number
282
-
283
- ## [1.1.6](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.1.5...@alwatr/is-number@1.1.6) (2024-10-12)
284
-
285
- **Note:** Version bump only for package @alwatr/is-number
286
-
287
- ## [1.1.5](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.1.4...@alwatr/is-number@1.1.5) (2024-10-11)
288
-
289
- ### Code Refactoring
290
-
291
- - prevent side-effects ([01e00e1](https://github.com/Alwatr/nanolib/commit/01e00e191385cc92b28677df0c01a085916ae677)) by @mohammadhonarvar
292
-
293
- ## [1.1.4](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.1.3...@alwatr/is-number@1.1.4) (2024-10-11)
294
-
295
- ### Miscellaneous Chores
296
-
297
- - include LICENSE and LEGAL files to publish ([09f366f](https://github.com/Alwatr/nanolib/commit/09f366f680bfa9fb26acb2cd1ccbc68c5a9e9ad8)) by @alimd
298
-
299
- ## [1.1.3](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.1.2...@alwatr/is-number@1.1.3) (2024-10-11)
300
-
301
- **Note:** Version bump only for package @alwatr/is-number
302
-
303
- ## [1.1.2](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.1.1...@alwatr/is-number@1.1.2) (2024-10-10)
304
-
305
- ### Dependencies update
306
-
307
- - bump the development-dependencies group with 10 updates ([fa4aaf0](https://github.com/Alwatr/nanolib/commit/fa4aaf04c907ecae06aa14000ce35216170c15ad)) by @dependabot[bot]
308
-
309
- ## [1.1.1](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.1.0...@alwatr/is-number@1.1.1) (2024-10-08)
310
-
311
- **Note:** Version bump only for package @alwatr/is-number
312
-
313
- ## [1.1.0](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.11...@alwatr/is-number@1.1.0) (2024-09-29)
314
-
315
- ### Features
316
-
317
- - use `package-tracer` ([cc3c5f9](https://github.com/Alwatr/nanolib/commit/cc3c5f9c1a3d03f0d81b46835665f16a0426fd0d)) by @mohammadhonarvar
318
-
319
- ### Bug Fixes
320
-
321
- - all dependeny topology ([1c17f34](https://github.com/Alwatr/nanolib/commit/1c17f349adf3e98e2a80ab2da4f0f81028dc9c5f)) by @mohammadhonarvar
322
-
323
- ### Miscellaneous Chores
324
-
325
- - **is-number:** change the license to AGPL-3.0 ([3ad68cb](https://github.com/Alwatr/nanolib/commit/3ad68cb43659fe2af8358ff1393e0085e85b8857)) by @ArmanAsadian
326
- - Update build and lint scripts ([392d0b7](https://github.com/Alwatr/nanolib/commit/392d0b71f446bce336b0256119a80f07aff794ba)) by @alimd
327
-
328
- ### Dependencies update
329
-
330
- - bump @types/node ([3d80fed](https://github.com/Alwatr/nanolib/commit/3d80fedaf720af792feb060c2f81c737ebb84e11)) by @dependabot[bot]
331
-
332
- ## [1.0.11](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.10...@alwatr/is-number@1.0.11) (2024-09-21)
333
-
334
- **Note:** Version bump only for package @alwatr/is-number
335
-
336
- ## [1.0.10](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.9...@alwatr/is-number@1.0.10) (2024-09-15)
337
-
338
- ### Dependencies update
339
-
340
- - bump the development-dependencies group across 1 directory with 10 updates ([9ed98ff](https://github.com/Alwatr/nanolib/commit/9ed98ffd0668d5a36e255c82edab3af53bffda8f)) by @dependabot[bot]
341
- - update ([c36ed50](https://github.com/Alwatr/nanolib/commit/c36ed50f68da2f5608ccd96119963a16cfacb4ce)) by @alimd
342
-
343
- ## [1.0.9](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.8...@alwatr/is-number@1.0.9) (2024-08-31)
344
-
345
- ### Miscellaneous Chores
346
-
347
- - Update package.json exports for [@alwatr](https://github.com/alwatr) packages ([dacb362](https://github.com/Alwatr/nanolib/commit/dacb362b145e3c51b4aba00ff643687a3fac11d2)) by @
348
-
349
- ## [1.0.8](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.7...@alwatr/is-number@1.0.8) (2024-08-31)
350
-
351
- ### Dependencies update
352
-
353
- - update all dependencies ([1e0c30e](https://github.com/Alwatr/nanolib/commit/1e0c30e6a3a8e19deb5185814e24ab6c08dca573)) by @alimd
354
-
355
- ## [1.0.7](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.6...@alwatr/is-number@1.0.7) (2024-07-04)
356
-
357
- ### Dependencies update
358
-
359
- - update all dependencies ([0e908b4](https://github.com/Alwatr/nanolib/commit/0e908b476a6b976ec2447f864c8cafcbb8a0f099)) by @
360
-
361
- ## [1.0.6](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.5...@alwatr/is-number@1.0.6) (2024-05-12)
362
-
363
- ### Dependencies update
364
-
365
- - upgrade ([6dbd300](https://github.com/Alwatr/nanolib/commit/6dbd300642c9bcc9e7d0b281e244bf1b06eb1c38)) by @alimd
366
-
367
- ## [1.0.5](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.4...@alwatr/is-number@1.0.5) (2024-04-25)
368
-
369
- **Note:** Version bump only for package @alwatr/is-number
370
-
371
- ## [1.0.4](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.3...@alwatr/is-number@1.0.4) (2024-03-28)
372
-
373
- **Note:** Version bump only for package @alwatr/is-number
374
-
375
- ## [1.0.3](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.2...@alwatr/is-number@1.0.3) (2024-01-31)
376
-
377
- ### Miscellaneous Chores
378
-
379
- - **deps:** update ([1a45030](https://github.com/Alwatr/nanolib/commit/1a450305440b710a300787d4ca24b1ed8c6a39d7)) by @alimd
380
-
381
- ## [1.0.2](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.1...@alwatr/is-number@1.0.2) (2024-01-24)
382
-
383
- **Note:** Version bump only for package @alwatr/is-number
384
-
385
- ## [1.0.1](https://github.com/Alwatr/nanolib/compare/@alwatr/is-number@1.0.0...@alwatr/is-number@1.0.1) (2024-01-20)
386
-
387
- **Note:** Version bump only for package @alwatr/is-number
388
-
389
- # 1.0.0 (2024-01-16)
390
-
391
- ### Bug Fixes
392
-
393
- - **is-number:** Remove Number.isFinite polyfill ([aa149f3](https://github.com/Alwatr/nanolib/commit/aa149f302f96d961b058fc3a9d70399c1023cbe3)) by @alimd
394
-
395
- ### Features
396
-
397
- - **is-number:** extract from @alwatr/util ([1c8a676](https://github.com/Alwatr/nanolib/commit/1c8a676ccefcad12436f41b96eeb39c60cc09040)) by @njfamirm
398
- - **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.27 */
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.27 */
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
- }