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.1.3 to 1.2.0

8

dist/cjs/index.js

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.resolveCurrencyFormat = exports.resolveFormat = exports.formatCurrencyToParts = exports.formatToParts = exports.formatCurrency = exports.format = void 0;
exports.resolveCurrencyFormat = exports.resolveFormat = exports.formatCurrencyToParts = exports.formatToParts = exports.formatCurrency = exports.format = exports.CURRENCIES = exports.isIntlSupported = exports.isNumberFormatToPartsSupported = exports.isNumberFormatSupported = void 0;
var base_1 = require("./base");

@@ -33,3 +33,3 @@ var numbers_1 = require("./lib/numbers");

*/
exports.format = base_1.formatFactory(numbers_1.getDecimalOptions);
exports.format = base_1.formatFactory(numbers_1.getNumberOptions);
/**

@@ -45,3 +45,3 @@ * Formats a number according to the locale in the country's official curreny

*/
exports.formatToParts = base_1.formatToPartsFactory(numbers_1.getDecimalOptions);
exports.formatToParts = base_1.formatToPartsFactory(numbers_1.getNumberOptions);
/**

@@ -55,3 +55,3 @@ * Formats a number according to the locale in the country's official curreny

*/
exports.resolveFormat = base_1.resolveFormatFactory(numbers_1.getDecimalOptions);
exports.resolveFormat = base_1.resolveFormatFactory(numbers_1.getNumberOptions);
/**

@@ -58,0 +58,0 @@ * Resolves the locale and collation options that are used to format a number

@@ -39,2 +39,6 @@ "use strict";

});
it.each(locales)('should format a unit number for %o', function (locale) {
var actual = _1.format(number, locale, { style: 'unit', unit: 'liter' });
expect(actual).toMatchSnapshot();
});
});

@@ -54,2 +58,9 @@ describe('currency', function () {

});
it.each(locales)('should format a unit number for %o', function (locale) {
var actual = _1.formatToParts(number, locale, {
style: 'unit',
unit: 'liter',
});
expect(actual).toMatchSnapshot();
});
});

@@ -56,0 +67,0 @@ describe('currency', function () {

@@ -15,5 +15,5 @@ /**

*/
import { Locale, CurrencyOptions, DecimalOptions, Currency } from '../types';
import { Locale, CurrencyFormatOptions, NumberFormatOptions, Currency } from '../types';
export declare function extractCountry(locale: string): string;
export declare function resolveCurrency(locales?: Locale | Locale[]): Currency | null;
export declare function getCurrencyOptions(locales?: Locale | Locale[], currency?: Currency, options?: Intl.NumberFormatOptions): CurrencyOptions | DecimalOptions;
export declare function getCurrencyOptions(locales?: Locale | Locale[], currency?: Currency, options?: Intl.NumberFormatOptions): CurrencyFormatOptions | NumberFormatOptions;

@@ -40,2 +40,3 @@ "use strict";

try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
return typeof Intl.NumberFormat.prototype.formatToParts !== 'undefined';

@@ -53,3 +54,3 @@ }

