geld 2.0.0 → 3.0.0

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 CHANGED
@@ -2,13 +2,12 @@
2
2
 
3
3
  > geld is a minimal currency formatter.
4
4
 
5
- ![Update Status](https://img.shields.io/david/dev/dreamseer/geld.svg)
6
- ![GitHub Workflow Status](https://img.shields.io/github/workflow/status/dreamseer/geld/default/main)
7
- [![Coverage Status](https://coveralls.io/repos/github/Dreamseer/geld/badge.svg?branch=main)](https://coveralls.io/github/Dreamseer/geld?branch=main)
5
+ [![Test](https://github.com/mrcgrtz/geld/actions/workflows/test.yml/badge.svg)](https://github.com/mrcgrtz/geld/actions/workflows/test.yml)
6
+ [![Coverage Status](https://coveralls.io/repos/github/mrcgrtz/geld/badge.svg?branch=main)](https://coveralls.io/github/mrcgrtz/geld?branch=main)
8
7
  [![Install size](https://packagephobia.now.sh/badge?p=geld)](https://packagephobia.now.sh/result?p=geld)
9
8
  [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)
10
- [![Flow](https://img.shields.io/npm/types/geld)](https://flow.org/)
11
- [![MIT license](https://img.shields.io/github/license/dreamseer/geld.svg)](https://github.com/Dreamseer/geld/blob/main/LICENSE.md)
9
+ [![Types](https://img.shields.io/npm/types/geld)](https://www.typescriptlang.org/)
10
+ [![MIT license](https://img.shields.io/github/license/mrcgrtz/geld.svg)](https://github.com/mrcgrtz/geld/blob/main/LICENSE.md)
12
11
 
13
12
  ## Install
14
13
 
@@ -27,7 +26,7 @@ yarn add geld
27
26
  ## Usage
28
27
 
29
28
  ```js
30
- const geld = require('geld');
29
+ import geld from 'geld';
31
30
 
32
31
  const price1 = geld(42.23);
33
32
  console.log(price1); // => '42,23 €'
@@ -108,7 +107,7 @@ geld, not GELD or Geld. Pronounced [/ɡɛlt/](https://en.wiktionary.org/wiki/Gel
108
107
 
109
108
  ## Related
110
109
 
111
- * [geld-cli](https://github.com/dreamseer/geld-cli) is a CLI for geld.
110
+ * [geld-cli](https://github.com/mrcgrtz/geld-cli) is a CLI for geld.
112
111
  * [`Number.toLocaleString()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString) provides native currency formatting.
113
112
  * [currency-formatter](https://github.com/smirzaei/currency-formatter) is a more powerful formatter.
114
113
 
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  declare namespace Geld {
2
- interface Options {
2
+ type Options = {
3
3
  currency?: string;
4
4
  currencyPosition?: 'before' | 'after';
5
5
  decimals?: number;
@@ -7,7 +7,7 @@ declare namespace Geld {
7
7
  orderSeparator?: string;
8
8
  zeroDecimals?: string;
9
9
  space?: string;
10
- }
10
+ };
11
11
  }
12
12
 
13
13
  declare function geld(
package/index.js CHANGED
@@ -21,9 +21,9 @@ const geld = (value, options) => {
21
21
  const fnums = parts[0];
22
22
  let dec = parts[1] ? config.decimalSeparator + parts[1] : '';
23
23
 
24
- let curr = '';
24
+ let currency = '';
25
25
  if (config.currency) {
26
- curr = config.currencyPosition === 'before'
26
+ currency = config.currencyPosition === 'before'
27
27
  ? config.currency + config.space
28
28
  : config.space + config.currency;
29
29
  }
@@ -34,12 +34,12 @@ const geld = (value, options) => {
34
34
  }
35
35
 
36
36
  const formattedValue
37
- = fnums.replace(/(?<num>\d)(?=(?:\d{3})+$)/g, '$1' + config.orderSeparator) + dec;
37
+ = fnums.replaceAll(/(?<num>\d)(?=(?:\d{3})+$)/g, '$1' + config.orderSeparator) + dec;
38
38
  return config.currencyPosition === 'before'
39
39
  // As in '$ 123'
40
- ? curr + formattedValue
40
+ ? currency + formattedValue
41
41
  // As in '123 €'
42
- : formattedValue + curr;
42
+ : formattedValue + currency;
43
43
  };
44
44
 
45
45
  export default geld;
package/package.json CHANGED
@@ -1,26 +1,34 @@
1
1
  {
2
2
  "name": "geld",
3
- "version": "2.0.0",
3
+ "version": "3.0.0",
4
4
  "description": "geld is a minimal currency formatter.",
5
5
  "license": "MIT",
6
- "repository": {
7
- "type": "git",
8
- "url": "https://github.com/Dreamseer/geld.git"
9
- },
10
- "funding": {
11
- "type": "kofi",
12
- "url": "https://ko-fi.com/dreamseer"
13
- },
6
+ "repository": "github:mrcgrtz/geld",
7
+ "funding": [
8
+ {
9
+ "type": "kofi",
10
+ "url": "https://ko-fi.com/mrcgrtz"
11
+ },
12
+ {
13
+ "type": "liberapay",
14
+ "url": "https://liberapay.com/mrcgrtz"
15
+ }
16
+ ],
14
17
  "author": {
15
18
  "name": "Marc Görtz",
16
19
  "email": "git@marcgoertz.de",
17
20
  "url": "https://marcgoertz.de/"
18
21
  },
19
22
  "engines": {
20
- "node": ">=16"
23
+ "node": ">=18"
21
24
  },
22
25
  "main": "index.js",
23
26
  "type": "module",
27
+ "scripts": {
28
+ "coverage": "c8 report --reporter=lcov",
29
+ "prepare": "husky",
30
+ "test": "xo && tsd && c8 ava"
31
+ },
24
32
  "files": [
25
33
  "index.js",
26
34
  "index.d.ts"
@@ -29,6 +37,17 @@
29
37
  "currency",
30
38
  "format"
31
39
  ],
40
+ "devDependencies": {
41
+ "ava": "^6.0.1",
42
+ "c8": "^9.1.0",
43
+ "husky": "^9.0.9",
44
+ "lint-staged": "^15.0.2",
45
+ "tsd": "^0.30.1",
46
+ "xo": "^0.57.0"
47
+ },
48
+ "lint-staged": {
49
+ "*.js": "xo --fix"
50
+ },
32
51
  "tsd": {
33
52
  "directory": "test"
34
53
  }