es-toolkit 1.4.0-dev.93 → 1.4.0-dev.95

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.
Files changed (53) hide show
  1. package/dist/array/differenceWith.js.map +1 -1
  2. package/dist/array/differenceWith.mjs +1 -1
  3. package/dist/array/dropRightWhile.js.map +1 -1
  4. package/dist/array/dropRightWhile.mjs +2 -2
  5. package/dist/array/dropWhile.js.map +1 -1
  6. package/dist/array/dropWhile.mjs +1 -1
  7. package/dist/array/index.js.map +1 -1
  8. package/dist/array/index.mjs +8 -8
  9. package/dist/array/intersectionWith.js.map +1 -1
  10. package/dist/array/intersectionWith.mjs +1 -1
  11. package/dist/array/unionWith.js.map +1 -1
  12. package/dist/array/unionWith.mjs +1 -1
  13. package/dist/array/xorWith.js.map +1 -1
  14. package/dist/array/xorWith.mjs +4 -4
  15. package/dist/array/zip.js.map +1 -1
  16. package/dist/array/zip.mjs +1 -1
  17. package/dist/array/zipWith.js.map +1 -1
  18. package/dist/array/zipWith.mjs +1 -1
  19. package/dist/{chunk-KLJRZJOR.mjs → chunk-2EFS3VA3.mjs} +1 -1
  20. package/dist/{chunk-KLJRZJOR.mjs.map → chunk-2EFS3VA3.mjs.map} +1 -1
  21. package/dist/{chunk-T5FDOBCA.mjs → chunk-4KYXHZ4R.mjs} +1 -1
  22. package/dist/{chunk-T5FDOBCA.mjs.map → chunk-4KYXHZ4R.mjs.map} +1 -1
  23. package/dist/{chunk-WWFZN6VL.mjs → chunk-5PMKOZ2F.mjs} +4 -1
  24. package/dist/chunk-5PMKOZ2F.mjs.map +1 -0
  25. package/dist/{chunk-3KHI4I2X.mjs → chunk-642SWVKJ.mjs} +1 -1
  26. package/dist/{chunk-3KHI4I2X.mjs.map → chunk-642SWVKJ.mjs.map} +1 -1
  27. package/dist/{chunk-FQ4K36VD.mjs → chunk-6NVQAHXP.mjs} +1 -1
  28. package/dist/{chunk-FQ4K36VD.mjs.map → chunk-6NVQAHXP.mjs.map} +1 -1
  29. package/dist/{chunk-DD73BULA.mjs → chunk-IDCUZVJL.mjs} +1 -1
  30. package/dist/{chunk-DD73BULA.mjs.map → chunk-IDCUZVJL.mjs.map} +1 -1
  31. package/dist/{chunk-JFHM6EY2.mjs → chunk-K2BAFL2T.mjs} +1 -1
  32. package/dist/{chunk-JFHM6EY2.mjs.map → chunk-K2BAFL2T.mjs.map} +1 -1
  33. package/dist/{chunk-CIRFWC7Y.mjs → chunk-RNJM5BHX.mjs} +2 -2
  34. package/dist/{chunk-VZUJ5PIA.mjs → chunk-SAL5OUAE.mjs} +1 -1
  35. package/dist/{chunk-VZUJ5PIA.mjs.map → chunk-SAL5OUAE.mjs.map} +1 -1
  36. package/dist/{chunk-FCF2RHPW.mjs → chunk-UMDNWTJC.mjs} +4 -4
  37. package/dist/{chunk-FCF2RHPW.mjs.map → chunk-UMDNWTJC.mjs.map} +1 -1
  38. package/dist/index.js +3 -0
  39. package/dist/index.js.map +1 -1
  40. package/dist/index.mjs +14 -14
  41. package/dist/math/index.js +3 -0
  42. package/dist/math/index.js.map +1 -1
  43. package/dist/math/index.mjs +2 -2
  44. package/dist/math/minBy.js.map +1 -1
  45. package/dist/math/minBy.mjs +1 -1
  46. package/dist/math/round.d.mts +2 -0
  47. package/dist/math/round.d.ts +2 -0
  48. package/dist/math/round.js +3 -0
  49. package/dist/math/round.js.map +1 -1
  50. package/dist/math/round.mjs +1 -1
  51. package/package.json +1 -1
  52. package/dist/chunk-WWFZN6VL.mjs.map +0 -1
  53. /package/dist/{chunk-CIRFWC7Y.mjs.map → chunk-RNJM5BHX.mjs.map} +0 -0
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  minBy
3
- } from "../chunk-VZUJ5PIA.mjs";
3
+ } from "../chunk-SAL5OUAE.mjs";
4
4
  import "../chunk-2MM5EJJX.mjs";
