Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(adapters): embrace the adapter pattern
Breaking changes Full refactoring, everything shall break :)
- Loading branch information
1 parent
c2c4073
commit 046ee56
Showing
16 changed files
with
835 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/*jshint node:true */ | ||
|
||
'use strict'; | ||
|
||
var bigjs = require('big.js'); | ||
|
||
module.exports = { | ||
getInstance: bigjs, | ||
getPrecision: getPrecision, | ||
setPrecision: setPrecision, | ||
plus: plus, | ||
minus: minus, | ||
times: times, | ||
div: div, | ||
toString: toString, | ||
valueOf: valueOf, | ||
toJSON: valueOf | ||
}; | ||
|
||
function getPrecision(Big) { | ||
return Big.DP; | ||
} | ||
|
||
function setPrecision(Big, n) { | ||
Big.DP = n; | ||
} | ||
|
||
function plus(big, x) { | ||
return big.plus(x); | ||
} | ||
|
||
function minus(big, x) { | ||
return big.minus(x); | ||
} | ||
|
||
function times(big, x) { | ||
return big.times(x); | ||
} | ||
|
||
function div(big, x) { | ||
return big.div(x); | ||
} | ||
|
||
function toString(big) { | ||
return big.toString(); | ||
} | ||
|
||
function valueOf(big) { | ||
return big.valueOf(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/*jshint node:true */ | ||
|
||
'use strict'; | ||
|
||
var bignumber = require('bignumber.js'); | ||
|
||
module.exports = { | ||
getInstance: getInstance, | ||
getPrecision: getPrecision, | ||
setPrecision: setPrecision, | ||
plus: plus, | ||
minus: minus, | ||
times: times, | ||
div: div, | ||
toString: toString, | ||
valueOf: valueOf, | ||
toJSON: valueOf | ||
}; | ||
|
||
function getPrecision(Bignumber) { | ||
return Bignumber.config().DECIMAL_PLACES; | ||
} | ||
|
||
function setPrecision(Bignumber, n) { | ||
Bignumber.config(n); | ||
} | ||
|
||
function plus(bignumber, x) { | ||
return bignumber.plus(x); | ||
} | ||
|
||
function minus(bignumber, x) { | ||
return bignumber.minus(x); | ||
} | ||
|
||
function times(bignumber, x) { | ||
return bignumber.times(x); | ||
} | ||
|
||
function div(bignumber, x) { | ||
return bignumber.div(x); | ||
} | ||
|
||
function toString(bignumber) { | ||
return bignumber.toString(); | ||
} | ||
|
||
function valueOf(bignumber) { | ||
return bignumber.valueOf(); | ||
} | ||
|
||
function getInstance() { | ||
return bignumber.another(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/*jshint node:true */ | ||
|
||
'use strict'; | ||
|
||
var decimal = require('decimal.js'); | ||
|
||
module.exports = { | ||
getInstance: getInstance, | ||
getPrecision: getPrecision, | ||
setPrecision: setPrecision, | ||
plus: plus, | ||
minus: minus, | ||
times: times, | ||
div: div, | ||
toString: toString, | ||
valueOf: valueOf, | ||
toJSON: valueOf | ||
}; | ||
|
||
function getPrecision(Decimal) { | ||
return Decimal.precision; | ||
} | ||
|
||
function setPrecision(Decimal, n) { | ||
Decimal.precision = n; | ||
} | ||
|
||
function plus(decimal, x) { | ||
return decimal.plus(x); | ||
} | ||
|
||
function minus(decimal, x) { | ||
return decimal.minus(x); | ||
} | ||
|
||
function times(decimal, x) { | ||
return decimal.times(x); | ||
} | ||
|
||
function div(decimal, x) { | ||
return decimal.div(x); | ||
} | ||
|
||
function toString(decimal) { | ||
return decimal.toString(); | ||
} | ||
|
||
function valueOf(decimal) { | ||
return decimal.valueOf(); | ||
} | ||
|
||
function getInstance() { | ||
return decimal.constructor(); | ||
} |
Oops, something went wrong.