Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sumup/intl

Package Overview
Dependencies
Maintainers
19
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sumup/intl - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0

8

dist/cjs/base.js

@@ -44,3 +44,3 @@ "use strict";

}
if (!intl_1.isIntlSupported) {
if (!intl_1.isNumberFormatSupported) {
return "" + value;

@@ -60,4 +60,3 @@ }

}
if (!intl_1.isIntlSupported ||
typeof Intl.NumberFormat.prototype.formatToParts === 'undefined') {
if (!intl_1.isNumberFormatToPartsSupported) {
return [{ type: 'integer', value: value.toString() }];

@@ -82,4 +81,3 @@ }

}
if (!intl_1.isIntlSupported ||
typeof Intl.NumberFormat.prototype.formatToParts === 'undefined') {
if (!intl_1.isNumberFormatToPartsSupported) {
return null;

@@ -86,0 +84,0 @@ }

@@ -15,3 +15,3 @@ /**

*/
export { isIntlSupported } from './lib/intl';
export { isNumberFormatSupported, isNumberFormatToPartsSupported, isIntlSupported, } from './lib/intl';
export { CURRENCIES } from './data/currencies';

@@ -18,0 +18,0 @@ /**

@@ -22,2 +22,4 @@ "use strict";

var intl_1 = require("./lib/intl");
Object.defineProperty(exports, "isNumberFormatSupported", { enumerable: true, get: function () { return intl_1.isNumberFormatSupported; } });
Object.defineProperty(exports, "isNumberFormatToPartsSupported", { enumerable: true, get: function () { return intl_1.isNumberFormatToPartsSupported; } });
Object.defineProperty(exports, "isIntlSupported", { enumerable: true, get: function () { return intl_1.isIntlSupported; } });

@@ -24,0 +26,0 @@ var currencies_2 = require("./data/currencies");

@@ -17,6 +17,17 @@ /**

/**
* Whether the `Intl` and `Intl.NumberFormat` APIs are supported by the runtime.
* Whether the `Intl` and `Intl.NumberFormat` APIs
* are supported by the runtime.
*/
export declare const isNumberFormatSupported: boolean;
/**
* Whether the `Intl`, `Intl.NumberFormat`, and
* `Intl.NumberFormat.formatToParts` APIs are supported by the runtime.
*/
export declare const isNumberFormatToPartsSupported: boolean;
/**
* @deprecated Whether the `Intl` and `Intl.NumberFormat` APIs
* are supported by the runtime.
*/
export declare const isIntlSupported: boolean;
export declare const getNumberFormat: (locales?: Locale | Locale[], options?: Intl.NumberFormatOptions) => Intl.NumberFormat;
export declare function resolveLocale(locales?: Locale | Locale[]): Locale | Locale[];

@@ -20,8 +20,43 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveLocale = exports.getNumberFormat = exports.isIntlSupported = void 0;
exports.resolveLocale = exports.getNumberFormat = exports.isIntlSupported = exports.isNumberFormatToPartsSupported = exports.isNumberFormatSupported = void 0;
var intl_format_cache_1 = __importDefault(require("intl-format-cache"));
/**
* Whether the `Intl` and `Intl.NumberFormat` APIs are supported by the runtime.
* Whether the `Intl` and `Intl.NumberFormat` APIs
* are supported by the runtime.
*/
exports.isIntlSupported = typeof Intl !== 'undefined' && typeof Intl.NumberFormat !== 'undefined';
exports.isNumberFormatSupported = (function () {
try {
return (typeof Intl !== 'undefined' && typeof Intl.NumberFormat !== 'undefined');
}
catch (error) {
return false;
}
})();
/**
* Whether the `Intl`, `Intl.NumberFormat`, and
* `Intl.NumberFormat.formatToParts` APIs are supported by the runtime.
*/
exports.isNumberFormatToPartsSupported = (function () {
try {
return typeof Intl.NumberFormat.prototype.formatToParts !== 'undefined';
}
catch (error) {
return false;
}
})();
/**
* @deprecated Whether the `Intl` and `Intl.NumberFormat` APIs
* are supported by the runtime.
*/
exports.isIntlSupported = (function () {
if (process.env.NODE_ENV !== 'production') {
// eslint-disable-next-line no-console
console.warn([
'DEPRECATED: isIntlSupported has been replaced',
'by isNumberFormatSupported & isNumberFormatToPartsSupported',
'and will be removed in the next major version.',
].join(' '));
}
return exports.isNumberFormatSupported;
})();
exports.getNumberFormat = intl_format_cache_1.default(Intl.NumberFormat);

@@ -28,0 +63,0 @@ function resolveLocale(locales) {

@@ -15,7 +15,7 @@ /**

*/
import { isIntlSupported, getNumberFormat } from './lib/intl';
import { isNumberFormatSupported, isNumberFormatToPartsSupported, getNumberFormat, } from './lib/intl';
import { findIndex } from './lib/findIndex';
export function formatFactory(getOptions) {
return (value, locales, ...args) => {
if (!isIntlSupported) {
if (!isNumberFormatSupported) {
return `${value}`;

@@ -30,4 +30,3 @@ }

return (value, locales, ...args) => {
if (!isIntlSupported ||
typeof Intl.NumberFormat.prototype.formatToParts === 'undefined') {
if (!isNumberFormatToPartsSupported) {
return [{ type: 'integer', value: value.toString() }];

@@ -47,4 +46,3 @@ }

return (locales, ...args) => {
if (!isIntlSupported ||
typeof Intl.NumberFormat.prototype.formatToParts === 'undefined') {
if (!isNumberFormatToPartsSupported) {
return null;

@@ -51,0 +49,0 @@ }

@@ -15,3 +15,3 @@ /**

*/
export { isIntlSupported } from './lib/intl';
export { isNumberFormatSupported, isNumberFormatToPartsSupported, isIntlSupported, } from './lib/intl';
export { CURRENCIES } from './data/currencies';

@@ -18,0 +18,0 @@ /**

@@ -18,3 +18,3 @@ /**

import { getCurrencyOptions } from './lib/currencies';
export { isIntlSupported } from './lib/intl';
export { isNumberFormatSupported, isNumberFormatToPartsSupported, isIntlSupported, } from './lib/intl';
export { CURRENCIES } from './data/currencies';

@@ -21,0 +21,0 @@ /**

@@ -17,6 +17,17 @@ /**

/**
* Whether the `Intl` and `Intl.NumberFormat` APIs are supported by the runtime.
* Whether the `Intl` and `Intl.NumberFormat` APIs
* are supported by the runtime.
*/
export declare const isNumberFormatSupported: boolean;
/**
* Whether the `Intl`, `Intl.NumberFormat`, and
* `Intl.NumberFormat.formatToParts` APIs are supported by the runtime.
*/
export declare const isNumberFormatToPartsSupported: boolean;
/**
* @deprecated Whether the `Intl` and `Intl.NumberFormat` APIs
* are supported by the runtime.
*/
export declare const isIntlSupported: boolean;
export declare const getNumberFormat: (locales?: Locale | Locale[], options?: Intl.NumberFormatOptions) => Intl.NumberFormat;
export declare function resolveLocale(locales?: Locale | Locale[]): Locale | Locale[];

@@ -17,5 +17,40 @@ /**

/**
* Whether the `Intl` and `Intl.NumberFormat` APIs are supported by the runtime.
* Whether the `Intl` and `Intl.NumberFormat` APIs
* are supported by the runtime.
*/
export const isIntlSupported = typeof Intl !== 'undefined' && typeof Intl.NumberFormat !== 'undefined';
export const isNumberFormatSupported = (() => {
try {
return (typeof Intl !== 'undefined' && typeof Intl.NumberFormat !== 'undefined');
}
catch (error) {
return false;
}
})();
/**
* Whether the `Intl`, `Intl.NumberFormat`, and
* `Intl.NumberFormat.formatToParts` APIs are supported by the runtime.
*/
export const isNumberFormatToPartsSupported = (() => {
try {
return typeof Intl.NumberFormat.prototype.formatToParts !== 'undefined';
}
catch (error) {
return false;
}
})();
/**
* @deprecated Whether the `Intl` and `Intl.NumberFormat` APIs
* are supported by the runtime.
*/
export const isIntlSupported = (() => {
if (process.env.NODE_ENV !== 'production') {
// eslint-disable-next-line no-console
console.warn([
'DEPRECATED: isIntlSupported has been replaced',
'by isNumberFormatSupported & isNumberFormatToPartsSupported',
'and will be removed in the next major version.',
].join(' '));
}
return isNumberFormatSupported;
})();
export const getNumberFormat = memoizeFormatConstructor(Intl.NumberFormat);

@@ -22,0 +57,0 @@ export function resolveLocale(locales) {

{
"name": "@sumup/intl",
"version": "1.0.3",
"version": "1.1.0",
"description": "Format numbers and currency values for any locale with the ECMAScript Internationalization API",

@@ -5,0 +5,0 @@ "repository": "git@github.com:sumup-oss/intl-js.git",

@@ -317,3 +317,3 @@ <div align="center">

#### `isIntlSupported`
#### `isNumberFormatSupported`

@@ -323,5 +323,13 @@ Whether the `Intl` and `Intl.NumberFormat` APIs are supported by the runtime.

```ts
const isIntlSupported: boolean;
const isNumberFormatSupported: boolean;
```
#### `isNumberFormatToPartsSupported`
Whether the `Intl`, `Intl.NumberFormat`, and `Intl.NumberFormat.formatToParts` APIs are supported by the runtime.
```ts
const isNumberFormatToPartsSupported: boolean;
```
#### `CURRENCIES`

@@ -328,0 +336,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc