UNPKG

make-it-rain

Version:

Because who formats money manually like a peasant?

73 lines (52 loc) โ€ข 3.06 kB
# ๐Ÿ’ธ make-it-rain ๐Ÿ’ธ [![Version](https://img.shields.io/badge/version-1.1.1.1-blue)](https://npmjs.com/package/make-it-rain) [![Node.js](https://img.shields.io/badge/node-%3E%3D12.0-brightgreen)](https://nodejs.org/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) ### The Only Money Formatter You'll Ever Need (Probably) So, you've finally decided that numbers should look nice? **Wow, groundbreaking.** Instead of manually adding commas and dots like a caveman, let **`make-it-rain`** handle the **tough** job of making your numbers **actually readable**. ## ๐Ÿš€ Why Use This? Because: โœ… You want your app to look like it knows what money is. โœ… You're too lazy to format numbers manually (same). โœ… You finally realized not everyone uses the same thousands separator. โœ… You enjoy writing `toLocaleString()` 50 times per project? No? Didnโ€™t think so. ## ๐Ÿ“ฆ Installation Oh no, another package to install? **Deal with it.** ```sh npm install make-it-rain ``` or if you're feeling edgy: ```sh yarn add make-it-rain ``` ## ๐Ÿ› ๏ธ Usage Initialize this life-changing formatter once, then flex on your ugly numbers forever. ```js const makeItRain = require("make-it-rain"); const money = makeItRain("EUR", ".", true); // Set it and forget it console.log(money.makeItPretty(1234567.89)); // โ‚ฌ1.234.567,89 money.useWhat(false); // Switch to ISO code mode console.log(money.makeItPretty(1234567.89)); // EUR 1.234.567,89 ``` | Method | Description | |--------|-------------| |`makeItRain(currency, separator, useSymbol)` | Initializes the formatter once. Currency = any ISO currency code, separator = `,` or .`,` useSymbol = `true` for symbols (`$`), `false` for codes (`USD`). | | `makeItPretty(amount)` | Takes a number and makes it visually acceptable.| | `swapMoney(newCurrency)` | Change the currency to something else, because why not? | | `useWhat(symbol)` | Toggle between using currency symbols (`$`) or ISO codes (`USD`). | | `whatNow()` | Returns the current currency, in case you forgot. | ## ๐ŸŽฉ Features (That Should Have Existed in JavaScript Already) - One-time setup: Set currency & separator once, use it everywhere. - Formats numbers beautifully: Because nobody likes reading 1000000.00. - Handles separators like a champ: Pick , or ., because the world can't agree. - Errors when you mess up: Because I'm not letting you pass "lol" as a number. ## โŒ What This Wonโ€™t Do - Convert currency: This isn't a forex exchange, buddy. - Fix your bad financial decisions: Your debt is still your problem. - Magically make you rich: But hey, your numbers will look expensive. ## ๐Ÿ† Contributing Want to contribute? Cool. Fork it, break it, fix it, and submit a PR. ## ๐Ÿ“œ License MIT โ€“ Because I'm not here to sue you. ## โญ Pro Tip Use this package and pretend youโ€™re rich. Youโ€™re welcome. This README will **ensure** your package is taken *seriously* while also making people question their life choices.