Socket
Socket
Sign inDemoInstall

@formatjs/intl-utils

Package Overview
Dependencies
Maintainers
3
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@formatjs/intl-utils - npm Package Compare versions

Comparing version 3.0.1 to 3.1.0

13

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [3.1.0](https://github.com/formatjs/formatjs/compare/@formatjs/intl-utils@3.0.1...@formatjs/intl-utils@3.1.0) (2020-05-25)
### Features
* **@formatjs/intl-utils:** Remove aliases and parentLocales ([e0e9370](https://github.com/formatjs/formatjs/commit/e0e937062514f0f776401be99b556682dd0623cc))
## [3.0.1](https://github.com/formatjs/formatjs/compare/@formatjs/intl-utils@3.0.0...@formatjs/intl-utils@3.0.1) (2020-05-23)

@@ -28,6 +39,6 @@

* Most of NumberFormat public and internal types are moved out of this package.
# [2.3.0](https://github.com/formatjs/formatjs/compare/@formatjs/intl-utils@2.2.5...@formatjs/intl-utils@2.3.0) (2020-05-16)

@@ -34,0 +45,0 @@

2

dist/index.d.ts
export { selectUnit } from './diff';
export { defaultNumberOption, getAliasesByLang, getInternalSlot, getMultiInternalSlots, getNumberOption, getOption, getParentLocalesByLang, isLiteralPart, LiteralPart, partitionPattern, setInternalSlot, setMultiInternalSlots, setNumberFormatDigitOptions, toObject, objectIs, isWellFormedCurrencyCode, toString, formatNumericToString, toRawFixed, toRawPrecision, getMagnitude, repeat, hasOwnProperty, isWellFormedUnitIdentifier, defineProperty, } from './polyfill-utils';
export { defaultNumberOption, getInternalSlot, getMultiInternalSlots, getNumberOption, getOption, isLiteralPart, LiteralPart, partitionPattern, setInternalSlot, setMultiInternalSlots, setNumberFormatDigitOptions, toObject, objectIs, isWellFormedCurrencyCode, toString, formatNumericToString, toRawFixed, toRawPrecision, getMagnitude, repeat, hasOwnProperty, isWellFormedUnitIdentifier, defineProperty, } from './polyfill-utils';
export { createResolveLocale, getLocaleHierarchy, supportedLocales, unpackData, isMissingLocaleDataError, } from './resolve-locale';

@@ -4,0 +4,0 @@ export * from './units';

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

exports.defaultNumberOption = polyfill_utils_1.defaultNumberOption;
exports.getAliasesByLang = polyfill_utils_1.getAliasesByLang;
exports.getInternalSlot = polyfill_utils_1.getInternalSlot;

@@ -16,3 +15,2 @@ exports.getMultiInternalSlots = polyfill_utils_1.getMultiInternalSlots;

exports.getOption = polyfill_utils_1.getOption;
exports.getParentLocalesByLang = polyfill_utils_1.getParentLocalesByLang;
exports.isLiteralPart = polyfill_utils_1.isLiteralPart;

@@ -19,0 +17,0 @@ exports.partitionPattern = polyfill_utils_1.partitionPattern;

@@ -38,4 +38,2 @@ import { NumberFormatDigitInternalSlots, NumberFormatDigitOptions, NumberFormatNotation, RawNumberFormatResult } from './number-types';

export declare function getNumberOption<T extends object, K extends keyof T>(options: T, property: K, minimum: number, maximum: number, fallback: number): number;
export declare function getAliasesByLang(lang: string): Record<string, string>;
export declare function getParentLocalesByLang(lang: string): Record<string, string>;
export declare function setInternalSlot<Instance extends object, Internal extends object, Field extends keyof Internal>(map: WeakMap<Instance, Internal>, pl: Instance, field: Field, value: NonNullable<Internal>[Field]): void;

@@ -42,0 +40,0 @@ export declare function setMultiInternalSlots<Instance extends object, Internal extends object, K extends keyof Internal>(map: WeakMap<Instance, Internal>, pl: Instance, props: Pick<NonNullable<Internal>, K>): void;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var aliases_1 = require("./aliases");
var parentLocales_1 = require("./parentLocales");
var invariant_1 = require("./invariant");

@@ -93,20 +91,2 @@ var units_1 = require("./units");

exports.getNumberOption = getNumberOption;
function getAliasesByLang(lang) {
return Object.keys(aliases_1.default).reduce(function (all, locale) {
if (locale.split('-')[0] === lang) {
all[locale] = aliases_1.default[locale];
}
return all;
}, {});
}
exports.getAliasesByLang = getAliasesByLang;
function getParentLocalesByLang(lang) {
return Object.keys(parentLocales_1.default).reduce(function (all, locale) {
if (locale.split('-')[0] === lang) {
all[locale] = parentLocales_1.default[locale];
}
return all;
}, {});
}
exports.getParentLocalesByLang = getParentLocalesByLang;
function setInternalSlot(map, pl, field, value) {

@@ -113,0 +93,0 @@ if (!map.get(pl)) {

@@ -13,3 +13,3 @@ import { LocaleData } from './types';

}, relevantExtensionKeys: K[], localeData: Record<string, D>) => ResolveLocaleResult;
export declare function getLocaleHierarchy(locale: string, aliases: Record<string, string>, parentLocales: Record<string, string>): string[];
export declare function getLocaleHierarchy(locale: string): string[];
export declare function supportedLocales(availableLocales: string[], requestedLocales: string[], options?: {

@@ -16,0 +16,0 @@ localeMatcher?: 'best fit' | 'lookup';

@@ -211,12 +211,4 @@ "use strict";

}
function getLocaleHierarchy(locale, aliases, parentLocales) {
function getLocaleHierarchy(locale) {
var results = [locale];
if (aliases[locale]) {
locale = aliases[locale];
results.push(locale);
}
var parentLocale = parentLocales[locale];
if (parentLocale) {
results.push(parentLocale);
}
var localeParts = locale.split('-');

@@ -270,3 +262,3 @@ for (var i = localeParts.length; i > 1; i--) {

if (reducer === void 0) { reducer = function (all, d) { return (__assign(__assign({}, all), d)); }; }
var localeHierarchy = getLocaleHierarchy(locale, localeData.aliases, localeData.parentLocales);
var localeHierarchy = getLocaleHierarchy(locale);
var dataToMerge = localeHierarchy

@@ -273,0 +265,0 @@ .map(function (l) { return localeData.data[l]; })

export declare type Locale = string;
export interface LocaleData<T> {
data: Record<Locale, T>;
aliases: Record<string, string>;
availableLocales: string[];
parentLocales: Record<string, string>;
}
//# sourceMappingURL=types.d.ts.map
export { selectUnit } from './diff';
export { defaultNumberOption, getAliasesByLang, getInternalSlot, getMultiInternalSlots, getNumberOption, getOption, getParentLocalesByLang, isLiteralPart, LiteralPart, partitionPattern, setInternalSlot, setMultiInternalSlots, setNumberFormatDigitOptions, toObject, objectIs, isWellFormedCurrencyCode, toString, formatNumericToString, toRawFixed, toRawPrecision, getMagnitude, repeat, hasOwnProperty, isWellFormedUnitIdentifier, defineProperty, } from './polyfill-utils';
export { defaultNumberOption, getInternalSlot, getMultiInternalSlots, getNumberOption, getOption, isLiteralPart, LiteralPart, partitionPattern, setInternalSlot, setMultiInternalSlots, setNumberFormatDigitOptions, toObject, objectIs, isWellFormedCurrencyCode, toString, formatNumericToString, toRawFixed, toRawPrecision, getMagnitude, repeat, hasOwnProperty, isWellFormedUnitIdentifier, defineProperty, } from './polyfill-utils';
export { createResolveLocale, getLocaleHierarchy, supportedLocales, unpackData, isMissingLocaleDataError, } from './resolve-locale';

@@ -4,0 +4,0 @@ export * from './units';

export { selectUnit } from './diff';
export { defaultNumberOption, getAliasesByLang, getInternalSlot, getMultiInternalSlots, getNumberOption, getOption, getParentLocalesByLang, isLiteralPart, partitionPattern, setInternalSlot, setMultiInternalSlots, setNumberFormatDigitOptions, toObject, objectIs, isWellFormedCurrencyCode, toString, formatNumericToString, toRawFixed, toRawPrecision, getMagnitude, repeat, hasOwnProperty, isWellFormedUnitIdentifier, defineProperty, } from './polyfill-utils';
export { defaultNumberOption, getInternalSlot, getMultiInternalSlots, getNumberOption, getOption, isLiteralPart, partitionPattern, setInternalSlot, setMultiInternalSlots, setNumberFormatDigitOptions, toObject, objectIs, isWellFormedCurrencyCode, toString, formatNumericToString, toRawFixed, toRawPrecision, getMagnitude, repeat, hasOwnProperty, isWellFormedUnitIdentifier, defineProperty, } from './polyfill-utils';
export { createResolveLocale, getLocaleHierarchy, supportedLocales, unpackData, isMissingLocaleDataError, } from './resolve-locale';

@@ -4,0 +4,0 @@ export * from './units';

@@ -113,7 +113,5 @@

export declare function getAliasesByLang(lang: string): Record<string, string>;
export declare function getInternalSlot<Instance extends object, Internal extends object, Field extends keyof Internal>(map: WeakMap<Instance, Internal>, pl: Instance, field: Field): Internal[Field];
export declare function getLocaleHierarchy(locale: string, aliases: Record<string, string>, parentLocales: Record<string, string>): string[];
export declare function getLocaleHierarchy(locale: string): string[];

@@ -148,4 +146,2 @@ /**

export declare function getParentLocalesByLang(lang: string): Record<string, string>;
export declare function hasOwnProperty(o: unknown, key: string): boolean;

@@ -211,5 +207,3 @@

data: Record<Locale, T>;
aliases: Record<string, string>;
availableLocales: string[];
parentLocales: Record<string, string>;
}

@@ -216,0 +210,0 @@

@@ -38,4 +38,2 @@ import { NumberFormatDigitInternalSlots, NumberFormatDigitOptions, NumberFormatNotation, RawNumberFormatResult } from './number-types';

export declare function getNumberOption<T extends object, K extends keyof T>(options: T, property: K, minimum: number, maximum: number, fallback: number): number;
export declare function getAliasesByLang(lang: string): Record<string, string>;
export declare function getParentLocalesByLang(lang: string): Record<string, string>;
export declare function setInternalSlot<Instance extends object, Internal extends object, Field extends keyof Internal>(map: WeakMap<Instance, Internal>, pl: Instance, field: Field, value: NonNullable<Internal>[Field]): void;

@@ -42,0 +40,0 @@ export declare function setMultiInternalSlots<Instance extends object, Internal extends object, K extends keyof Internal>(map: WeakMap<Instance, Internal>, pl: Instance, props: Pick<NonNullable<Internal>, K>): void;

@@ -1,3 +0,1 @@

import aliases from './aliases';
import parentLocales from './parentLocales';
import { invariant } from './invariant';

@@ -85,18 +83,2 @@ import { SANCTIONED_UNITS } from './units';

}
export function getAliasesByLang(lang) {
return Object.keys(aliases).reduce(function (all, locale) {
if (locale.split('-')[0] === lang) {
all[locale] = aliases[locale];
}
return all;
}, {});
}
export function getParentLocalesByLang(lang) {
return Object.keys(parentLocales).reduce(function (all, locale) {
if (locale.split('-')[0] === lang) {
all[locale] = parentLocales[locale];
}
return all;
}, {});
}
export function setInternalSlot(map, pl, field, value) {

@@ -103,0 +85,0 @@ if (!map.get(pl)) {

@@ -13,3 +13,3 @@ import { LocaleData } from './types';

}, relevantExtensionKeys: K[], localeData: Record<string, D>) => ResolveLocaleResult;
export declare function getLocaleHierarchy(locale: string, aliases: Record<string, string>, parentLocales: Record<string, string>): string[];
export declare function getLocaleHierarchy(locale: string): string[];
export declare function supportedLocales(availableLocales: string[], requestedLocales: string[], options?: {

@@ -16,0 +16,0 @@ localeMatcher?: 'best fit' | 'lookup';

@@ -208,12 +208,4 @@ var __extends = (this && this.__extends) || (function () {

}
export function getLocaleHierarchy(locale, aliases, parentLocales) {
export function getLocaleHierarchy(locale) {
var results = [locale];
if (aliases[locale]) {
locale = aliases[locale];
results.push(locale);
}
var parentLocale = parentLocales[locale];
if (parentLocale) {
results.push(parentLocale);
}
var localeParts = locale.split('-');

@@ -264,3 +256,3 @@ for (var i = localeParts.length; i > 1; i--) {

if (reducer === void 0) { reducer = function (all, d) { return (__assign(__assign({}, all), d)); }; }
var localeHierarchy = getLocaleHierarchy(locale, localeData.aliases, localeData.parentLocales);
var localeHierarchy = getLocaleHierarchy(locale);
var dataToMerge = localeHierarchy

@@ -267,0 +259,0 @@ .map(function (l) { return localeData.data[l]; })

export declare type Locale = string;
export interface LocaleData<T> {
data: Record<Locale, T>;
aliases: Record<string, string>;
availableLocales: string[];
parentLocales: Record<string, string>;
}
//# sourceMappingURL=types.d.ts.map
{
"name": "@formatjs/intl-utils",
"version": "3.0.1",
"version": "3.1.0",
"description": "Smartly determine best unit for relative time format",

@@ -33,17 +33,12 @@ "keywords": [

"clean": "rimraf dist dist-es6 lib *.tsbuildinfo",
"cldr": "ts-node scripts/cldr",
"build": "yarn run cldr && tsc && tsc -p tsconfig.esm.json && tsc -p tsconfig.es6.json && api-extractor run --local",
"test": "mocha --opts ../../mocha.opts tests/*"
"build": "tsc && tsc -p tsconfig.esm.json && tsc -p tsconfig.es6.json && api-extractor run --local",
"test": "jest"
},
"homepage": "https://github.com/formatjs/formatjs",
"license": "MIT",
"gitHead": "b1541f5148ee2463b57393deb00c0dd1107d286d",
"gitHead": "91d1251eb9a54e153314e6c14572cd5dfd01b9ce",
"devDependencies": {
"@types/chai": "^4.2.11",
"@types/mocha": "^7.0.2",
"@types/serialize-javascript": "^1.5.0",
"chai": "^4.2.0",
"mocha": "^7.1.2",
"serialize-javascript": "^3.0.0"
}
}
export {selectUnit} from './diff';
export {
defaultNumberOption,
getAliasesByLang,
getInternalSlot,

@@ -9,3 +8,2 @@ getMultiInternalSlots,

getOption,
getParentLocalesByLang,
isLiteralPart,

@@ -12,0 +10,0 @@ LiteralPart,

@@ -1,3 +0,1 @@

import aliases from './aliases';
import parentLocales from './parentLocales';
import {invariant} from './invariant';

@@ -118,23 +116,2 @@ import {

export function getAliasesByLang(lang: string): Record<string, string> {
return Object.keys(aliases).reduce((all: Record<string, string>, locale) => {
if (locale.split('-')[0] === lang) {
all[locale] = aliases[locale as 'zh-CN'];
}
return all;
}, {});
}
export function getParentLocalesByLang(lang: string): Record<string, string> {
return Object.keys(parentLocales).reduce(
(all: Record<string, string>, locale) => {
if (locale.split('-')[0] === lang) {
all[locale] = parentLocales[locale as 'en-150'];
}
return all;
},
{}
);
}
export function setInternalSlot<

@@ -141,0 +118,0 @@ Instance extends object,

@@ -243,16 +243,4 @@ import {invariant} from './invariant';

export function getLocaleHierarchy(
locale: string,
aliases: Record<string, string>,
parentLocales: Record<string, string>
): string[] {
export function getLocaleHierarchy(locale: string): string[] {
const results = [locale];
if (aliases[locale as 'zh-CN']) {
locale = aliases[locale as 'zh-CN'];
results.push(locale);
}
const parentLocale = parentLocales[locale as 'en-150'];
if (parentLocale) {
results.push(parentLocale);
}
const localeParts = locale.split('-');

@@ -324,7 +312,3 @@ for (let i = localeParts.length; i > 1; i--) {

): T {
const localeHierarchy = getLocaleHierarchy(
locale,
localeData.aliases,
localeData.parentLocales
);
const localeHierarchy = getLocaleHierarchy(locale);
const dataToMerge = localeHierarchy

@@ -331,0 +315,0 @@ .map(l => localeData.data[l])

export type Locale = string;
export interface LocaleData<T> {
data: Record<Locale, T>;
aliases: Record<string, string>;
availableLocales: string[];
parentLocales: Record<string, string>;
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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