File tree Expand file tree Collapse file tree 5 files changed +16
-2
lines changed
Expand file tree Collapse file tree 5 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " jsbd" ,
3- "version" : " 0.0.7 " ,
3+ "version" : " 0.0.8 " ,
44 "main" : " dist/index.js" ,
55 "module" : " dist/index.modern.mjs" ,
66 "unpkg" : " dist/index.umd.js" ,
Original file line number Diff line number Diff line change 11import { JSBD } from './jsbd'
22
3+ export { Decimal } from './decimal'
4+
35export default JSBD
Original file line number Diff line number Diff line change @@ -8,6 +8,9 @@ export class JSBD {
88 * @param intVal default value to init a BigDecimal object
99 */
1010 static BigDecimal ( intVal : DecimalIntVal ) {
11+ if ( intVal instanceof Decimal ) {
12+ return snDecimal ( intVal . mantissa , intVal . exponent )
13+ }
1114 return new Decimal ( intVal )
1215 }
1316 // add => a + b
Original file line number Diff line number Diff line change 1- export type DecimalIntVal = string | number | bigint
1+ import { Decimal } from './decimal'
2+
3+ export type DecimalIntVal = string | number | bigint | Decimal
24
35export type DecimalSign = - 1 | 1
46
Original file line number Diff line number Diff line change 1+ import { JSBD } from '../../src/jsbd'
2+
3+ test ( 'copy Decimal a' , ( ) => {
4+ let a = JSBD . BigDecimal ( '100' )
5+ let b = JSBD . BigDecimal ( a )
6+ expect ( JSBD . equal ( a , b ) ) . toBe ( true )
7+ } )
You can’t perform that action at this time.
0 commit comments