Package Exports
- currency-library
- currency-library/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (currency-library) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
currency-library
Easily get data about different currencies in Javascript
Usage
getAll
Parameters
None
Return value
Returns object with ISO currency code as a key
const currencyLibrary = require('currency-library');
// OR
import * as currencyLibrary from 'currency-library';
console.log(currencyLibrary.getAll());
/** =>
{
//...
USD: {
isoCode: 'USD',
numericCode: '840',
minorUnits: 2,
name: 'United States dollar',
symbol: '$'
},
UAH: {
isoCode: 'UAH',
numericCode: '980',
minorUnits: 2,
name: 'Ukrainian hryvnia',
symbol: '₴'
},
// ...
}
**/getByIsoCode
Parameters
Expects ISO code string as only parameter
Return value
Returns currency object or undefined if currency not found
const currencyLibrary = require('currency-library');
// OR
import * as currencyLibrary from 'currency-library';
console.log(currencyLibrary.getByIsoCode('UAH'));
/** =>
{
isoCode: 'UAH',
numericCode: '980',
minorUnits: 2,
name: 'Ukrainian hryvnia',
symbol: '₴'
}
**/
console.log(currencyLibrary.getByIsoCode('WRONG CODE'));
// => undefinedgetByNumericCode
Parameters
Expects numeric currency code as only parameter
Return value
Returns currency object or undefined if currency not found
const currencyLibrary = require('currency-library');
// OR
import * as currencyLibrary from 'currency-library';
console.log(currencyLibrary.getByNumericCode(980));
/** =>
{
isoCode: 'UAH',
numericCode: '980',
minorUnits: 2,
name: 'Ukrainian hryvnia',
symbol: '₴'
}
**/
console.log(currencyLibrary.getByNumericCode(-1));
// => undefinedgetBySymbol
Parameters
Expects symbol parameter as only parameter
Return value
Returns currency object or undefined if currency not found
const currencyLibrary = require('currency-library');
// OR
import * as currencyLibrary from 'currency-library';
console.log(currencyLibrary.getBySymbol('₴'));
/** =>
{
isoCode: 'UAH',
numericCode: '980',
minorUnits: 2,
name: 'Ukrainian hryvnia',
symbol: '₴'
}
**/
console.log(currencyLibrary.getBySymbol('~'));
// => undefinedDevelopment
Run tests:
npm test -- --coverage