Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@exodus/currency

Package Overview
Dependencies
Maintainers
0
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@exodus/currency - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

6

CHANGELOG.md

@@ -0,1 +1,7 @@

1.0.4 / 2019-06-22
------------------
- Add `number-unit.div`
- Use `number-unit.div` in `conversion-by-rate` to avoid using `parseFloat`
1.0.3 / 2019-06-21

@@ -2,0 +8,0 @@ ------------------

11

lib/conversion-by-rate.js

@@ -32,4 +32,11 @@ "use strict";

} else if (ut === ut2) {
rate = parseFloat(rate);
const newUnit = ut1.baseUnit(someNumberUnit._number).mul(ut1[unit1].multiplier).mul(rate === 0 ? 0 : 1 / rate);
let newUnit = ut1.baseUnit(someNumberUnit._number).mul(ut1[unit1].multiplier);
try {
newUnit = newUnit.div(rate);
} catch (err) {
if (String(err.message) !== 'Invalid division by 0') throw err;
newUnit = ut1.baseUnit(0);
}
newUnit._number = newUnit._number.div(ut2[unit2].multiplier);

@@ -36,0 +43,0 @@ return newUnit.to(unit1);

@@ -217,2 +217,22 @@ "use strict";

div(num) {
if (_bn.default.isBN(num)) {
return new NumberUnit(this._number.div(num), this.unit);
}
const {
number,
fraction,
fractionLength
} = this._stringToNumberFraction(num, 0);
const fractionPow = new _bn.default(10, 10).pow(new _bn.default(fractionLength, 10));
const numberBN = new _bn.default(number, 10).imul(fractionPow).iadd(new _bn.default(fraction, 10));
if (numberBN.isZero()) throw new Error('Invalid division by 0');
const bn = this._number.mul(fractionPow).div(numberBN);
return new NumberUnit(bn, this.unit);
}
floor() {

@@ -219,0 +239,0 @@ if (this.unit.power === 0) {

2

package.json
{
"name": "@exodus/currency",
"version": "1.0.3",
"version": "1.0.4",
"description": "Currency support.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc