Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a8ce248

Browse files
committed
updating readme md and other small fix with currency locales
1 parent 28ef6e0 commit a8ce248

File tree

3 files changed

+26
-10
lines changed

3 files changed

+26
-10
lines changed

‎README.md‎

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,38 @@ $ npm install js-utility-functions --save
66

77
```
88

9-
## Availble functions
9+
## Available functions
1010

11-
-> CamelCase Characters in a string
11+
* CamelCase Characters in a string
12+
* Currency Formatter
1213

1314

1415
```Javascript
1516

16-
const CamelCaseString = require('js-utility-functions');
17-
1817
// ES 2015
1918
import { CamelCaseString } from 'js-utility-functions';
2019

2120
const formattedText = CamelCaseString('hello world');
2221

2322
console.log(formattedText);
2423

25-
// Hello World
24+
// Output: Hello World
25+
26+
- - - -
27+
28+
import { LocalCurrencyFormat } from 'js-utility-functions';
29+
30+
const formattedCurrency = LocalCurrencyFormat('10000', 'en-IN');
31+
32+
// You can pass first argument the money or amount you want to format.
33+
// Second argument you can pass the locales more check here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toLocaleString
34+
35+
console.log(formattedCurrency);
36+
37+
// Output: 10,000
38+
39+
40+
41+
2642

2743
```

‎src/index.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ export const CamelCaseString = (data) => {
66

77
export const LocalCurrencyFormat = (amount, formatIn) => {
88
const price = Number(amount);
9-
return price.toLocaleString(`en-${formatIn}`, { maximumFractionDigits: 0, currency: 'INR'});
9+
return price.toLocaleString(`${formatIn}`, { maximumFractionDigits: 0, currency: 'INR'});
1010
}

‎src/index.test.js‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ test('Capitalize First Character after Space', () => (
1212
));
1313

1414
test('Get Currency Format in INR', () => (
15-
expect(LocalCurrencyFormat('100', 'IN')).toBe('100')
15+
expect(LocalCurrencyFormat('100', 'en-IN')).toBe('100')
1616
));
1717

1818
test('Get Currency Format in INR', () => (
19-
expect(LocalCurrencyFormat('10000', 'IN')).toBe('10,000')
19+
expect(LocalCurrencyFormat('10000', 'en-IN')).toBe('10,000')
2020
));
2121

2222
test('Get Currency Format in INR', () => (
23-
expect(LocalCurrencyFormat('1000000', 'IN')).toBe('10,00,000')
23+
expect(LocalCurrencyFormat('1000000', 'en-IN')).toBe('10,00,000')
2424
));
2525

2626
test('Get Currency Format in USD', () => (
27-
expect(LocalCurrencyFormat('1000000', 'US')).toBe('1,000,000')
27+
expect(LocalCurrencyFormat('1000000', 'en-US')).toBe('1,000,000')
2828
));

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /