@glister/currency-utils 1.0.0 → 1.0.2
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.
- package/README.md +22 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ formatPercent(0.075); // 7.5%
|
|
|
46
46
|
|
|
47
47
|
## Project-level Configuration
|
|
48
48
|
|
|
49
|
-
You can configure the default currency and locale **once per project**.
|
|
49
|
+
You can configure the default currency and locale **once per project in your main entrypoint: app.ts main.tsx main.jsx main.js. etc**.
|
|
50
50
|
|
|
51
51
|
```ts
|
|
52
52
|
import { setCurrencyConfig } from '@glister/currency-utils';
|
|
@@ -56,8 +56,29 @@ setCurrencyConfig({
|
|
|
56
56
|
locale: 'en-NG',
|
|
57
57
|
});
|
|
58
58
|
```
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
### On the Next.js codebase
|
|
62
|
+
|
|
63
|
+
Call `setCurrencyConfig` inside a client component or provider:
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
'use client';
|
|
67
|
+
|
|
68
|
+
import { useEffect } from 'react';
|
|
69
|
+
import { setCurrencyConfig } from '@glister/currency-utils';
|
|
70
|
+
|
|
71
|
+
useEffect(() => {
|
|
72
|
+
setCurrencyConfig({ currency: 'NGN', locale: 'en-NG' });
|
|
73
|
+
}, []);
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
59
77
|
|
|
60
78
|
After this, **all formatters automatically respect the config**.
|
|
79
|
+
* Note!: NGN & en-NG is just an example which is Nigeria Currency and English.
|
|
80
|
+
|
|
81
|
+
---
|
|
61
82
|
|
|
62
83
|
```ts
|
|
63
84
|
formatCurrency(1000); // ₦1,000.00
|