mcduck

0.1.7 • Public • Published

mcduck

Convert integers and string formatted integers to a properly formatted currency and back again to an integer/string formatted integer

Build Status

Coverage Status

Installation

npm install mcduck --save or yarn add mcduck --save

Usage

RequireJS:

const mcduck = require('mcduck');

const formattedCurrency = mcduck.toCurrency('356660', 'USD');
Output should be 'USD 3 566.60';
const formattedCurrencyToInteger = mcduck.toInteger(formattedCurrency);
Output should be 356660;
const formattedCurrencyToIntegerString = mcduck.toIntegerString(formattedCurrency);
Output should be '356660';

es6:
import mcduck from 'mcduck';

const formattedCurrency = mcduck.toCurrency('356660', 'USD');
Output should be 'USD 3 566.60';
const formattedCurrencyToInteger = mcduck.toInteger(formattedCurrency);
Output should be 356660;
const formattedCurrencyToIntegerString = mcduck.toIntegerString(formattedCurrency);
Output should be '356660';

Tests

npm test

Contributing

In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

Package Sidebar

Install

npm i mcduck

Weekly Downloads

1

Version

0.1.7

License

ISC

Unpacked Size

79.6 kB

Total Files

9

Last publish

Collaborators

  • hermannhh