es-toolkit 1.17.0-dev.560 → 1.17.0-dev.562

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.
@@ -159,5 +159,6 @@ export { endsWith } from './string/endsWith.mjs';
159
159
  export { padStart } from './string/padStart.mjs';
160
160
  export { padEnd } from './string/padEnd.mjs';
161
161
  export { repeat } from './string/repeat.mjs';
162
+ export { parseInt } from './string/parseInt.mjs';
162
163
  export { max } from './math/max.mjs';
163
164
  export { min } from './math/min.mjs';
@@ -159,5 +159,6 @@ export { endsWith } from './string/endsWith.js';
159
159
  export { padStart } from './string/padStart.js';
160
160
  export { padEnd } from './string/padEnd.js';
161
161
  export { repeat } from './string/repeat.js';
162
+ export { parseInt } from './string/parseInt.js';
162
163
  export { max } from './math/max.js';
163
164
  export { min } from './math/min.js';
@@ -987,6 +987,13 @@ function repeat(str, n) {
987
987
  return str.repeat(n);
988
988
  }
989
989
 
990
+ function parseInt(string, radix = 0, guard) {
991
+ if (guard) {
992
+ radix = 0;
993
+ }
994
+ return Number.parseInt(string, radix);
995
+ }
996
+
990
997
  function max(items = []) {
991
998
  let maxElement = items[0];
992
999
  let max = undefined;
@@ -1164,6 +1171,7 @@ exports.min = min;
1164
1171
  exports.orderBy = orderBy;
1165
1172
  exports.padEnd = padEnd;
1166
1173
  exports.padStart = padStart;
1174
+ exports.parseInt = parseInt;
1167
1175
  exports.property = property;
1168
1176
  exports.rearg = rearg;
1169
1177
  exports.repeat = repeat;
@@ -159,5 +159,6 @@ export { endsWith } from './string/endsWith.mjs';
159
159
  export { padStart } from './string/padStart.mjs';
160
160
  export { padEnd } from './string/padEnd.mjs';
161
161
  export { repeat } from './string/repeat.mjs';
162
+ export { parseInt } from './string/parseInt.mjs';
162
163
  export { max } from './math/max.mjs';
163
164
  export { min } from './math/min.mjs';
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Converts `string` to an integer of the specified radix. If `radix` is undefined or 0, a `radix` of 10 is used unless `string` is a hexadecimal, in which case a `radix` of 16 is used.
3
+ *
4
+ * @param {string} string The string to convert to an integer.
5
+ * @param {number} radix The radix to use when converting the string to an integer. Defaults to `0`.
6
+ * @param {unknown} guard Enables use as an iteratee for methods like `Array#map`.
7
+ * @returns {number} Returns the converted integer.
8
+ *
9
+ * @example
10
+ * parseInt('08'); // => 8
11
+ * parseInt('0x20'); // => 32
12
+ *
13
+ * parseInt('08', 10); // => 8
14
+ * parseInt('0x20', 16); // => 32
15
+ *
16
+ * ['6', '08', '10'].map(parseInt); // => [6, 8, 10]
17
+ */
18
+ declare function parseInt(string: string, radix?: number, guard?: unknown): number;
19
+
20
+ export { parseInt };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Converts `string` to an integer of the specified radix. If `radix` is undefined or 0, a `radix` of 10 is used unless `string` is a hexadecimal, in which case a `radix` of 16 is used.
3
+ *
4
+ * @param {string} string The string to convert to an integer.
5
+ * @param {number} radix The radix to use when converting the string to an integer. Defaults to `0`.
6
+ * @param {unknown} guard Enables use as an iteratee for methods like `Array#map`.
7
+ * @returns {number} Returns the converted integer.
8
+ *
9
+ * @example
10
+ * parseInt('08'); // => 8
11
+ * parseInt('0x20'); // => 32
12
+ *
13
+ * parseInt('08', 10); // => 8
14
+ * parseInt('0x20', 16); // => 32
15
+ *
16
+ * ['6', '08', '10'].map(parseInt); // => [6, 8, 10]
17
+ */
18
+ declare function parseInt(string: string, radix?: number, guard?: unknown): number;
19
+
20
+ export { parseInt };
@@ -0,0 +1,8 @@
1
+ function parseInt(string, radix = 0, guard) {
2
+ if (guard) {
3
+ radix = 0;
4
+ }
5
+ return Number.parseInt(string, radix);
6
+ }
7
+
8
+ export { parseInt };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "es-toolkit",
3
3
  "description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
4
- "version": "1.17.0-dev.560+9c721833",
4
+ "version": "1.17.0-dev.562+33bdce12",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {