@formatjs/ecma376 0.3.16 → 0.4.1

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/index.js CHANGED
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateNumFmtPattern = generateNumFmtPattern;
4
1
  var NUMBER = 10000;
5
2
  var ALL_ZEROS = /^0+$/;
6
3
  function partToPattern(part) {
@@ -20,7 +17,7 @@ function partToPattern(part) {
20
17
  return '#';
21
18
  }
22
19
  }
23
- function generateNumFmtPattern(locales, opts) {
20
+ export function generateNumFmtPattern(locales, opts) {
24
21
  var nf = new Intl.NumberFormat(locales, opts);
25
22
  var positivePattern = nf.formatToParts(NUMBER).reduce(function (pattern, part) {
26
23
  return pattern + partToPattern(part);
package/package.json CHANGED
@@ -1,9 +1,14 @@
1
1
  {
2
2
  "name": "@formatjs/ecma376",
3
3
  "description": "generate ecma376 numFmt in different locales & currencies",
4
- "version": "0.3.16",
4
+ "version": "0.4.1",
5
5
  "license": "ISC",
6
6
  "author": "Long Ho <holevietlong@gmail.com>",
7
+ "type": "module",
8
+ "types": "index.d.ts",
9
+ "exports": {
10
+ ".": "./index.js"
11
+ },
7
12
  "dependencies": {
8
13
  "tslib": "^2.8.0"
9
14
  },
@@ -15,8 +20,6 @@
15
20
  "intl",
16
21
  "numFmt"
17
22
  ],
18
- "main": "index.js",
19
- "module": "lib/index.js",
20
23
  "repository": "formatjs/formatjs.git",
21
24
  "scripts": {
22
25
  "test": "echo \"Error: no test specified\" && exit 1"
package/lib/index.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function generateNumFmtPattern(locales: string | string[], opts: Intl.NumberFormatOptions): string;
package/lib/index.js DELETED
@@ -1,29 +0,0 @@
1
- var NUMBER = 10000;
2
- var ALL_ZEROS = /^0+$/;
3
- function partToPattern(part) {
4
- switch (part.type) {
5
- default:
6
- return part.value;
7
- case 'currency':
8
- case 'compact':
9
- return "\"".concat(part.value, "\"");
10
- case 'integer':
11
- if (ALL_ZEROS.test(part.value)) {
12
- return part.value
13
- .split('')
14
- .map(function (_, i, arr) { return (i === arr.length - 1 ? '0' : '#'); })
15
- .join('');
16
- }
17
- return '#';
18
- }
19
- }
20
- export function generateNumFmtPattern(locales, opts) {
21
- var nf = new Intl.NumberFormat(locales, opts);
22
- var positivePattern = nf.formatToParts(NUMBER).reduce(function (pattern, part) {
23
- return pattern + partToPattern(part);
24
- }, '');
25
- var negativePattern = nf.formatToParts(-NUMBER).reduce(function (pattern, part) {
26
- return pattern + partToPattern(part);
27
- }, '');
28
- return positivePattern + ';' + negativePattern;
29
- }