File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed
packages/common-ts/src/util Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change @@ -2,3 +2,4 @@ export * from './equal'
22export * from './arrays'
33export * from './addresses'
44export * from './bytes'
5+ export * from './commify'
You can’t perform that action at this time.
0 commit comments