es-toolkit 1.31.0-dev.992 → 1.31.0-dev.994

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.
@@ -144,6 +144,7 @@ export { floor } from './math/floor.mjs';
144
144
  export { inRange } from './math/inRange.mjs';
145
145
  export { max } from './math/max.mjs';
146
146
  export { min } from './math/min.mjs';
147
+ export { multiply } from './math/multiply.mjs';
147
148
  export { parseInt } from './math/parseInt.mjs';
148
149
  export { random } from './math/random.mjs';
149
150
  export { range } from './math/range.mjs';
@@ -144,6 +144,7 @@ export { floor } from './math/floor.js';
144
144
  export { inRange } from './math/inRange.js';
145
145
  export { max } from './math/max.js';
146
146
  export { min } from './math/min.js';
147
+ export { multiply } from './math/multiply.js';
147
148
  export { parseInt } from './math/parseInt.js';
148
149
  export { random } from './math/random.js';
149
150
  export { range } from './math/range.js';
@@ -1859,6 +1859,38 @@ function min(items = []) {
1859
1859
  return minElement;
1860
1860
  }
1861
1861
 
1862
+ function toString(value) {
1863
+ if (value == null) {
1864
+ return '';
1865
+ }
1866
+ if (Array.isArray(value)) {
1867
+ return value.map(toString).join(',');
1868
+ }
1869
+ const result = String(value);
1870
+ if (result === '0' && Object.is(Number(value), -0)) {
1871
+ return '-0';
1872
+ }
1873
+ return result;
1874
+ }
1875
+
1876
+ function multiply(value, other) {
1877
+ if (value === undefined && other === undefined) {
1878
+ return 1;
1879
+ }
1880
+ if (value === undefined || other === undefined) {
1881
+ return value || other;
1882
+ }
1883
+ if (typeof value === 'string' || typeof other === 'string') {
1884
+ value = toString(value);
1885
+ other = toString(other);
1886
+ }
1887
+ else {
1888
+ value = Number(value);
1889
+ other = Number(other);
1890
+ }
1891
+ return value * other;
1892
+ }
1893
+
1862
1894
  function parseInt(string, radix = 0, guard) {
1863
1895
  if (guard) {
1864
1896
  radix = 0;
@@ -2606,20 +2638,6 @@ function isWeakSet(value) {
2606
2638
  return isWeakSet$1.isWeakSet(value);
2607
2639
  }
2608
2640
 
2609
- function toString(value) {
2610
- if (value == null) {
2611
- return '';
2612
- }
2613
- if (Array.isArray(value)) {
2614
- return value.map(toString).join(',');
2615
- }
2616
- const result = String(value);
2617
- if (result === '0' && Object.is(Number(value), -0)) {
2618
- return '-0';
2619
- }
2620
- return result;
2621
- }
2622
-
2623
2641
  function normalizeForCase(str) {
2624
2642
  if (typeof str !== 'string') {
2625
2643
  str = toString(str);
@@ -3246,6 +3264,7 @@ exports.mergeWith = mergeWith;
3246
3264
  exports.method = method;
3247
3265
  exports.methodOf = methodOf;
3248
3266
  exports.min = min;
3267
+ exports.multiply = multiply;
3249
3268
  exports.negate = negate;
3250
3269
  exports.now = now;
3251
3270
  exports.nth = nth;
@@ -146,6 +146,7 @@ export { floor } from './math/floor.mjs';
146
146
  export { inRange } from './math/inRange.mjs';
147
147
  export { max } from './math/max.mjs';
148
148
  export { min } from './math/min.mjs';
149
+ export { multiply } from './math/multiply.mjs';
149
150
  export { parseInt } from './math/parseInt.mjs';
150
151
  export { random } from './math/random.mjs';
151
152
  export { range } from './math/range.mjs';
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Multiply two numbers.
3
+ *
4
+ * If either of the numbers is `NaN`, the function returns `NaN`.
5
+ *
6
+ * @param {number} value The first number in a multiplication
7
+ * @param {number} other The second number in a multiplication
8
+ * @returns {number} The product of value and other
9
+ *
10
+ * @example
11
+ * multiply(2, 3); // => 6
12
+ * multiply(2, NaN); // => NaN
13
+ * multiply(NaN, 3); // => NaN
14
+ * multiply(NaN, NaN); // => NaN
15
+ */
16
+ declare function multiply(value: number, other: number): number;
17
+
18
+ export { multiply };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Multiply two numbers.
3
+ *
4
+ * If either of the numbers is `NaN`, the function returns `NaN`.
5
+ *
6
+ * @param {number} value The first number in a multiplication
7
+ * @param {number} other The second number in a multiplication
8
+ * @returns {number} The product of value and other
9
+ *
10
+ * @example
11
+ * multiply(2, 3); // => 6
12
+ * multiply(2, NaN); // => NaN
13
+ * multiply(NaN, 3); // => NaN
14
+ * multiply(NaN, NaN); // => NaN
15
+ */
16
+ declare function multiply(value: number, other: number): number;
17
+
18
+ export { multiply };
@@ -0,0 +1,21 @@
1
+ import { toString } from '../util/toString.mjs';
2
+
3
+ function multiply(value, other) {
4
+ if (value === undefined && other === undefined) {
5
+ return 1;
6
+ }
7
+ if (value === undefined || other === undefined) {
8
+ return value || other;
9
+ }
10
+ if (typeof value === 'string' || typeof other === 'string') {
11
+ value = toString(value);
12
+ other = toString(other);
13
+ }
14
+ else {
15
+ value = Number(value);
16
+ other = Number(other);
17
+ }
18
+ return value * other;
19
+ }
20
+
21
+ export { multiply };
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.31.0-dev.992+030e4ead",
4
+ "version": "1.31.0-dev.994+14843eed",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {