@peter-present/format-number 0.0.1 → 0.0.12

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/README.md CHANGED
@@ -1,115 +1,125 @@
1
1
  # format-number
2
2
 
3
- A lightweight, high-precision JavaScript/TypeScript library for rounding and formatting numbers. It handles everything from large financial figures and crypto balances to extremely small fractions with scientific subscripts.
3
+ A lightweight, zero-dependency JavaScript/TypeScript library for precise number formatting. Designed for financial applications, crypto dashboards, and scientific data where precision is paramount.
4
4
 
5
- Designed for precision-critical applications where numbers often exceed safe integer limits.
5
+ Unlike standard libraries that rely on floating-point math, **format-number** uses internal string-based arithmetic to handle numbers of any size (including `string`, `number`, and `bigint`) without losing a single decimal point.
6
6
 
7
- For detailed documentation and advanced usage, visit: [here](https://blog.peter-present.xyz/format-number)
7
+ For detailed documentation, visit: [here](https://blog.peter-present.xyz/format-number)
8
8
 
9
9
  ## Key Features
10
10
 
11
- - **High Precision**: Native support for `string`, `number`, and `bigint` without loss of precision.
12
- - **Multiple Rounding Modes**: 5 different strategies to handle rounding exactly how you need.
13
- - **Compact Formatting**: Automatically shorten large numbers with suffixes (K, M, B, T, Q).
14
- - **Small Number Notation**: Smart formatting for tiny numbers using subscript zeros (e.g., `0.0₃5`).
15
- - **Flexible Metadata**: Easily add prefixes and suffixes (e.g., Currency symbols, Units).
16
- - **Fluent API**: Chained operations for cleaner, more readable code.
17
- - **Zero Dependencies**: Keeps your bundle size minimal.
11
+ - **Zero Precision Loss**: Uses string manipulation for rounding and formatting to avoid binary floating-point errors.
12
+ - **Robust Input Parsing**: Centralized parsing handles messy strings with currency symbols ($€£¥), commas, underscores, and scientific notation.
13
+ - **Advanced Rounding**: 5 strategies (`half`, `up`, `down`, `banker`, `truncate`) with customizable decimal precision.
14
+ - **Intelligent Notation**: Format small numbers with subscript zeros (e.g., `0.0₃5`) or standard scientific notation.
15
+ - **Flexible Compacting**: Shorten massive numbers into readable strings like `1.5T` or `20.4B`.
16
+ - **Fluent Chainable API**: Build complex formatting logic with a clean, readable syntax.
17
+
18
+ ## Robust Parsing & Error Handling
19
+
20
+ The library follows a **Single-Gate Parsing** philosophy. High-level entry points (`FN`, `formatNumber`, and `parseNum`) are designed to be robust and will attempt to clean and normalize nearly any "number-like" string.
21
+
22
+ > [!IMPORTANT]
23
+ > **Internal functions** (like `round`, `compact`, `scientific`, etc.) are optimized for performance and **assume valid numeric strings**. Passing completely invalid non-numeric data (e.g., `"abc"`) directly to these utilities may result in fallback values or undefined behavior.
24
+
25
+ For manual parsing with custom error handling, use `parseNum`:
26
+
27
+ ```typescript
28
+ import { parseNum } from '@peter-present/format-number';
29
+
30
+ // Default fallback is '--'
31
+ parseNum('invalid'); // '--'
32
+
33
+ // Custom fallback for your own error boundaries
34
+ parseNum('not-a-number', { fallback: 'NaN' }); // 'NaN'
35
+ parseNum('null', { fallback: '0' }); // '0'
36
+ ```
18
37
 
19
38
  ## Installation
20
39
 
21
40
  ```shell
22
41
  # npm
23
- npm install format-number
42
+ npm install @peter-present/format-number
24
43
 
25
44
  # yarn
26
- yarn add format-number
45
+ yarn add @peter-present/format-number
27
46
 
28
47
  # bun
29
- bun install format-number
48
+ bun install @peter-present/format-number
30
49
  ```
31
50
 
32
- ## Core Functions
51
+ ## Core API
33
52
 
34
- ### Rounding: `round()`
53
+ ### `formatNumber(value, options)`
35
54
 
36
- Round numbers using specific strategies and precision.
55
+ The primary entry point for one-off formatting. It combines parsing, rounding, and visualization.
37
56
 
38
57
  ```typescript
39
- import { round } from 'format-number';
40
-
41
- round(123.456, { precision: 2 }); // '123.46'
42
- round(-123.45, { mode: 'up', precision: 1 }); // '-123.4' (Towards +Infinity)
43
- ```
58
+ import { formatNumber } from '@peter-present/format-number';
44
59
 
45
- ### Compact Formatting: `compact()`
60
+ // Currency & Rounding
61
+ formatNumber('$1,234.567', { prefix: '€', precision: 2 }); // '€1234.57'
46
62
 
47
- Format large numbers with readable suffixes.
63
+ // Compact Notation
64
+ formatNumber(1500000000, { isCompact: true }); // '1.5B'
48
65
 
49
- ```typescript
50
- import { compact } from 'format-number';
51
-
52
- compact(1500); // '1.5K'
53
- compact(1200000, { precision: 1 }); // '1.2M'
54
- compact('1000000000000'); // '1T'
66
+ // Special Notations
67
+ formatNumber(0.00005, { notation: 'subscript' }); // '0.0₄5'
68
+ formatNumber(12345, { notation: 'scientific' }); // '1.2345e+4'
55
69
  ```
56
70
 
57
- ### Advanced Formatting: `formatNumber()`
71
+ ### `FN(value)` - Fluent API
58
72
 
59
- A comprehensive function combining rounding, compacting, and metadata.
73
+ Best for complex, multi-step formatting requirements where readability is key.
60
74
 
61
75
  ```typescript
62
- import { formatNumber } from 'format-number';
76
+ import { FN } from '@peter-present/format-number';
63
77
 
64
- // Currency formatting
65
- formatNumber(1234.56, { prefix: '$', precision: 1 }); // '$1234.6'
78
+ const formatted = FN('1234567.89')
79
+ .round({ precision: 0, rounding: 'banker' })
80
+ .prefix('Balance: ')
81
+ .suffix(' USD')
82
+ .toNumber();
66
83
 
67
- // Compact with metadata
68
- formatNumber(1500000, { isCompact: true, suffix: ' units' }); // '1.5M units'
84
+ console.log(formatted); // 'Balance: 1234568 USD'
69
85
 
70
- // Small number subscript notation
71
- formatNumber(0.00005, { isSmall: true }); // '0.0₄5'
86
+ // Seamlessly combine with compact and notation
87
+ FN(1500).compact({ precision: 1 }).prefix('$').toNumber(); // '$1.5K'
72
88
  ```
73
89
 
74
- ### Fluent / Chained API: `FN()`
90
+ ### `round(value, options)`
75
91
 
76
- Perform multiple operations in a readable chain.
92
+ Independent rounding utility with high-precision string logic.
77
93
 
78
94
  ```typescript
79
- import { FN } from 'format-number';
80
-
81
- const result = FN('1234567.89')
82
- .round({ precision: 0 })
83
- .format({ prefix: 'Total: ', suffix: ' tokens' });
84
-
85
- console.log(result); // 'Total: 1234568 tokens'
95
+ import { round } from '@peter-present/format-number';
86
96
 
87
- // Compact chaining
88
- FN(1000000).compact({ precision: 0 }); // '1M'
97
+ round(1.235, { precision: 2, rounding: 'half' }); // '1.24'
98
+ round(1.235, { precision: 2, rounding: 'down' }); // '1.23'
89
99
  ```
90
100
 
91
- ## API Reference
101
+ ## Configuration Reference
92
102
 
93
- ### Rounding Modes (`RoundingMode`)
103
+ ### `RoundingMode`
94
104
 
95
- | Mode | Description |
96
- | :--------- | :------------------------------------------------------------------- |
97
- | `half` | Round to the nearest neighbor. If equidistant, round away from zero. |
98
- | `up` | Round towards Positive Infinity. |
99
- | `down` | Round towards Negative Infinity. |
100
- | `truncate` | Round towards Zero. |
101
- | `banker` | Round to the nearest even neighbor (Statistical rounding). |
105
+ | Mode | Description |
106
+ | :--------- | :--------------------------------------------------------------------- |
107
+ | `half` | Rounds to the nearest neighbor (rounds away from zero if equidistant). |
108
+ | `up` | Rounds towards Positive Infinity. |
109
+ | `down` | Rounds towards Negative Infinity. |
110
+ | `truncate` | Rounds towards Zero (trims decimals). |
111
+ | `banker` | Rounds to the nearest even neighbor (minimizes statistical bias). |
102
112
 
103
- ### Configuration Options
113
+ ### `FormattingConfigType`
104
114
 
105
- | Option | Type | Description |
106
- | :---------- | :------------- | :----------------------------------------------- |
107
- | `precision` | `number` | Number of decimal places (default: `0`). |
108
- | `mode` | `RoundingMode` | Rounding strategy (default: `'half'`). |
109
- | `prefix` | `string` | Text to prepend to the result. |
110
- | `suffix` | `string` | Text to append to the result. |
111
- | `isCompact` | `boolean` | If `true`, uses K/M/B/T suffixes. |
112
- | `isSmall` | `boolean` | If `true`, formats tiny numbers with subscripts. |
115
+ | Property | Type | Default | Description |
116
+ | :---------- | :---------------------------- | :---------- | :------------------------------------------------- |
117
+ | `precision` | `number` | `0` | Number of decimal places to maintain. |
118
+ | `rounding` | `RoundingMode` | `'half'` | Strategy used for rounding. |
119
+ | `prefix` | `string` | `""` | Text prepended to the result. |
120
+ | `suffix` | `string` | `""` | Text appended to the result. |
121
+ | `isCompact` | `boolean` | `false` | Whether to use K/M/B/T suffixes for large numbers. |
122
+ | `notation` | `'subscript' \| 'scientific'` | `undefined` | Special formatting for extreme values. |
113
123
 
114
124
  ## License
115
125
 
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function f(s){const r=s.startsWith("-")?"-":"",t=r?s.slice(1):s;let e=0,n=t.length-1;for(;t[e]=="0"&&e<t.length;)e++;if(s.indexOf(".")>=0)for(;t[n]=="0"&&n>=0;)n--;const u=t.slice(e,n+1);return u==""||u=="."?"0":r+u}function g(s){let r=f(s);r=(r.startsWith("-")?"-":"")?r.slice(1):r;const[e,n=""]=r.split("."),i=n.match(/^0+/)?.[0]?.length||0,u=i.toString().split("").map(o=>String.fromCharCode(8320+parseInt(o))).join(""),c=n.slice(i);return`${e}.0${u}${c}`}function l(s){let r="",t=s.length-1,e="1";for(;t>=0;){const n=s[t];let i=Number(n)+(e?1:0);i>=10?(e="1",i-=10):e="",r=i.toString()+r,t--}return{result:e+r,remaining:e}}function S(s,r=0){const[t,e=""]=s.split(".");if(r===0)return e&&Number(e[0])>=5?l(t).result:t;if(r>=e.length)return t+(e?`.${e}`:"");const n=e.slice(0,r),i=e.slice(r);if(Number(i[0])>=5){const u=l(n);return u.remaining?l(t).result:t+"."+u.result}else return t+"."+n}function d(s,r=0){const[t,e=""]=s.split(".");if(r===0)return e?l(t).result:t;if(r>=e.length)return t+"."+e;const n=l(e.slice(0,r));return n.remaining?l(t).result:t+"."+n.result}function m(s,r=0){const[t,e=""]=s.split(".");if(r===0)return t;let n=e.slice(0,r),i=n.length-1;for(;i>=0&&n[i]=="0";)i--;return n=n.slice(0,i+1),t+(n?`.${n}`:"")}function $(s,r=0){const[t,e=""]=s.split(".");if(r===0)return e&&Number(e[0])>=5?Number(t[0])/2==0?t:l(t).result:t;if(r>=e.length)return t+(e?`.${e}`:"");const n=e.slice(0,r),i=e.slice(r);if(i[0]=="5"){if(Number(n[n.length-1])%2==0)return t+"."+n;{const u=l(n);return u.remaining?l(t).result:t+"."+u.result}}else if(Number(i[0])>5){const u=l(n);return u.remaining?l(t).result:t+"."+u.result}else return t+"."+n}function a(s,r={}){const t=r.mode||"half",e=r.precision||0;let n=f(String(s)),i="";switch(n.startsWith("-")&&(n=n.slice(1),i="-"),t){case"half":return i+S(n,e);case"up":return i==""?d(n,e):"-"+m(n,e);case"down":return i==""?m(n,e):"-"+d(n,e);case"truncate":return i+m(n,e);case"banker":return i+$(n,e)}}const b=["K","M","B","T","Q"];function P(s,r={}){let t=f(String(s)),e="";t.startsWith("-")&&(t=t.slice(1),e="-");let[n,i=""]=t.split("."),u=n.length,c=-1;for(;u>3&&c<4;){const o=n.slice(0,u-3);i=n.slice(u-3)+i,n=o,u-=3,c++}return a(`${e}${n}.${i}`,r)+(c>=0?b[c]:"")}function N(s,r){let t=String(s);r.isCompact==!0?t=P(t,r):r.isSmall||(t=a(t,r));const e=r.prefix||"",n=r.suffix||"",i=r.isSmall||!1;return`${e}${i?g(t):t}${n}`}function h(s){return{round(r={}){return h(a(s,r))},compact(r={}){return P(s,r)},format(r={}){const t=r.prefix||"",e=r.suffix||"",n=r.isSmall||!1;return`${t}${n?g(String(s)):s}${e}`},toString(){return String(s)}}}exports.FN=h;exports.compact=P;exports.formatNumber=N;exports.formatSmallNum=g;exports.removeZero=f;exports.round=a;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Z=t=>t.replace(/0+$/,""),B=t=>t.replace(/^0+(?!$)/,"");function p(t){return t.replace(/^(-?)0+(?=\d)/,"$1").replace(/(\.\d*?)0+$/,"$1").replace(/\.$/,"")}function z(t,r={}){const{fallback:n="--"}=r;if(typeof t=="number"||typeof t=="bigint")return t.toString();const e=String(t??"").trim();if(!e)return"0";const c=e.match(/^[\s+-]*/),i=(c&&c[0].match(/-/g)||[]).length%2===1,o=e.replace(/[$€£¥,_\s]/g,""),s=o.match(/^([+-]?\d+)\.0([\u2080-\u2089]+)([0-9]*)$/i);if(s){const[,l,K,Q]=s,V=K.split("").reduce((H,L)=>H+(L.charCodeAt(0)-8320),0),E=p(l.replace(/^[+-]/,"")+"."+"0".repeat(V)+Q);return(i?"-":"")+(E||"0")}const a=o.match(/[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?[KMBTQ]*/i);if(!a)return n;let f=a[0].toUpperCase(),b=0;const U=f.slice(-1),S="KMBTQ".indexOf(U);S!==-1&&(b=(S+1)*3,f=f.slice(0,-1));const h=f.match(/[E]([+-]?\d+)$/);if(h&&(b+=parseInt(h[1],10),f=f.slice(0,h.index)),f=f.replace(/^[+-]/,""),!/^(?:\d+\.?\d*|\.\d+)$/.test(f))return"0";const[D="0",F=""]=f.split("."),d=(D.replace(/^0+/,"")||"0")+F,x=F.length-b;let P;if(x<=0)P=(d+"0".repeat(-x)).replace(/^0+(?=\d)/,"")||"0";else{const l=d.length-x;P=l<=0?"0."+"0".repeat(-l)+d:d.slice(0,l)+"."+d.slice(l),P=p(P)}return(i?"-":"")+(P||"0")}function m(t){let r=String(t).trim();const n=r.startsWith("-")?"-":"";n&&(r=r.slice(1));const[e,c=""]=p(r).split(".");return{sign:n,intPart:e,fracPart:c}}const I=t=>t.fracPart?`${t.sign}${t.intPart}.${t.fracPart}`:`${t.sign}${t.intPart}`;function A(t){return typeof t=="object"&&t!==null&&"intPart"in t?t:m(t)}function $(t){if(!t)return{result:"",carry:!0};const n=(BigInt(t)+1n).toString();return n.length>t.length?{result:n.slice(1),carry:!0}:{result:n.padStart(t.length,"0"),carry:!1}}function g({intPart:t}){const{result:r,carry:n}=$(t);return{intPart:n?"1"+r:r,fracPart:""}}function k(t,r=0){const{intPart:n,fracPart:e}=t;if(!e||r>=e.length)return t;if(parseInt(e[r],10)>=5){if(r===0)return g(t);const i=e.slice(0,r),{result:o,carry:s}=$(i);return s?g(t):{intPart:n,fracPart:o}}return{intPart:n,fracPart:e.slice(0,r)}}function M(t,r=0){const{intPart:n,fracPart:e}=t;if(!e||r>=e.length)return t;if(r===0)return g(t);const c=e.slice(0,r),{result:i,carry:o}=$(c);return o?g(t):{intPart:n,fracPart:i}}function y(t,r=0){const{intPart:n,fracPart:e}=t;if(!e||r>=e.length)return t;const c=e.slice(0,r);return{intPart:n,fracPart:c.replace(/0+$/,"")}}function W(t,r=0){const{intPart:n,fracPart:e}=t;if(!e||r>=e.length)return t;const c=parseInt(e[r],10),i=e.slice(r+1).replace(/0+$/,""),o=c===5&&i==="";let s=!1;if(c>5||c===5&&i!=="")s=!0;else if(o){const a=r===0?n[n.length-1]:e[r-1];parseInt(a,10)%2!==0&&(s=!0)}if(s){if(r===0)return g(t);const{result:a,carry:f}=$(e.slice(0,r));return f?g(t):{intPart:n,fracPart:a}}return{intPart:n,fracPart:e.slice(0,r)}}function N(t,r={}){const n=r.rounding||"half",e=r.precision||0,{sign:c,intPart:i,fracPart:o}=t,s={intPart:i,fracPart:o};let a;switch(n){case"half":a=k(s,e);break;case"up":a=c?y(s,e):M(s,e);break;case"down":a=c?M(s,e):y(s,e);break;case"truncate":a=y(s,e);break;case"banker":a=W(s,e);break;default:a=k(s,e)}return{sign:c,...a}}function q(t,r={}){const n=N(m(t),r);return I(n)}const G=["K","M","B","T","Q"];function T(t,r={}){let{sign:n,intPart:e,fracPart:c}=t,i=e.length,o=-1;for(;i>3&&o<4;){const a=e.slice(0,i-3);c=e.slice(i-3)+c,e=a,i-=3,o++}const s=r.precision!=null?N({sign:n,intPart:e,fracPart:c},r):{intPart:e,fracPart:c};return{sign:n,intPart:B(s.intPart),fracPart:Z(s.fracPart),symbol:o>=0?G[o]:""}}function J(t,r={}){const{sign:n,intPart:e,fracPart:c,symbol:i}=T(m(t),r);return I({sign:n,intPart:e,fracPart:c})+i}function _(t){return typeof t=="object"&&"intPart"in t?t:m(t)}function j(t){const{sign:r,intPart:n,fracPart:e}=_(t),c=e.match(/^0+/)?.[0]?.length||0,i=c.toString().split("").reduce((o,s)=>o+String.fromCharCode(8320+Number(s)),"");return`${r}${n}.0${i}${e.slice(c)}`}function R(t){const{sign:r,intPart:n,fracPart:e}=t,c=r==="-"?"-":"";if(n!=="0"){const a=n.length-1,f=(n[0]+"."+(n.slice(1)+e).replace(/0+$/,"")).replace(/\.$/,"");return{value:`${c}${f}`,exponent:a,sign:"+"}}const i=e.search(/[1-9]/);if(i===-1)return{value:"0",exponent:0};const o=-(i+1),s=(e[i]+"."+e.slice(i+1).replace(/0+$/,"")).replace(/\.$/,"");return{value:`${c}${s}`,exponent:o,sign:""}}function O(t){const{value:r,exponent:n,sign:e}=R(_(t));return n!==0?`${r}e${e}${n}`:r}function u(t){return{round:r=>{const n=N(t,r);return u({...t,...n})},compact:r=>{if(t.compactedSymbol)return u(t);const n=T(t,r);return u({...t,intPart:n.intPart,fracPart:n.fracPart,compactedSymbol:n.symbol})},notation(r="scientific"){return u({...t,notation:r})},prefix(r){return u({...t,prefix:r})},suffix(r){return u({...t,suffix:r})},toNumber(){const{sign:r,intPart:n,fracPart:e,prefix:c,suffix:i,compactedSymbol:o,notation:s}=t;let a=e.length>0?`${n}.${e}`:n;return s==="scientific"?a=O({sign:"",intPart:n,fracPart:e}):s==="subscript"&&(a=j({sign:"",intPart:n,fracPart:e})),`${c||""}${r}${a}${o||""}${i||""}`},toObject(){return t}}}function w(t){return u(A(t))}function C(t,r={}){let n=w(t).round(r);return r.isCompact&&(n=n.compact(r)),r.notation&&(n=n.notation(r.notation)),r.prefix&&(n=n.prefix(r.prefix)),r.suffix&&(n=n.suffix(r.suffix)),n.toNumber()}function X(t={}){return r=>C(r,t)}exports.FN=w;exports.clearLeadingZero=B;exports.clearTrailingZero=Z;exports.clearUnnecessaryZero=p;exports.compact=J;exports.createFormatFunction=X;exports.formatNumber=C;exports.getBaseNumberNumber=m;exports.parseNum=z;exports.round=q;exports.scientific=O;exports.subscript=j;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,212 @@
1
- export * from './types';
2
- export * from './utils';
3
- export { compact } from './compact';
4
- export { FN, formatNumber } from './format';
5
- export { round } from './round';
1
+ export declare type BaseObjectNumberType = {
2
+ sign: SignType;
3
+ } & BasePositiveNumberType;
4
+
5
+ export declare type BasePositiveNumberType = {
6
+ intPart: string;
7
+ fracPart: string;
8
+ };
9
+
10
+ /**
11
+ * Removes leading zeros from a string (e.g., '005' -> '5').
12
+ */
13
+ export declare const clearLeadingZero: (value: string) => string;
14
+
15
+ /**
16
+ * Removes trailing zeros from a decimal string (e.g., '1.500' -> '1.5').
17
+ */
18
+ export declare const clearTrailingZero: (value: string) => string;
19
+
20
+ /**
21
+ * Removes redundant leading and trailing zeros from a number string.
22
+ */
23
+ export declare function clearUnnecessaryZero(value: string): string;
24
+
25
+ /**
26
+ * Formats a number into a short, human-readable string with a suffix (e.g., K, M, B).
27
+ *
28
+ * @param value - The value to be compacted. Can be a number, string, or bigint.
29
+ * @param options - Configuration for rounding the compacted value.
30
+ * @param options.rounding - The rounding strategy to use. Default is 'half'.
31
+ * @param options.precision - The number of decimal places to include after compacting. Default is 0.
32
+ * @returns The compacted number with a suffix as a string.
33
+ *
34
+ * @example
35
+ * compact(1500); // '1.5K'
36
+ * compact(1200000, { precision: 1 }); // '1.2M'
37
+ * compact('1000000000000'); // '1T'
38
+ */
39
+ export declare function compact(value: NumberType, options?: RoundingConfigType): string;
40
+
41
+ /**
42
+ * Creates a reusable formatting function with predefined options.
43
+ * Useful for applying consistent formatting across multiple numbers.
44
+ *
45
+ * @param options - Configuration options for the formatter.
46
+ * @returns A function that accepts a value and returns the formatted string.
47
+ *
48
+ * @example
49
+ * const formatCurrency = createFormatFunction({ prefix: '$', precision: 2 });
50
+ * formatCurrency(1234.56); // '$1234.56'
51
+ * formatCurrency(100); // '$100.00'
52
+ */
53
+ export declare function createFormatFunction(options?: FormattingConfigType): (value: NumberType) => string;
54
+
55
+ /**
56
+ * Fluent API for performing multiple formatting operations in a readable chain.
57
+ * Wraps the input value into a formatter object that supports rounding,
58
+ * compacting, notation, prefixes, and suffixes.
59
+ *
60
+ * @param value - The initial value to format, can be a number, string, or bigint.
61
+ * @returns A chainable `FNType` object.
62
+ *
63
+ * @example
64
+ * FN('1234567.89')
65
+ * .round({ precision: 0 })
66
+ * .prefix('$')
67
+ * .toNumber(); // '$1234568'
68
+ *
69
+ * @example
70
+ * FN(1000000)
71
+ * .compact()
72
+ * .suffix(' total')
73
+ * .toNumber(); // '1M total'
74
+ */
75
+ export declare function FN(value: NumberType | ObjectNumberType): FNType;
76
+
77
+ /**
78
+ * Fluent API interface for chainable number formatting operations.
79
+ */
80
+ export declare type FNType = {
81
+ /**
82
+ * Rounds the number based on the provided precision and strategy.
83
+ * @param options - Rounding configuration (precision, rounding strategy).
84
+ * @returns The same FNType instance for further chaining.
85
+ */
86
+ round(options?: RoundingConfigType): FNType;
87
+ /**
88
+ * Converts the number to a compact representation (e.g., 1K, 1M, 1B).
89
+ * @param options - Optional rounding configuration to apply during compaction.
90
+ * @returns The same FNType instance for further chaining.
91
+ */
92
+ compact(options?: RoundingConfigType): FNType;
93
+ /**
94
+ * Sets the notation style for the number (e.g., scientific, subscript).
95
+ * @param mode - The notation mode to use. Defaults to 'scientific'.
96
+ * @returns The same FNType instance for further chaining.
97
+ */
98
+ notation(mode?: NotationMode): FNType;
99
+ /**
100
+ * Adds a prefix to the formatted number string.
101
+ * @param symbol - The string to prepend.
102
+ * @returns The same FNType instance for further chaining.
103
+ */
104
+ prefix(symbol: string): FNType;
105
+ /**
106
+ * Adds a suffix to the formatted number string.
107
+ * @param symbol - The string to append.
108
+ * @returns The same FNType instance for further chaining.
109
+ */
110
+ suffix(symbol: string): FNType;
111
+ /**
112
+ * Finalizes the chain and returns the formatted number as a string.
113
+ * @returns The final formatted number string.
114
+ */
115
+ toNumber(): string;
116
+ /**
117
+ * Returns the internal state of the number as an ObjectNumberType.
118
+ * @returns The internal object representation.
119
+ */
120
+ toObject(): ObjectNumberType;
121
+ };
122
+
123
+ /**
124
+ * Comprehensive formatting function that combines rounding, compacting, and metadata.
125
+ * This is the quickest way to format a number with multiple options in a single call.
126
+ *
127
+ * @param value - The value to format (number, string, or bigint).
128
+ * @param options - Formatting configuration (precision, rounding strategy, compact mode, prefix, suffix, and notation style).
129
+ * @returns The final formatted number string.
130
+ *
131
+ * @example
132
+ * formatNumber(1234.56, { prefix: '$', precision: 1 }); // '$1234.6'
133
+ *
134
+ * @example
135
+ * formatNumber(1500000, { isCompact: true, notation: 'scientific' }); // '1.5M' (compacted before potential notation)
136
+ */
137
+ export declare function formatNumber(value: NumberType, options?: FormattingConfigType): string;
138
+
139
+ /** Full configuration options for the formatNumber function */
140
+ export declare type FormattingConfigType = RoundingConfigType & NumberConfigType & Partial<{
141
+ /** Whether to use compact notation (K, M, B, etc.) */
142
+ isCompact: boolean;
143
+ }>;
144
+
145
+ export declare function getBaseNumberNumber(value: NumberType): BaseObjectNumberType;
146
+
147
+ /** Modes for special numerical notation */
148
+ export declare type NotationMode = 'subscript' | 'scientific';
149
+
150
+ /** Configuration for basic number display properties */
151
+ export declare type NumberConfigType = Partial<{
152
+ /** Text to prepend to the number (e.g., '$') */
153
+ prefix: string;
154
+ /** Text to append to the number (e.g., ' units') */
155
+ suffix: string;
156
+ /** The notation style to apply */
157
+ notation: NotationMode;
158
+ }>;
159
+
160
+ /** Supported input types for number formatting */
161
+ export declare type NumberType = number | string | bigint;
162
+
163
+ /** Internal object structure containing full formatting state */
164
+ export declare type ObjectNumberType = BaseObjectNumberType & NumberConfigType & Partial<{
165
+ /** The symbol used for compact notation (e.g., 'K', 'M') */
166
+ compactedSymbol: string;
167
+ }>;
168
+
169
+ /**
170
+ * Parses various input formats into a standard decimal string.
171
+ */
172
+ export declare function parseNum(value: NumberType, options?: ParseNumberParamsType): string;
173
+
174
+ /** Configuration for input parsing */
175
+ export declare type ParseNumberParamsType = Partial<{
176
+ /** Value to return if parsing fails. Default is '--' */
177
+ fallback: string;
178
+ }>;
179
+
180
+ export declare function round(value: NumberType, options?: RoundingConfigType): string;
181
+
182
+ /** Configuration for rounding operations */
183
+ export declare type RoundingConfigType = Partial<{
184
+ /** The rounding strategy to use */
185
+ rounding: RoundingMode;
186
+ /** Number of decimal places to keep */
187
+ precision: number;
188
+ }>;
189
+
190
+ /** Strategies for rounding numbers */
191
+ export declare type RoundingMode = 'half' | 'up' | 'down' | 'banker' | 'truncate';
192
+
193
+ /**
194
+ * Formats a number string using standard scientific notation.
195
+ */
196
+ export declare function scientific(value: NumberType | BaseObjectNumberType): string;
197
+
198
+ export declare type ScientificReturnType = {
199
+ value: string;
200
+ exponent: number;
201
+ sign?: string;
202
+ };
203
+
204
+ /** Possible sign values for internal number representation */
205
+ export declare type SignType = '-' | '';
206
+
207
+ /**
208
+ * Formats the decimal part of small numbers using subscript characters.
209
+ */
210
+ export declare function subscript(value: NumberType | BaseObjectNumberType): string;
211
+
212
+ export { }
package/dist/index.js CHANGED
@@ -1,125 +1,223 @@
1
- function o(s) {
2
- const r = s.startsWith("-") ? "-" : "", t = r ? s.slice(1) : s;
3
- let e = 0, n = t.length - 1;
4
- for (; t[e] == "0" && e < t.length; ) e++;
5
- if (s.indexOf(".") >= 0) for (; t[n] == "0" && n >= 0; ) n--;
6
- const l = t.slice(e, n + 1);
7
- return l == "" || l == "." ? "0" : r + l;
8
- }
9
- function P(s) {
10
- let r = o(s);
11
- r = (r.startsWith("-") ? "-" : "") ? r.slice(1) : r;
12
- const [e, n = ""] = r.split("."), i = n.match(/^0+/)?.[0]?.length || 0, l = i.toString().split("").map((f) => String.fromCharCode(8320 + parseInt(f))).join(""), c = n.slice(i);
13
- return `${e}.0${l}${c}`;
14
- }
15
- function u(s) {
16
- let r = "", t = s.length - 1, e = "1";
17
- for (; t >= 0; ) {
18
- const n = s[t];
19
- let i = Number(n) + (e ? 1 : 0);
20
- i >= 10 ? (e = "1", i -= 10) : e = "", r = i.toString() + r, t--;
1
+ const K = (t) => t.replace(/0+$/, ""), Q = (t) => t.replace(/^0+(?!$)/, "");
2
+ function y(t) {
3
+ return t.replace(/^(-?)0+(?=\d)/, "$1").replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
4
+ }
5
+ function G(t, r = {}) {
6
+ const { fallback: n = "--" } = r;
7
+ if (typeof t == "number" || typeof t == "bigint") return t.toString();
8
+ const e = String(t ?? "").trim();
9
+ if (!e) return "0";
10
+ const c = e.match(/^[\s+-]*/), i = (c && c[0].match(/-/g) || []).length % 2 === 1, o = e.replace(/[$€£¥,_\s]/g, ""), s = o.match(/^([+-]?\d+)\.0([\u2080-\u2089]+)([0-9]*)$/i);
11
+ if (s) {
12
+ const [, l, C, O] = s, T = C.split("").reduce((U, D) => U + (D.charCodeAt(0) - 8320), 0), Z = y(l.replace(/^[+-]/, "") + "." + "0".repeat(T) + O);
13
+ return (i ? "-" : "") + (Z || "0");
21
14
  }
22
- return { result: e + r, remaining: e };
23
- }
24
- function d(s, r = 0) {
25
- const [t, e = ""] = s.split(".");
26
- if (r === 0)
27
- return e && Number(e[0]) >= 5 ? u(t).result : t;
28
- if (r >= e.length) return t + (e ? `.${e}` : "");
29
- const n = e.slice(0, r), i = e.slice(r);
30
- if (Number(i[0]) >= 5) {
31
- const l = u(n);
32
- return l.remaining ? u(t).result : t + "." + l.result;
33
- } else return t + "." + n;
34
- }
35
- function g(s, r = 0) {
36
- const [t, e = ""] = s.split(".");
37
- if (r === 0)
38
- return e ? u(t).result : t;
39
- if (r >= e.length) return t + "." + e;
40
- const n = u(e.slice(0, r));
41
- return n.remaining ? u(t).result : t + "." + n.result;
42
- }
43
- function a(s, r = 0) {
44
- const [t, e = ""] = s.split(".");
45
- if (r === 0) return t;
46
- let n = e.slice(0, r), i = n.length - 1;
47
- for (; i >= 0 && n[i] == "0"; ) i--;
48
- return n = n.slice(0, i + 1), t + (n ? `.${n}` : "");
49
- }
50
- function S(s, r = 0) {
51
- const [t, e = ""] = s.split(".");
52
- if (r === 0)
53
- return e && Number(e[0]) >= 5 ? Number(t[0]) / 2 == 0 ? t : u(t).result : t;
54
- if (r >= e.length) return t + (e ? `.${e}` : "");
55
- const n = e.slice(0, r), i = e.slice(r);
56
- if (i[0] == "5") {
57
- if (Number(n[n.length - 1]) % 2 == 0)
58
- return t + "." + n;
59
- {
60
- const l = u(n);
61
- return l.remaining ? u(t).result : t + "." + l.result;
62
- }
63
- } else if (Number(i[0]) > 5) {
64
- const l = u(n);
65
- return l.remaining ? u(t).result : t + "." + l.result;
66
- } else return t + "." + n;
67
- }
68
- function m(s, r = {}) {
69
- const t = r.mode || "half", e = r.precision || 0;
70
- let n = o(String(s)), i = "";
71
- switch (n.startsWith("-") && (n = n.slice(1), i = "-"), t) {
15
+ const a = o.match(/[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?[KMBTQ]*/i);
16
+ if (!a) return n;
17
+ let f = a[0].toUpperCase(), $ = 0;
18
+ const j = f.slice(-1), N = "KMBTQ".indexOf(j);
19
+ N !== -1 && ($ = (N + 1) * 3, f = f.slice(0, -1));
20
+ const h = f.match(/[E]([+-]?\d+)$/);
21
+ if (h && ($ += parseInt(h[1], 10), f = f.slice(0, h.index)), f = f.replace(/^[+-]/, ""), !/^(?:\d+\.?\d*|\.\d+)$/.test(f)) return "0";
22
+ const [w = "0", k = ""] = f.split("."), P = (w.replace(/^0+/, "") || "0") + k, b = k.length - $;
23
+ let d;
24
+ if (b <= 0)
25
+ d = (P + "0".repeat(-b)).replace(/^0+(?=\d)/, "") || "0";
26
+ else {
27
+ const l = P.length - b;
28
+ d = l <= 0 ? "0." + "0".repeat(-l) + P : P.slice(0, l) + "." + P.slice(l), d = y(d);
29
+ }
30
+ return (i ? "-" : "") + (d || "0");
31
+ }
32
+ function p(t) {
33
+ let r = String(t).trim();
34
+ const n = r.startsWith("-") ? "-" : "";
35
+ n && (r = r.slice(1));
36
+ const [e, c = ""] = y(r).split(".");
37
+ return { sign: n, intPart: e, fracPart: c };
38
+ }
39
+ const _ = (t) => t.fracPart ? `${t.sign}${t.intPart}.${t.fracPart}` : `${t.sign}${t.intPart}`;
40
+ function V(t) {
41
+ return typeof t == "object" && t !== null && "intPart" in t ? t : p(t);
42
+ }
43
+ function m(t) {
44
+ if (!t) return { result: "", carry: !0 };
45
+ const n = (BigInt(t) + 1n).toString();
46
+ return n.length > t.length ? { result: n.slice(1), carry: !0 } : { result: n.padStart(t.length, "0"), carry: !1 };
47
+ }
48
+ function g({ intPart: t }) {
49
+ const { result: r, carry: n } = m(t);
50
+ return { intPart: n ? "1" + r : r, fracPart: "" };
51
+ }
52
+ function I(t, r = 0) {
53
+ const { intPart: n, fracPart: e } = t;
54
+ if (!e || r >= e.length) return t;
55
+ if (parseInt(e[r], 10) >= 5) {
56
+ if (r === 0) return g(t);
57
+ const i = e.slice(0, r), { result: o, carry: s } = m(i);
58
+ return s ? g(t) : { intPart: n, fracPart: o };
59
+ }
60
+ return { intPart: n, fracPart: e.slice(0, r) };
61
+ }
62
+ function M(t, r = 0) {
63
+ const { intPart: n, fracPart: e } = t;
64
+ if (!e || r >= e.length) return t;
65
+ if (r === 0) return g(t);
66
+ const c = e.slice(0, r), { result: i, carry: o } = m(c);
67
+ return o ? g(t) : { intPart: n, fracPart: i };
68
+ }
69
+ function x(t, r = 0) {
70
+ const { intPart: n, fracPart: e } = t;
71
+ if (!e || r >= e.length) return t;
72
+ const c = e.slice(0, r);
73
+ return { intPart: n, fracPart: c.replace(/0+$/, "") };
74
+ }
75
+ function E(t, r = 0) {
76
+ const { intPart: n, fracPart: e } = t;
77
+ if (!e || r >= e.length) return t;
78
+ const c = parseInt(e[r], 10), i = e.slice(r + 1).replace(/0+$/, ""), o = c === 5 && i === "";
79
+ let s = !1;
80
+ if (c > 5 || c === 5 && i !== "")
81
+ s = !0;
82
+ else if (o) {
83
+ const a = r === 0 ? n[n.length - 1] : e[r - 1];
84
+ parseInt(a, 10) % 2 !== 0 && (s = !0);
85
+ }
86
+ if (s) {
87
+ if (r === 0) return g(t);
88
+ const { result: a, carry: f } = m(e.slice(0, r));
89
+ return f ? g(t) : { intPart: n, fracPart: a };
90
+ }
91
+ return { intPart: n, fracPart: e.slice(0, r) };
92
+ }
93
+ function S(t, r = {}) {
94
+ const n = r.rounding || "half", e = r.precision || 0, { sign: c, intPart: i, fracPart: o } = t, s = { intPart: i, fracPart: o };
95
+ let a;
96
+ switch (n) {
72
97
  case "half":
73
- return i + d(n, e);
98
+ a = I(s, e);
99
+ break;
74
100
  case "up":
75
- return i == "" ? g(n, e) : "-" + a(n, e);
101
+ a = c ? x(s, e) : M(s, e);
102
+ break;
76
103
  case "down":
77
- return i == "" ? a(n, e) : "-" + g(n, e);
104
+ a = c ? M(s, e) : x(s, e);
105
+ break;
78
106
  case "truncate":
79
- return i + a(n, e);
107
+ a = x(s, e);
108
+ break;
80
109
  case "banker":
81
- return i + S(n, e);
110
+ a = E(s, e);
111
+ break;
112
+ default:
113
+ a = I(s, e);
82
114
  }
115
+ return { sign: c, ...a };
83
116
  }
84
- const $ = ["K", "M", "B", "T", "Q"];
85
- function h(s, r = {}) {
86
- let t = o(String(s)), e = "";
87
- t.startsWith("-") && (t = t.slice(1), e = "-");
88
- let [n, i = ""] = t.split("."), l = n.length, c = -1;
89
- for (; l > 3 && c < 4; ) {
90
- const f = n.slice(0, l - 3);
91
- i = n.slice(l - 3) + i, n = f, l -= 3, c++;
117
+ function J(t, r = {}) {
118
+ const n = S(p(t), r);
119
+ return _(n);
120
+ }
121
+ const H = ["K", "M", "B", "T", "Q"];
122
+ function B(t, r = {}) {
123
+ let { sign: n, intPart: e, fracPart: c } = t, i = e.length, o = -1;
124
+ for (; i > 3 && o < 4; ) {
125
+ const a = e.slice(0, i - 3);
126
+ c = e.slice(i - 3) + c, e = a, i -= 3, o++;
127
+ }
128
+ const s = r.precision != null ? S({ sign: n, intPart: e, fracPart: c }, r) : { intPart: e, fracPart: c };
129
+ return {
130
+ sign: n,
131
+ intPart: Q(s.intPart),
132
+ fracPart: K(s.fracPart),
133
+ symbol: o >= 0 ? H[o] : ""
134
+ };
135
+ }
136
+ function R(t, r = {}) {
137
+ const { sign: n, intPart: e, fracPart: c, symbol: i } = B(p(t), r);
138
+ return _({ sign: n, intPart: e, fracPart: c }) + i;
139
+ }
140
+ function F(t) {
141
+ return typeof t == "object" && "intPart" in t ? t : p(t);
142
+ }
143
+ function z(t) {
144
+ const { sign: r, intPart: n, fracPart: e } = F(t), c = e.match(/^0+/)?.[0]?.length || 0, i = c.toString().split("").reduce((o, s) => o + String.fromCharCode(8320 + Number(s)), "");
145
+ return `${r}${n}.0${i}${e.slice(c)}`;
146
+ }
147
+ function A(t) {
148
+ const { sign: r, intPart: n, fracPart: e } = t, c = r === "-" ? "-" : "";
149
+ if (n !== "0") {
150
+ const a = n.length - 1, f = (n[0] + "." + (n.slice(1) + e).replace(/0+$/, "")).replace(
151
+ /\.$/,
152
+ ""
153
+ );
154
+ return { value: `${c}${f}`, exponent: a, sign: "+" };
92
155
  }
93
- return m(`${e}${n}.${i}`, r) + (c >= 0 ? $[c] : "");
156
+ const i = e.search(/[1-9]/);
157
+ if (i === -1) return { value: "0", exponent: 0 };
158
+ const o = -(i + 1), s = (e[i] + "." + e.slice(i + 1).replace(/0+$/, "")).replace(/\.$/, "");
159
+ return { value: `${c}${s}`, exponent: o, sign: "" };
94
160
  }
95
- function b(s, r) {
96
- let t = String(s);
97
- r.isCompact == !0 ? t = h(t, r) : r.isSmall || (t = m(t, r));
98
- const e = r.prefix || "", n = r.suffix || "", i = r.isSmall || !1;
99
- return `${e}${i ? P(t) : t}${n}`;
161
+ function L(t) {
162
+ const { value: r, exponent: n, sign: e } = A(F(t));
163
+ return n !== 0 ? `${r}e${e}${n}` : r;
100
164
  }
101
- function x(s) {
165
+ function u(t) {
102
166
  return {
103
- round(r = {}) {
104
- return x(m(s, r));
167
+ round: (r) => {
168
+ const n = S(t, r);
169
+ return u({ ...t, ...n });
170
+ },
171
+ compact: (r) => {
172
+ if (t.compactedSymbol) return u(t);
173
+ const n = B(t, r);
174
+ return u({
175
+ ...t,
176
+ intPart: n.intPart,
177
+ fracPart: n.fracPart,
178
+ compactedSymbol: n.symbol
179
+ });
180
+ },
181
+ notation(r = "scientific") {
182
+ return u({ ...t, notation: r });
183
+ },
184
+ prefix(r) {
185
+ return u({ ...t, prefix: r });
105
186
  },
106
- compact(r = {}) {
107
- return h(s, r);
187
+ suffix(r) {
188
+ return u({ ...t, suffix: r });
108
189
  },
109
- format(r = {}) {
110
- const t = r.prefix || "", e = r.suffix || "", n = r.isSmall || !1;
111
- return `${t}${n ? P(String(s)) : s}${e}`;
190
+ toNumber() {
191
+ const { sign: r, intPart: n, fracPart: e, prefix: c, suffix: i, compactedSymbol: o, notation: s } = t;
192
+ let a = e.length > 0 ? `${n}.${e}` : n;
193
+ return s === "scientific" ? a = L({ sign: "", intPart: n, fracPart: e }) : s === "subscript" && (a = z({ sign: "", intPart: n, fracPart: e })), `${c || ""}${r}${a}${o || ""}${i || ""}`;
112
194
  },
113
- toString() {
114
- return String(s);
195
+ toObject() {
196
+ return t;
115
197
  }
116
198
  };
117
199
  }
200
+ function W(t) {
201
+ return u(V(t));
202
+ }
203
+ function q(t, r = {}) {
204
+ let n = W(t).round(r);
205
+ return r.isCompact && (n = n.compact(r)), r.notation && (n = n.notation(r.notation)), r.prefix && (n = n.prefix(r.prefix)), r.suffix && (n = n.suffix(r.suffix)), n.toNumber();
206
+ }
207
+ function X(t = {}) {
208
+ return (r) => q(r, t);
209
+ }
118
210
  export {
119
- x as FN,
120
- h as compact,
121
- b as formatNumber,
122
- P as formatSmallNum,
123
- o as removeZero,
124
- m as round
211
+ W as FN,
212
+ Q as clearLeadingZero,
213
+ K as clearTrailingZero,
214
+ y as clearUnnecessaryZero,
215
+ R as compact,
216
+ X as createFormatFunction,
217
+ q as formatNumber,
218
+ p as getBaseNumberNumber,
219
+ G as parseNum,
220
+ J as round,
221
+ L as scientific,
222
+ z as subscript
125
223
  };
package/package.json CHANGED
@@ -1,16 +1,24 @@
1
1
  {
2
2
  "name": "@peter-present/format-number",
3
- "version": "0.0.1",
4
- "description": "Utility library for number formatting, rounding, and compact display.",
3
+ "version": "0.0.12",
4
+ "description": "A lightweight, zero-dependency JavaScript/TypeScript library for precise number formatting. Designed for financial applications, crypto dashboards, and scientific data where precision is paramount.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "sideEffects": false,
9
17
  "files": [
10
18
  "dist"
11
19
  ],
12
20
  "scripts": {
13
- "build": "bun run clear && tsc && vite build",
21
+ "build": "bun run clear && vite build",
14
22
  "preview": "vite preview",
15
23
  "clear": "rm -rf dist",
16
24
  "test": "vitest run",
package/dist/compact.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import { RoundingConfigType, NumberType } from './types';
2
- export declare function compact(value: NumberType, options?: RoundingConfigType): string;
package/dist/format.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { MetadataType, NumberType, OtherMetadataType, RoundingConfigType } from './types';
2
- export declare function formatNumber(value: NumberType, options?: MetadataType): string;
3
- export declare function FN(value: NumberType): {
4
- round(options?: RoundingConfigType): any;
5
- compact(options?: RoundingConfigType): string;
6
- format(options?: OtherMetadataType): string;
7
- toString(): string;
8
- };
package/dist/round.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { NumberType, RoundingConfigType } from './types';
2
- export declare function roundPositiveHalf(value: string, precision?: number): string;
3
- export declare function round(value: NumberType, options?: RoundingConfigType): string;
package/dist/types.d.ts DELETED
@@ -1,14 +0,0 @@
1
- export type NumberType = number | string | bigint;
2
- export type RoundingMode = 'half' | 'up' | 'down' | 'banker' | 'truncate';
3
- export type RoundingConfigType = Partial<{
4
- mode: RoundingMode;
5
- precision: number;
6
- }>;
7
- export type OtherMetadataType = Partial<{
8
- prefix: string;
9
- suffix: string;
10
- isSmall: boolean;
11
- }>;
12
- export type MetadataType = RoundingConfigType & OtherMetadataType & Partial<{
13
- isCompact: boolean;
14
- }>;
package/dist/utils.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export declare function removeZero(value: string): string;
2
- export declare function formatSmallNum(value: string): string;