make-it-rain 1.1.2 β†’ 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +72 -72
  3. package/index.js +68 -68
  4. package/package.json +1 -1
package/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2025 Alvian Zachry Faturrahman
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Alvian Zachry Faturrahman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,72 +1,72 @@
1
- # πŸ’Έ make-it-rain πŸ’Έ
2
- [![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)
3
-
4
- ### The Only Money Formatter You'll Ever Need (Probably)
5
-
6
- So, you've finally decided that numbers should look nice? **Wow, groundbreaking.**
7
- Instead of manually adding commas and dots like a caveman, let **`make-it-rain`** handle the **tough** job of making your numbers **actually readable**.
8
-
9
- ## πŸš€ Why Use This?
10
- Because:
11
- βœ… You want your app to look like it knows what money is.
12
- βœ… You're too lazy to format numbers manually (same).
13
- βœ… You finally realized not everyone uses the same thousands separator.
14
- βœ… You enjoy writing `toLocaleString()` 50 times per project? No? Didn’t think so.
15
-
16
- ## πŸ“¦ Installation
17
- Oh no, another package to install? **Deal with it.**
18
- ```sh
19
- npm install make-it-rain
20
- ```
21
-
22
- or if you're feeling edgy:
23
-
24
- ```sh
25
- yarn add make-it-rain
26
- ```
27
- ## πŸ› οΈ Usage
28
- Initialize this life-changing formatter once, then flex on your ugly numbers forever.
29
-
30
-
31
- ```js
32
- const makeItRain = require("make-it-rain");
33
-
34
- const money = makeItRain("EUR", ".", true); // Set it and forget it
35
-
36
- console.log(money.makeItPretty(1234567.89)); // €1.234.567,89
37
- money.useWhat(false); // Switch to ISO code mode
38
- console.log(money.makeItPretty(1234567.89)); // EUR 1.234.567,89
39
- ```
40
-
41
-
42
- | Method | Description |
43
- |--------|-------------|
44
- |`makeItRain(currency, separator, useSymbol)` | Initializes the formatter once. Currency = any ISO currency code, separator = `,` or .`,` useSymbol = `true` for symbols (`$`), `false` for codes (`USD`). |
45
- | `makeItPretty(amount)` | Takes a number and makes it visually acceptable.|
46
- | `swapMoney(newCurrency)` | Change the currency to something else, because why not? |
47
- | `useWhat(symbol)` | Toggle between using currency symbols (`$`) or ISO codes (`USD`). |
48
- | `whatNow()` | Returns the current currency, in case you forgot. |
49
-
50
-
51
- ## 🎩 Features (That Should Have Existed in JavaScript Already)
52
- - One-time setup: Set currency & separator once, use it everywhere.
53
- - Formats numbers beautifully: Because nobody likes reading 1000000.00.
54
- - Handles separators like a champ: Pick , or ., because the world can't agree.
55
- - Errors when you mess up: Because I'm not letting you pass "lol" as a number.
56
-
57
- ## ❌ What This Won’t Do
58
- - Convert currency: This isn't a forex exchange, buddy.
59
- - Fix your bad financial decisions: Your debt is still your problem.
60
- - Magically make you rich: But hey, your numbers will look expensive.
61
-
62
- ## πŸ† Contributing
63
- Want to contribute? Cool. Fork it, break it, fix it, and submit a PR.
64
-
65
- ## πŸ“œ License
66
- MIT – Because I'm not here to sue you.
67
-
68
- ## ⭐ Pro Tip
69
- Use this package and pretend you’re rich. You’re welcome.
70
-
71
- This README will **ensure** your package is taken *seriously* while also making people question their life choices.
72
-
1
+ # πŸ’Έ make-it-rain πŸ’Έ
2
+ [![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)
3
+
4
+ ### The Only Money Formatter You'll Ever Need (Probably)
5
+
6
+ So, you've finally decided that numbers should look nice? **Wow, groundbreaking.**
7
+ Instead of manually adding commas and dots like a caveman, let **`make-it-rain`** handle the **tough** job of making your numbers **actually readable**.
8
+
9
+ ## πŸš€ Why Use This?
10
+ Because:
11
+ βœ… You want your app to look like it knows what money is.
12
+ βœ… You're too lazy to format numbers manually (same).
13
+ βœ… You finally realized not everyone uses the same thousands separator.
14
+ βœ… You enjoy writing `toLocaleString()` 50 times per project? No? Didn’t think so.
15
+
16
+ ## πŸ“¦ Installation
17
+ Oh no, another package to install? **Deal with it.**
18
+ ```sh
19
+ npm install make-it-rain
20
+ ```
21
+
22
+ or if you're feeling edgy:
23
+
24
+ ```sh
25
+ yarn add make-it-rain
26
+ ```
27
+ ## πŸ› οΈ Usage
28
+ Initialize this life-changing formatter once, then flex on your ugly numbers forever.
29
+
30
+
31
+ ```js
32
+ const makeItRain = require("make-it-rain");
33
+
34
+ const money = makeItRain("EUR", ".", true); // Set it and forget it
35
+
36
+ console.log(money.makeItPretty(1234567.89)); // €1.234.567,89
37
+ money.useWhat(false); // Switch to ISO code mode
38
+ console.log(money.makeItPretty(1234567.89)); // EUR 1.234.567,89
39
+ ```
40
+
41
+
42
+ | Method | Description |
43
+ |--------|-------------|
44
+ |`makeItRain(currency, separator, useSymbol)` | Initializes the formatter once. Currency = any ISO currency code, separator = `,` or .`,` useSymbol = `true` for symbols (`$`), `false` for codes (`USD`). |
45
+ | `makeItPretty(amount)` | Takes a number and makes it visually acceptable.|
46
+ | `swapMoney(newCurrency)` | Change the currency to something else, because why not? |
47
+ | `useWhat(symbol)` | Toggle between using currency symbols (`$`) or ISO codes (`USD`). |
48
+ | `whatNow()` | Returns the current currency, in case you forgot. |
49
+
50
+
51
+ ## 🎩 Features (That Should Have Existed in JavaScript Already)
52
+ - One-time setup: Set currency & separator once, use it everywhere.
53
+ - Formats numbers beautifully: Because nobody likes reading 1000000.00.
54
+ - Handles separators like a champ: Pick , or ., because the world can't agree.
55
+ - Errors when you mess up: Because I'm not letting you pass "lol" as a number.
56
+
57
+ ## ❌ What This Won’t Do
58
+ - Convert currency: This isn't a forex exchange, buddy.
59
+ - Fix your bad financial decisions: Your debt is still your problem.
60
+ - Magically make you rich: But hey, your numbers will look expensive.
61
+
62
+ ## πŸ† Contributing
63
+ Want to contribute? Cool. Fork it, break it, fix it, and submit a PR.
64
+
65
+ ## πŸ“œ License
66
+ MIT – Because I'm not here to sue you.
67
+
68
+ ## ⭐ Pro Tip
69
+ Use this package and pretend you’re rich. You’re welcome.
70
+
71
+ This README will **ensure** your package is taken *seriously* while also making people question their life choices.
72
+
package/index.js CHANGED
@@ -1,68 +1,68 @@
1
- const currencySymbols = require("currency-symbol-map");
2
-
3
- class MoneyFormatter {
4
- constructor(currency = "USD", separator = ",", useSymbol = true) {
5
- if (![".", ","].includes(separator)) {
6
- throw new Error("Separator must be either ',' or '.' β€” not whatever creative mess you just passed.");
7
- }
8
-
9
- this.currency = currency;
10
- this.separator = separator;
11
- this.useSymbol = useSymbol;
12
- this.fixIt();
13
- }
14
-
15
- fixIt() {
16
- this.formatter = new Intl.NumberFormat("en-US", {
17
- style: "currency",
18
- currency: this.currency,
19
- minimumFractionDigits: 2,
20
- });
21
- }
22
-
23
- swapMoney(newCurrency) {
24
- if (typeof newCurrency !== "string" || newCurrency.length !== 3) {
25
- throw new Error("Nice try. Use a real 3-letter currency code.");
26
- }
27
- this.currency = newCurrency.toUpperCase();
28
- this.fixIt();
29
- }
30
-
31
- useWhat(symbol = true) {
32
- this.useSymbol = symbol;
33
- }
34
-
35
- makeItPretty(amount) {
36
- if (typeof amount !== "number") {
37
- throw new Error("Oh, so now we're formatting non-numbers? Genius.");
38
- }
39
-
40
- let formatted = this.formatter.format(amount);
41
-
42
- if (this.separator === ".") {
43
- formatted = formatted.replace(/,/g, ".").replace(/\./g, ",");
44
- }
45
-
46
- if (!this.useSymbol) {
47
- let symbol = currencySymbols.getSymbol(this.currency) || "";
48
- formatted = formatted.replace(symbol, this.currency);
49
- }
50
-
51
- return formatted;
52
- }
53
-
54
- whatNow() {
55
- return this.currency;
56
- }
57
- }
58
-
59
- let instance = null;
60
-
61
- function makeItRain(currency = "USD", separator = ",", useSymbol = true) {
62
- if (!instance) {
63
- instance = new MoneyFormatter(currency, separator, useSymbol);
64
- }
65
- return instance;
66
- }
67
-
68
- module.exports = makeItRain;
1
+ const currencySymbols = require("currency-symbol-map");
2
+
3
+ class MoneyFormatter {
4
+ constructor(currency = "USD", separator = ",", useSymbol = true) {
5
+ if (![".", ","].includes(separator)) {
6
+ throw new Error("Separator must be either ',' or '.' β€” not whatever creative mess you just passed.");
7
+ }
8
+
9
+ this.currency = currency;
10
+ this.separator = separator;
11
+ this.useSymbol = useSymbol;
12
+ this.fixIt();
13
+ }
14
+
15
+ fixIt() {
16
+ this.formatter = new Intl.NumberFormat("en-US", {
17
+ style: "currency",
18
+ currency: this.currency,
19
+ minimumFractionDigits: 2,
20
+ });
21
+ }
22
+
23
+ swapMoney(newCurrency) {
24
+ if (typeof newCurrency !== "string" || newCurrency.length !== 3) {
25
+ throw new Error("Nice try. Use a real 3-letter currency code.");
26
+ }
27
+ this.currency = newCurrency.toUpperCase();
28
+ this.fixIt();
29
+ }
30
+
31
+ useWhat(symbol = true) {
32
+ this.useSymbol = symbol;
33
+ }
34
+
35
+ makeItPretty(amount) {
36
+ if (typeof amount !== "number") {
37
+ throw new Error("Oh, so now we're formatting non-numbers? Genius.");
38
+ }
39
+
40
+ let formatted = this.formatter.format(amount);
41
+
42
+ if (this.separator === ".") {
43
+ formatted = formatted.replace(/[,.]/g, c => (c === "," ? "." : ","));
44
+ }
45
+
46
+ if (!this.useSymbol) {
47
+ let symbol = currencySymbols.getSymbol(this.currency) || "";
48
+ formatted = formatted.replace(symbol, this.currency);
49
+ }
50
+
51
+ return formatted;
52
+ }
53
+
54
+ whatNow() {
55
+ return this.currency;
56
+ }
57
+ }
58
+
59
+ let instance = null;
60
+
61
+ function makeItRain(currency = "USD", separator = ",", useSymbol = true) {
62
+ if (!instance) {
63
+ instance = new MoneyFormatter(currency, separator, useSymbol);
64
+ }
65
+ return instance;
66
+ }
67
+
68
+ module.exports = makeItRain;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "make-it-rain",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Because who formats money manually like a peasant?",
5
5
  "main": "index.js",
6
6
  "bin": {