@formatjs/intl-durationformat 0.10.11 → 0.10.13

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/polyfill.js CHANGED
@@ -178,12 +178,28 @@ const strategies = {
178
178
  };
179
179
  //#endregion
180
180
  //#region packages/ecma402-abstract/utils.js
181
+ function defineProperty(target, name, { value }) {
182
+ Object.defineProperty(target, name, {
183
+ configurable: true,
184
+ enumerable: false,
185
+ writable: true,
186
+ value
187
+ });
188
+ }
189
+ function ensureIntl() {
190
+ if (typeof Intl === "undefined") Object.defineProperty(globalThis, "Intl", {
191
+ configurable: true,
192
+ enumerable: false,
193
+ writable: true,
194
+ value: {}
195
+ });
196
+ return Intl;
197
+ }
181
198
  function invariant$2(condition, message, Err = Error) {
182
199
  if (!condition) throw new Err(message);
183
200
  }
184
201
  const createMemoizedNumberFormat = memoize((...args) => new Intl.NumberFormat(...args), { strategy: strategies.variadic });
185
202
  memoize((...args) => new Intl.PluralRules(...args), { strategy: strategies.variadic });
186
- memoize((...args) => new Intl.Locale(...args), { strategy: strategies.variadic });
187
203
  const createMemoizedListFormat = memoize((...args) => new Intl.ListFormat(...args), { strategy: strategies.variadic });
188
204
  //#endregion
189
205
  //#region packages/ecma402-abstract/DurationFormat/GetDurationUnitOptions.js
@@ -1721,11 +1737,8 @@ function shouldPolyfill() {
1721
1737
  }
1722
1738
  //#endregion
1723
1739
  //#region packages/intl-durationformat/polyfill.ts
1724
- if (typeof Intl === "undefined") {
1725
- if (typeof window !== "undefined") Object.defineProperty(window, "Intl", { value: {} });
1726
- else if (typeof global !== "undefined") Object.defineProperty(global, "Intl", { value: {} });
1727
- }
1728
- if (shouldPolyfill()) Object.defineProperty(Intl, "DurationFormat", { value: DurationFormat });
1740
+ const intl = ensureIntl();
1741
+ if (shouldPolyfill()) defineProperty(intl, "DurationFormat", { value: DurationFormat });
1729
1742
  //#endregion
1730
1743
 
1731
1744
  //# sourceMappingURL=polyfill.js.map