var memoizedIntl;
exports.memoizeIntl = function () {
var memoizeIntl = function () {
if (!memoizedIntl) {

@@ -60,2 +61,3 @@ memoizedIntl = intl_format_cache_1.default(Intl.NumberFormat);

};
exports.memoizeIntl = memoizeIntl;
function resolveLocale(locales) {

@@ -62,0 +64,0 @@ if (locales && locales.length >= 0) {

@@ -15,4 +15,4 @@ /**

*/
import { Locale, DecimalOptions } from '../types';
export declare function getDecimalOptions(locales?: Locale | Locale[], options?: Intl.NumberFormatOptions): DecimalOptions;
import { Locale, NumberFormatOptions } from '../types';
export declare function getNumberOptions(locales?: Locale | Locale[], options?: Intl.NumberFormatOptions): NumberFormatOptions;
export declare function normalize(value?: string): number;

@@ -28,7 +28,7 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.normalize = exports.getDecimalOptions = void 0;
function getDecimalOptions(locales, options) {
return __assign(__assign({}, options), { style: 'decimal' });
exports.normalize = exports.getNumberOptions = void 0;
function getNumberOptions(locales, options) {
return __assign({ style: 'decimal' }, options);
}
exports.getDecimalOptions = getDecimalOptions;
exports.getNumberOptions = getNumberOptions;
function normalize(value) {

@@ -35,0 +35,0 @@ if (!value || !value.length) {

@@ -23,9 +23,7 @@ /**

};
export interface DecimalOptions extends Intl.NumberFormatOptions {
style: 'decimal';
}
export interface CurrencyOptions extends Intl.NumberFormatOptions {
export declare type NumberFormatOptions = Intl.NumberFormatOptions;
export interface CurrencyFormatOptions extends Intl.NumberFormatOptions {
style: 'currency';
currency: Currency;
}
export declare type Options = DecimalOptions | CurrencyOptions;
export declare type Options = NumberFormatOptions | CurrencyFormatOptions;

@@ -16,3 +16,3 @@ /**

import { formatFactory, formatToPartsFactory, resolveFormatFactory, } from './base';
import { getDecimalOptions } from './lib/numbers';
import { getNumberOptions } from './lib/numbers';
import { getCurrencyOptions } from './lib/currencies';

@@ -26,3 +26,3 @@ export { isNumberFormatSupported, isNumberFormatToPartsSupported, isIntlSupported, } from './lib/intl';

*/
export const format = formatFactory(getDecimalOptions);
export const format = formatFactory(getNumberOptions);
/**

@@ -38,3 +38,3 @@ * Formats a number according to the locale in the country's official curreny

*/
export const formatToParts = formatToPartsFactory(getDecimalOptions);
export const formatToParts = formatToPartsFactory(getNumberOptions);
/**

@@ -48,3 +48,3 @@ * Formats a number according to the locale in the country's official curreny

*/
export const resolveFormat = resolveFormatFactory(getDecimalOptions);
export const resolveFormat = resolveFormatFactory(getNumberOptions);
/**

@@ -51,0 +51,0 @@ * Resolves the locale and collation options that are used to format a number

@@ -31,2 +31,6 @@ /**

});
it.each(locales)('should format a unit number for %o', (locale) => {
const actual = format(number, locale, { style: 'unit', unit: 'liter' });
expect(actual).toMatchSnapshot();
});
});

@@ -46,2 +50,9 @@ describe('currency', () => {

});
it.each(locales)('should format a unit number for %o', (locale) => {
const actual = formatToParts(number, locale, {
style: 'unit',
unit: 'liter',
});
expect(actual).toMatchSnapshot();
});
});

@@ -48,0 +59,0 @@ describe('currency', () => {

@@ -15,5 +15,5 @@ /**

*/
import { Locale, CurrencyOptions, DecimalOptions, Currency } from '../types';
import { Locale, CurrencyFormatOptions, NumberFormatOptions, Currency } from '../types';
export declare function extractCountry(locale: string): string;
export declare function resolveCurrency(locales?: Locale | Locale[]): Currency | null;
export declare function getCurrencyOptions(locales?: Locale | Locale[], currency?: Currency, options?: Intl.NumberFormatOptions): CurrencyOptions | DecimalOptions;
export declare function getCurrencyOptions(locales?: Locale | Locale[], currency?: Currency, options?: Intl.NumberFormatOptions): CurrencyFormatOptions | NumberFormatOptions;

@@ -34,2 +34,3 @@ /**

try {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
return typeof Intl.NumberFormat.prototype.formatToParts !== 'undefined';

@@ -36,0 +37,0 @@ }

@@ -15,4 +15,4 @@ /**

*/
import { Locale, DecimalOptions } from '../types';
export declare function getDecimalOptions(locales?: Locale | Locale[], options?: Intl.NumberFormatOptions): DecimalOptions;
import { Locale, NumberFormatOptions } from '../types';
export declare function getNumberOptions(locales?: Locale | Locale[], options?: Intl.NumberFormatOptions): NumberFormatOptions;
export declare function normalize(value?: string): number;

@@ -15,4 +15,4 @@ /**

*/
export function getDecimalOptions(locales, options) {
return Object.assign(Object.assign({}, options), { style: 'decimal' });
export function getNumberOptions(locales, options) {
return Object.assign({ style: 'decimal' }, options);
}

@@ -19,0 +19,0 @@ export function normalize(value) {

@@ -23,9 +23,7 @@ /**

};
export interface DecimalOptions extends Intl.NumberFormatOptions {
style: 'decimal';
}
export interface CurrencyOptions extends Intl.NumberFormatOptions {
export declare type NumberFormatOptions = Intl.NumberFormatOptions;
export interface CurrencyFormatOptions extends Intl.NumberFormatOptions {
style: 'currency';
currency: Currency;
}
export declare type Options = DecimalOptions | CurrencyOptions;
export declare type Options = NumberFormatOptions | CurrencyFormatOptions;

@@ -15,1 +15,2 @@ /**

*/
export {};
{
"name": "@sumup/intl",
"version": "1.1.3",
"version": "1.2.0",
"description": "Format numbers and currency values for any locale with the ECMAScript Internationalization API",

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

"devDependencies": {
"@sumup/foundry": "^3.0.0",
"@types/jest": "^25.2.0",
"@sumup/foundry": "^4.0.0-canary",
"@types/jest": "^26.0.15",
"audit-ci": "^3.0.0",
"jest": "^26.0.0",
"jest-extended": "^0.11.4",
"jest-junit": "^10.0.0",
"jest-junit": "^12.0.0",
"license-checker": "^25.0.1",
"ts-jest": "^26.0.0",
"typescript": "^3.7.5"
"typescript": "^4.1.3"
}
}
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