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

@makerdao/currency

Package Overview
Dependencies
Maintainers
5
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@makerdao/currency - npm Package Compare versions

Comparing version 0.9.9 to 0.9.10

4

dist/Currency.js

@@ -47,2 +47,3 @@ 'use strict';

function amountToBigNumber(amount) {
if (amount._isBigNumber && amount._hex) amount = amount._hex;
if (amount instanceof Currency || typeof amount.toBigNumber === 'function') return amount.toBigNumber();

@@ -76,4 +77,5 @@

var decimals = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 2;
var symbol = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
return this._amount.toFixed(decimals) + ' ' + this.symbol;
return symbol ? this._amount.toFixed(decimals) + ' ' + this.symbol : this._amount.toFixed(decimals);
}

@@ -80,0 +82,0 @@ }, {

{
"name": "@makerdao/currency",
"description": "Utilities for working with currency amounts",
"version": "0.9.9",
"version": "0.9.10",
"license": "MIT",

@@ -20,2 +20,3 @@ "main": "dist/index.js",

"devDependencies": {
"@ethersproject/bignumber": "^5.5.0",
"babel-cli": "^6.26.0",

@@ -22,0 +23,0 @@ "babel-jest": "^22.4.3",

import BigNumber from 'bignumber.js';
function amountToBigNumber(amount) {
if (amount._isBigNumber && amount._hex) amount = amount._hex;
if (amount instanceof Currency || typeof amount.toBigNumber === 'function')

@@ -27,4 +28,6 @@ return amount.toBigNumber();

toString(decimals = 2) {
return `${this._amount.toFixed(decimals)} ${this.symbol}`;
toString(decimals = 2, symbol = true) {
return symbol
? `${this._amount.toFixed(decimals)} ${this.symbol}`
: this._amount.toFixed(decimals);
}

@@ -31,0 +34,0 @@

import { Currency, createCurrency, createCurrencyRatio } from '../src';
import BigNumber from 'bignumber.js';
import { BigNumber as EthersBN } from '@ethersproject/bignumber';

@@ -44,2 +45,7 @@ const DAI = createCurrency('DAI');

test('toString accepts a boolean to not print symbol', () => {
const n = MKR('1000.5447123');
expect(n.toString(3, false)).toBe('1000.545');
});
test('basic math', () => {

@@ -154,2 +160,8 @@ const a = MKR('1.2');

expect(val.eq(5)).toBeTruthy();
});
});
test('can safely handle ethers bignumber (BN.js)', () => {
const ethersBN = EthersBN.from(555);
const val = ETH(ethersBN);
expect(val.eq(555)).toBeTruthy();
});
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