@formatjs/intl-durationformat 0.2.4 → 0.4.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.
@@ -1,4 +1,4 @@
1
- import { invariant } from '@formatjs/ecma402-abstract';
1
+ import { createMemoizedListFormat, createMemoizedNumberFormat, invariant, } from '@formatjs/ecma402-abstract';
2
2
  import { TABLE_2 } from '../constants';
3
3
  import { DurationFormat } from '../core';
4
4
  import { getInternalSlots } from '../get_internal_slots';
@@ -69,7 +69,7 @@ export function PartitionDurationFormatPattern(df, duration) {
69
69
  nfOpts.unit = numberFormatUnit;
70
70
  nfOpts.unitDisplay = style;
71
71
  }
72
- var nf = new Intl.NumberFormat(internalSlots.locale, nfOpts);
72
+ var nf = createMemoizedNumberFormat(internalSlots.locale, nfOpts);
73
73
  var list_1;
74
74
  if (!separated) {
75
75
  list_1 = [];
@@ -111,7 +111,7 @@ export function PartitionDurationFormatPattern(df, duration) {
111
111
  listStyle = 'short';
112
112
  }
113
113
  lfOpts.style = listStyle;
114
- var lf = new Intl.ListFormat(internalSlots.locale, lfOpts);
114
+ var lf = createMemoizedListFormat(internalSlots.locale, lfOpts);
115
115
  var strings = [];
116
116
  for (var _i = 0, result_1 = result; _i < result_1.length; _i++) {
117
117
  var parts = result_1[_i];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@formatjs/intl-durationformat",
3
- "version": "0.2.4",
3
+ "version": "0.4.0",
4
4
  "description": "Intl.DurationFormat polyfill",
5
5
  "keywords": [
6
6
  "intl",
@@ -25,8 +25,8 @@
25
25
  "url": "https://github.com/formatjs/formatjs/issues"
26
26
  },
27
27
  "dependencies": {
28
- "tslib": "^2.4.0",
29
- "@formatjs/intl-localematcher": "0.5.4",
30
- "@formatjs/ecma402-abstract": "2.0.0"
28
+ "tslib": "^2.7.0",
29
+ "@formatjs/intl-localematcher": "0.5.5",
30
+ "@formatjs/ecma402-abstract": "2.2.0"
31
31
  }
32
32
  }
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.shouldPolyfill = void 0;
3
+ exports.shouldPolyfill = shouldPolyfill;
4
4
  function shouldPolyfill() {
5
5
  return typeof Intl === 'undefined' || !('DurationFormat' in Intl);
6
6
  }
7
- exports.shouldPolyfill = shouldPolyfill;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DurationRecordSign = void 0;
3
+ exports.DurationRecordSign = DurationRecordSign;
4
4
  var constants_1 = require("../constants");
5
5
  function DurationRecordSign(record) {
6
6
  for (var _i = 0, TABLE_1_1 = constants_1.TABLE_1; _i < TABLE_1_1.length; _i++) {
@@ -14,4 +14,3 @@ function DurationRecordSign(record) {
14
14
  }
15
15
  return 0;
16
16
  }
17
- exports.DurationRecordSign = DurationRecordSign;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.GetDurationUnitOptions = void 0;
3
+ exports.GetDurationUnitOptions = GetDurationUnitOptions;
4
4
  var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
5
5
  function GetDurationUnitOptions(unit, options, baseStyle, stylesList, digitalBase, prevStyle) {
6
6
  var style = (0, ecma402_abstract_1.GetOption)(options, unit, 'string', stylesList, undefined);
@@ -44,4 +44,3 @@ function GetDurationUnitOptions(unit, options, baseStyle, stylesList, digitalBas
44
44
  display: display,
45
45
  };
46
46
  }
47
- exports.GetDurationUnitOptions = GetDurationUnitOptions;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.IsValidDurationRecord = void 0;
3
+ exports.IsValidDurationRecord = IsValidDurationRecord;
4
4
  var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
5
5
  var constants_1 = require("../constants");
6
6
  var DurationRecordSign_1 = require("./DurationRecordSign");
@@ -19,4 +19,3 @@ function IsValidDurationRecord(record) {
19
19
  }
20
20
  return true;
21
21
  }
22
- exports.IsValidDurationRecord = IsValidDurationRecord;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PartitionDurationFormatPattern = void 0;
3
+ exports.PartitionDurationFormatPattern = PartitionDurationFormatPattern;
4
4
  var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
5
5
  var constants_1 = require("../constants");
6
6
  var core_1 = require("../core");
@@ -72,7 +72,7 @@ function PartitionDurationFormatPattern(df, duration) {
72
72
  nfOpts.unit = numberFormatUnit;
73
73
  nfOpts.unitDisplay = style;
74
74
  }
75
- var nf = new Intl.NumberFormat(internalSlots.locale, nfOpts);
75
+ var nf = (0, ecma402_abstract_1.createMemoizedNumberFormat)(internalSlots.locale, nfOpts);
76
76
  var list_1;
77
77
  if (!separated) {
78
78
  list_1 = [];
@@ -114,7 +114,7 @@ function PartitionDurationFormatPattern(df, duration) {
114
114
  listStyle = 'short';
115
115
  }
116
116
  lfOpts.style = listStyle;
117
- var lf = new Intl.ListFormat(internalSlots.locale, lfOpts);
117
+ var lf = (0, ecma402_abstract_1.createMemoizedListFormat)(internalSlots.locale, lfOpts);
118
118
  var strings = [];
119
119
  for (var _i = 0, result_1 = result; _i < result_1.length; _i++) {
120
120
  var parts = result_1[_i];
@@ -150,4 +150,3 @@ function PartitionDurationFormatPattern(df, duration) {
150
150
  }
151
151
  return flattened;
152
152
  }
153
- exports.PartitionDurationFormatPattern = PartitionDurationFormatPattern;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ToDurationRecord = void 0;
3
+ exports.ToDurationRecord = ToDurationRecord;
4
4
  var IsValidDurationRecord_1 = require("./IsValidDurationRecord");
5
5
  var ToIntegerIfIntegral_1 = require("./ToIntegerIfIntegral");
6
6
  function ToDurationRecord(input) {
@@ -69,4 +69,3 @@ function ToDurationRecord(input) {
69
69
  }
70
70
  return result;
71
71
  }
72
- exports.ToDurationRecord = ToDurationRecord;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ToIntegerIfIntegral = void 0;
3
+ exports.ToIntegerIfIntegral = ToIntegerIfIntegral;
4
4
  var ecma402_abstract_1 = require("@formatjs/ecma402-abstract");
5
5
  function ToIntegerIfIntegral(arg) {
6
6
  var number = (0, ecma402_abstract_1.ToNumber)(arg);
@@ -9,4 +9,3 @@ function ToIntegerIfIntegral(arg) {
9
9
  }
10
10
  return number;
11
11
  }
12
- exports.ToIntegerIfIntegral = ToIntegerIfIntegral;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getInternalSlots = void 0;
3
+ exports.getInternalSlots = getInternalSlots;
4
4
  var internalSlotMap = new WeakMap();
5
5
  function getInternalSlots(x) {
6
6
  var internalSlots = internalSlotMap.get(x);
@@ -10,4 +10,3 @@ function getInternalSlots(x) {
10
10
  }
11
11
  return internalSlots;
12
12
  }
13
- exports.getInternalSlots = getInternalSlots;