@hairy/utils 0.7.0 → 0.7.2

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/index.cjs CHANGED
@@ -74,7 +74,8 @@ __export(src_exports, {
74
74
  unum: () => unum,
75
75
  weexPlatform: () => weexPlatform,
76
76
  whenever: () => whenever,
77
- zerofill: () => zerofill
77
+ zerofill: () => zerofill,
78
+ zeromove: () => zeromove
78
79
  });
79
80
  module.exports = __toCommonJS(src_exports);
80
81
 
@@ -1731,6 +1732,9 @@ function zerofill(value, n = 2, type = "positive") {
1731
1732
  return zero + value;
1732
1733
  return "";
1733
1734
  }
1735
+ function zeromove(value) {
1736
+ return value.toString().replace(/\.?0+$/, "");
1737
+ }
1734
1738
  function numerfix(value) {
1735
1739
  const _isNaN = Number.isNaN(Number(value)) || value.toString() === "NaN";
1736
1740
  if (_isNaN)
@@ -1772,7 +1776,16 @@ function formatNumeric(value = "0", options) {
1772
1776
  decimals = 2
1773
1777
  } = options || {};
1774
1778
  const config = parseNumeric(value, delimiters || []);
1775
- const number = unum(value).div(config.v).toFormat(decimals, rounding, format);
1779
+ let number = unum(value).div(config.v).toFormat(decimals, rounding, {
1780
+ decimalSeparator: ".",
1781
+ groupSeparator: ",",
1782
+ groupSize: 3,
1783
+ secondaryGroupSize: 0,
1784
+ fractionGroupSeparator: " ",
1785
+ fractionGroupSize: 0,
1786
+ ...format
1787
+ });
1788
+ number = (options == null ? void 0 : options.zeromove) ? zeromove(number) : number;
1776
1789
  return `${number}${config.n}`;
1777
1790
  }
1778
1791
 
@@ -1836,5 +1849,6 @@ function cover(value, mode, symbol = "*") {
1836
1849
  unum,
1837
1850
  weexPlatform,
1838
1851
  whenever,
1839
- zerofill
1852
+ zerofill,
1853
+ zeromove
1840
1854
  });
package/dist/index.d.ts CHANGED
@@ -162,6 +162,7 @@ interface FormatNumericOptions {
162
162
  delimiters?: Delimiter[] | false;
163
163
  rounding?: Bignumber.RoundingMode;
164
164
  decimals?: number;
165
+ zeromove?: boolean;
165
166
  format?: Bignumber.Format;
166
167
  }
167
168
  declare function unum(num?: Numeric): Bignumber;
@@ -183,6 +184,7 @@ declare function percentage(total: Numeric, count: Numeric, options?: DecimalOpt
183
184
  * @param lh
184
185
  */
185
186
  declare function zerofill(value: Numberish, n?: number, type?: 'positive' | 'reverse'): Numberish;
187
+ declare function zeromove(value: Numberish): string;
186
188
  declare function numerfix(value: any): string;
187
189
  /**
188
190
  * format as a positive integer
@@ -216,4 +218,4 @@ declare function formatNumeric(value?: Numeric, options?: FormatNumericOptions):
216
218
  */
217
219
  declare function cover(value: string, mode: [number, number, number], symbol?: string): string;
218
220
 
219
- export { Arrayable, Awaitable, BIG_INTS, BooleanLike, DecimalOptions, DeepKeyof, DeepPartial, DeepReadonly, DeepReplace, DeepRequired, Deferred, Delimiter, Dimension, DynamicObject, FormatGroupOptions, FormatNumericOptions, Key, NumberObject, Numberish, Numeric, NumericObject, Option, StringObject, SymbolObject, TypeofType, UA, arange, average, compose, cover, decimal, delay, formDataToObject, formatNumeric, formatSize, formatUnit, getTypeof, gt, gte, integer, isAndroid, isArray, isBrowser, isChrome, isEdge, isFF, isFormData, isIE, isIE11, isIE9, isIOS, isMobile, isNull, isNumber, isObject, isPhantomJS, isPlainObject, isString, isTypeof, isWeex, isWindow, loop, lt, lte, noop, numerfix, objectToFormData, pPipe, parseNumeric, percentage, pipe, plus, riposte, unum, weexPlatform, whenever, zerofill };
221
+ export { Arrayable, Awaitable, BIG_INTS, BooleanLike, DecimalOptions, DeepKeyof, DeepPartial, DeepReadonly, DeepReplace, DeepRequired, Deferred, Delimiter, Dimension, DynamicObject, FormatGroupOptions, FormatNumericOptions, Key, NumberObject, Numberish, Numeric, NumericObject, Option, StringObject, SymbolObject, TypeofType, UA, arange, average, compose, cover, decimal, delay, formDataToObject, formatNumeric, formatSize, formatUnit, getTypeof, gt, gte, integer, isAndroid, isArray, isBrowser, isChrome, isEdge, isFF, isFormData, isIE, isIE11, isIE9, isIOS, isMobile, isNull, isNumber, isObject, isPhantomJS, isPlainObject, isString, isTypeof, isWeex, isWindow, loop, lt, lte, noop, numerfix, objectToFormData, pPipe, parseNumeric, percentage, pipe, plus, riposte, unum, weexPlatform, whenever, zerofill, zeromove };
package/dist/index.mjs CHANGED
@@ -1651,6 +1651,9 @@ function zerofill(value, n = 2, type = "positive") {
1651
1651
  return zero + value;
1652
1652
  return "";
1653
1653
  }
1654
+ function zeromove(value) {
1655
+ return value.toString().replace(/\.?0+$/, "");
1656
+ }
1654
1657
  function numerfix(value) {
1655
1658
  const _isNaN = Number.isNaN(Number(value)) || value.toString() === "NaN";
1656
1659
  if (_isNaN)
@@ -1692,7 +1695,16 @@ function formatNumeric(value = "0", options) {
1692
1695
  decimals = 2
1693
1696
  } = options || {};
1694
1697
  const config = parseNumeric(value, delimiters || []);
1695
- const number = unum(value).div(config.v).toFormat(decimals, rounding, format);
1698
+ let number = unum(value).div(config.v).toFormat(decimals, rounding, {
1699
+ decimalSeparator: ".",
1700
+ groupSeparator: ",",
1701
+ groupSize: 3,
1702
+ secondaryGroupSize: 0,
1703
+ fractionGroupSeparator: " ",
1704
+ fractionGroupSize: 0,
1705
+ ...format
1706
+ });
1707
+ number = (options == null ? void 0 : options.zeromove) ? zeromove(number) : number;
1696
1708
  return `${number}${config.n}`;
1697
1709
  }
1698
1710
 
@@ -1755,5 +1767,6 @@ export {
1755
1767
  unum,
1756
1768
  weexPlatform,
1757
1769
  whenever,
1758
- zerofill
1770
+ zerofill,
1771
+ zeromove
1759
1772
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hairy/utils",
3
- "version": "0.7.0",
3
+ "version": "0.7.2",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.cjs",
6
6
  "publishConfig": {