-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,53 @@ | ||
# stripe-money-format | ||
# Stripe Money format | ||
|
||
A simple js function to format numbers to stripe's smallest common currency unit format | ||
|
||
Supports most International Curriences. | ||
|
||
## Usage | ||
|
||
### ES6 | ||
|
||
```js | ||
import {toStripeFormat} from "stripe-money-format"; | ||
|
||
const number = "86,753.09"; | ||
console.log(toStripeFormat(number)); // 8675309 | ||
``` | ||
|
||
### CommonJS | ||
|
||
```js | ||
const toStripeFormat = require("stripe-money-format"); | ||
|
||
const number = "86,753.09"; | ||
console.log(toStripeFormat(number)); // 8675309 | ||
``` | ||
|
||
## International Currency Support | ||
|
||
Should support any currency shown by the node Intl package: [Intl.NumberFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat) | ||
|
||
### ES6 Example | ||
|
||
```js | ||
import {toStripeFormatCustomCurrency} from "stripe-money-format"; | ||
|
||
const number = "123456.789"; | ||
const currency = "EUR"; | ||
const language = "de-DE"; | ||
|
||
console.log(toStripeFormatCustomCurrency(currency, language, number)); // 12345679 | ||
``` | ||
|
||
### Common JS Example | ||
|
||
```js | ||
const {toStripeCustomCurrency} = require("stripe-money-format"); | ||
|
||
const number = "123456.789"; | ||
const currency = "EUR"; | ||
const language = "de-DE"; | ||
|
||
console.log(toStripeCustomCurrency(currency, language, number)); // 12345679 | ||
``` |