{"_id":"format-currency","_rev":"407793","name":"format-currency","description":"Format strings or numbers to currency strings.","dist-tags":{"latest":"1.0.0"},"maintainers":[{"name":"jprichardson","email":""}],"time":{"modified":"2021-08-04T04:55:54.000Z","created":"2016-03-18T08:41:24.405Z","1.0.0":"2016-03-18T08:41:24.405Z"},"users":{"edgars-sirokovs":true},"author":{"name":"JP Richardson"},"repository":{"type":"git","url":"git+https://github.com/exodusmovement/format-num.git"},"versions":{"1.0.0":{"name":"format-currency","version":"1.0.0","description":"Format strings or numbers to currency strings.","main":"index.js","files":["index.js"],"scripts":{"lint":"standard","test":"npm run lint && npm run unit","unit":"ava --verbose"},"repository":{"type":"git","url":"git+https://github.com/exodusmovement/format-num.git"},"keywords":["number","format","formatting","string","number-unit","money","currency","bitcoin","ethereum"],"author":{"name":"JP Richardson"},"license":"MIT","bugs":{"url":"https://github.com/exodusmovement/format-num/issues"},"homepage":"https://github.com/exodusmovement/format-num#readme","dependencies":{"format-num":"^1.0.0"},"devDependencies":{"ava":"0.13.x","standard":"6.x"},"gitHead":"7c1aee247f723c21b1afbc68d4b73d022c25bd67","_id":"format-currency@1.0.0","_shasum":"f907943f390c2ff36be2a51b0a6fb25ad3fe01c8","_from":".","_npmVersion":"3.7.1","_nodeVersion":"5.3.0","_npmUser":{"name":"jprichardson","email":"jprichardson@gmail.com"},"maintainers":[{"name":"jprichardson","email":""}],"dist":{"shasum":"f907943f390c2ff36be2a51b0a6fb25ad3fe01c8","size":2162,"noattachment":false,"key":"/format-currency/-/format-currency-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/format-currency/download/format-currency-1.0.0.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/format-currency-1.0.0.tgz_1458290481968_0.08224577829241753"},"directories":{},"publish_time":1458290484405,"_cnpm_publish_time":1458290484405,"_hasShrinkwrap":false}},"readme":"format-currency\n===============\n\n[![NPM Package](https://img.shields.io/npm/v/format-currency.svg?style=flat-square)](https://www.npmjs.org/package/format-currency)\n[![Build Status](https://img.shields.io/travis/ExodusMovement/format-currency.svg?branch=master&style=flat-square)](https://travis-ci.org/ExodusMovement/format-currency)\n[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)\n\n`format-currency` is a JavaScript component to format numbers and strings to currency strings. Used in [Exodus Ethereum Wallet](http://www.exodus.io/).\n\n\nInstall\n-------\n\n    npm install --save format-currency\n\n\nNotes\n-----\n\n- Must have a JavaScript environment with `Object.assign` and `Intl.NumberFormat`.\nIn Node.js, this is at least v4. You can install in older environments, you'll just\nneed to polyfill.\n\n\nUsage\n-----\n\n### formatCurrency\n\n**Signature:** `formatCurrency(value, [options])`\n\n**Parameters:**\n\n- `value`: Value to convert. Will pass through [parse-num](https://github.com/ExodusMovement/parse-num) first.\nWill coerce anything to a number.\n- `options`: *optional* `object` parameter to specify [options](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat).\nAppending `Digits` is not necessary. You can also shorten `maximum` to `max` and `minimum` to `min`. Adds one more option `nanZero`, which when the number is\n`NaN`, if it should be coerced to `0` - defaults to `true` i.e. `NaN => '0'`. Also available `code`, `symbol`, `format`.\n\n**Returns:**\n\nA `string` currency representation of the number.\n\n**Example:**\n\n```js\nconst formatCurrency = require('format-currency')\n\n// default, no currency symbol or code\nconsole.log(formatCurrency(10000000.15)) // => 10,000,000.15\n\n// include the currency code 'USD'\nlet opts = { format: '%v %c', code: 'USD' }\nconsole.log(formatCurrency(10000000.15, opts)) // => 10,000,000.15 USD\n\n// now include the currency symbol\nlet opts = { format: '%s%v %c', code: 'USD', symbol: '$' }\nconsole.log(formatCurrency(10000000.15, opts)) // => $10,000,000.15 USD\n\n// use to reformat currency strings\nlet opts = { format: '%s%v', symbol: '$' }\nconsole.log(formatCurrency('$10,000,000.15 USD', opts)) // => $10,000,000.15\n\n// change locale\nlet opts = { format: '%s%v', symbol: '$', locale: 'de-DE' }\n// in Node.js (English only, unless you compiled with other language support)\nconsole.log(formatCurrency(10000000.15, opts)) // => $10,000,000.15\n// in Electron (renderer) or browser (supports all locales)\nconsole.log(formatCurrency(10000000.15, opts)) // => $10.000.000,15\n\n// crypto currency (Bitcoin, Ethereum)\nlet opts = { format: '%v %c', code: 'BTC', maxFraction: 8 }\nconsole.log(formatCurrency(1.123456789, opts)) // => 1.12345678 (notice only 8)\n```\n\nRelated\n-------\n- [format-num](https://github.com/ExodusMovement/format-num): Format numbers / number strings to nice strings with grouping and decimal separators.\n- [number-unit](https://github.com/ExodusMovement/number-unit): Numbers with units. Easily convert numbers to from different units.\n- [parse-num](https://github.com/ExodusMovement/parse-num): Parse anything into a number. A dependency\nof this library.\n\n\nLicense\n-------\n\nMIT\n","_attachments":{},"homepage":"https://github.com/exodusmovement/format-num#readme","bugs":{"url":"https://github.com/exodusmovement/format-num/issues"},"license":"MIT"}