5
5
  export {
6
6
  minBy
@@ -7,11 +7,13 @@
7
7
  * @param {number} value - The number to round.
8
8
  * @param {number} [precision=0] - The number of decimal places to round to. Defaults to 0.
9
9
  * @returns {number} The rounded number.
10
+ * @throws {Error} Throws an error if `Precision` is not integer.
10
11
  *
11
12
  * @example
12
13
  * const result1 = round(1.2345); // result1 will be 1
13
14
  * const result2 = round(1.2345, 2); // result2 will be 1.23
14
15
  * const result3 = round(1.2345, 3); // result3 will be 1.235
16
+ * const result4 = round(1.2345, 3.1); // This will throw an error
15
17
  */
16
18
  declare function round(value: number, precision?: number): number;
17
19
 
@@ -7,11 +7,13 @@
7
7
  * @param {number} value - The number to round.
8
8
  * @param {number} [precision=0] - The number of decimal places to round to. Defaults to 0.
9
9
  * @returns {number} The rounded number.
10
+ * @throws {Error} Throws an error if `Precision` is not integer.
10
11
  *
11
12
  * @example
12
13
  * const result1 = round(1.2345); // result1 will be 1
13
14
  * const result2 = round(1.2345, 2); // result2 will be 1.23
14
15
  * const result3 = round(1.2345, 3); // result3 will be 1.235
16
+ * const result4 = round(1.2345, 3.1); // This will throw an error
15
17
  */
16
18
  declare function round(value: number, precision?: number): number;
17
19
 
@@ -24,6 +24,9 @@ __export(round_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(round_exports);
26
26
  function round(value, precision = 0) {
27
+ if (!Number.isInteger(precision)) {
28
+ throw new Error("Precision must be an integer.");
29
+ }
27
30
  const multiplier = Math.pow(10, precision);
28
31
  return Math.round(value * multiplier) / multiplier;
29
32
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/math/round.ts"],"sourcesContent":["/**\n * Rounds a number to a specified precision.\n *\n * This function takes a number and an optional precision value, and returns the number rounded\n * to the specified number of decimal places.\n *\n * @param {number} value - The number to round.\n * @param {number} [precision=0] - The number of decimal places to round to. Defaults to 0.\n * @returns {number} The rounded number.\n *\n * @example\n * const result1 = round(1.2345); // result1 will be 1\n * const result2 = round(1.2345, 2); // result2 will be 1.23\n * const result3 = round(1.2345, 3); // result3 will be 1.235\n */\nexport function round(value: number, precision = 0): number {\n const multiplier = Math.pow(10, precision);\n return Math.round(value * multiplier) / multiplier;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAeO,SAAS,MAAM,OAAe,YAAY,GAAW;AAC1D,QAAM,aAAa,KAAK,IAAI,IAAI,SAAS;AACzC,SAAO,KAAK,MAAM,QAAQ,UAAU,IAAI;AAC1C;","names":[]}
1
+ {"version":3,"sources":["../../src/math/round.ts"],"sourcesContent":["/**\n * Rounds a number to a specified precision.\n *\n * This function takes a number and an optional precision value, and returns the number rounded\n * to the specified number of decimal places.\n *\n * @param {number} value - The number to round.\n * @param {number} [precision=0] - The number of decimal places to round to. Defaults to 0.\n * @returns {number} The rounded number.\n * @throws {Error} Throws an error if `Precision` is not integer.\n *\n * @example\n * const result1 = round(1.2345); // result1 will be 1\n * const result2 = round(1.2345, 2); // result2 will be 1.23\n * const result3 = round(1.2345, 3); // result3 will be 1.235\n * const result4 = round(1.2345, 3.1); // This will throw an error\n */\nexport function round(value: number, precision = 0): number {\n if (!Number.isInteger(precision)) {\n throw new Error('Precision must be an integer.');\n }\n const multiplier = Math.pow(10, precision);\n return Math.round(value * multiplier) / multiplier;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBO,SAAS,MAAM,OAAe,YAAY,GAAW;AAC1D,MAAI,CAAC,OAAO,UAAU,SAAS,GAAG;AAChC,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AACA,QAAM,aAAa,KAAK,IAAI,IAAI,SAAS;AACzC,SAAO,KAAK,MAAM,QAAQ,UAAU,IAAI;AAC1C;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  round
3
- } from "../chunk-WWFZN6VL.mjs";
3
+ } from "../chunk-5PMKOZ2F.mjs";
4
4
  import "../chunk-2MM5EJJX.mjs";
5
5
  export {
6
6
  round
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.4.0-dev.93+3cc1a035",
4
+ "version": "1.4.0-dev.95+92c9db00",
5
5
  "workspaces": [
6
6
  "docs"
7
7
  ],
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/math/round.ts"],"sourcesContent":["/**\n * Rounds a number to a specified precision.\n *\n * This function takes a number and an optional precision value, and returns the number rounded\n * to the specified number of decimal places.\n *\n * @param {number} value - The number to round.\n * @param {number} [precision=0] - The number of decimal places to round to. Defaults to 0.\n * @returns {number} The rounded number.\n *\n * @example\n * const result1 = round(1.2345); // result1 will be 1\n * const result2 = round(1.2345, 2); // result2 will be 1.23\n * const result3 = round(1.2345, 3); // result3 will be 1.235\n */\nexport function round(value: number, precision = 0): number {\n const multiplier = Math.pow(10, precision);\n return Math.round(value * multiplier) / multiplier;\n}\n"],"mappings":";AAeO,SAAS,MAAM,OAAe,YAAY,GAAW;AAC1D,QAAM,aAAa,KAAK,IAAI,IAAI,SAAS;AACzC,SAAO,KAAK,MAAM,QAAQ,UAAU,IAAI;AAC1C;","names":[]}