Skip to content

Commit cb476a9

Browse files
Maikoltmigone
authored andcommitted
fix: export commify
Signed-off-by: Tomás Migone <[email protected]>
1 parent e1d7ad0 commit cb476a9

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import "ethers"
1+
import 'ethers'
22

3-
function commify(value: string): string {
4-
const match = value.match(/^(-?)([0-9]*)(\.?)([0-9]*)$/);
3+
export function commify(value: string): string {
4+
const match = value.match(/^(-?)([0-9]*)(\.?)([0-9]*)$/)
55
if (!match || (!match[2] && !match[4])) {
6-
throw new Error(`bad formatted number: ${ JSON.stringify(value) }`);
6+
throw new Error(`bad formatted number: ${JSON.stringify(value)}`)
77
}
88

9-
const neg = match[1];
10-
const whole = BigInt(match[2] || 0).toLocaleString("en-us");
11-
const frac = match[4] ? (match[4].match(/^(.*?)0*$/)?.[1] || "0") : "0";
9+
const neg = match[1]
10+
const whole = BigInt(match[2] || 0).toLocaleString('en-us')
11+
const frac = match[4] ? match[4].match(/^(.*?)0*$/)?.[1] || '0' : '0'
1212

13-
return `${ neg }${ whole }.${ frac }`;
14-
}
13+
return `${neg}${whole}.${frac}`
14+
}

packages/common-ts/src/util/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export * from './equal'
22
export * from './arrays'
33
export * from './addresses'
44
export * from './bytes'
5+
export * from './commify'

0 commit comments

Comments
 (0)