UNPKG

test-triam-base-contract

Version:

Low level triam smart cotnract support library

43 lines (33 loc) 854 B
import Bignumber from 'bignumber.js'; export class Numbers { constructor (_num) { if (typeof _num != 'string') { throw new Error ("argument must be a string"); } this.Number = new Bignumber (_num); } add (_num) { if (typeof _num != 'string') { throw new Error ("argument must be a string"); } return this.Number.plus (new Bignumber (_num)); } sub (_num) { if (typeof _num != 'string') { throw new Error ("argument must be a string"); } return this.Number.minus (new Bignumber (_num)); } mul (_num) { return this.Number.mul (new Bignumber (_num)); } div (_num) { return this.Number.div (new Bignumber (_num)); } mod (_num) { return this.Number.mod (new Bignumber (_num)); } toString (_base) { return this.Number.toString (_base); } }