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

@formatjs/intl-utils

Package Overview
Dependencies
Maintainers
2
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 2.0.1 to 2.0.2

13

CHANGELOG.md

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

## [2.0.2](https://github.com/formatjs/formatjs/compare/@formatjs/intl-utils@2.0.1...@formatjs/intl-utils@2.0.2) (2020-01-06)
### Bug Fixes
* **@formatjs/intl-unified-numberformat:** account for DecimalFormatNum in internal slots ([dc26b43](https://github.com/formatjs/formatjs/commit/dc26b434eabb4f629a821f7c12d5ae7570bd8cab))
* **@formatjs/intl-unified-numberformat:** fix cases where {number} or {0} is in the middle of the pattern ([3ca49d8](https://github.com/formatjs/formatjs/commit/3ca49d8f93a9acc1ea3908ffd9e367b21aa97248))
* **@formatjs/intl-utils:** fix getInternalSlot to prevent Object.prototype taint ([334441b](https://github.com/formatjs/formatjs/commit/334441b000c0206c77683f70a1f987d2793643cb))
## [2.0.1](https://github.com/formatjs/formatjs/compare/@formatjs/intl-utils@2.0.0...@formatjs/intl-utils@2.0.1) (2019-12-27)

@@ -8,0 +21,0 @@

13

dist/number-types.d.ts

@@ -42,7 +42,8 @@ import { LDMLPluralRule } from './plural-rules-types';

}
export declare type CompactSignPattern = Record<DecimalFormatNum, SignPattern>;
export interface NotationPattern {
standard: SignPattern;
scientific: SignPattern;
compactShort: SignPattern;
compactLong: SignPattern;
compactShort: CompactSignPattern;
compactLong: CompactSignPattern;
}

@@ -99,5 +100,5 @@ export interface SignDisplayPattern {

unitSymbols: Record<string, {
unitSymbol: LDMLPluralRuleMap<string>;
unitNarrowSymbol: LDMLPluralRuleMap<string>;
unitName: LDMLPluralRuleMap<string>;
unitSymbol: LDMLPluralRuleMap<string[]>;
unitNarrowSymbol: LDMLPluralRuleMap<string[]>;
unitName: LDMLPluralRuleMap<string[]>;
}>;

@@ -132,3 +133,3 @@ }

pattern: string;
symbol: string;
symbol: string[];
}

@@ -135,0 +136,0 @@ export interface CurrencyData {

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

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: Internal[Field]): void;
export declare function setMultiInternalSlots<Instance extends object, Internal extends object, K extends keyof Internal>(map: WeakMap<Instance, Internal>, pl: Instance, props: Pick<Internal, K>): void;
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;
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;
export declare function getInternalSlot<Instance extends object, Internal extends object, Field extends keyof Internal>(map: WeakMap<Instance, Internal>, pl: Instance, field: Field): Internal[Field];

@@ -39,0 +39,0 @@ export declare function getMultiInternalSlots<Instance extends object, Internal extends object, Field extends keyof Internal>(map: WeakMap<Instance, Internal>, pl: Instance, ...fields: Field[]): Pick<Internal, Field>;

@@ -96,7 +96,2 @@ "use strict";

function setInternalSlot(map, pl, field, value) {
var _a;
setMultiInternalSlots(map, pl, (_a = {}, _a[field] = value, _a));
}
exports.setInternalSlot = setInternalSlot;
function setMultiInternalSlots(map, pl, props) {
if (!map.get(pl)) {

@@ -106,4 +101,10 @@ map.set(pl, Object.create(null));

var slots = map.get(pl);
Object.assign(slots, props);
slots[field] = value;
}
exports.setInternalSlot = setInternalSlot;
function setMultiInternalSlots(map, pl, props) {
for (var k in props) {
setInternalSlot(map, pl, k, props[k]);
}
}
exports.setMultiInternalSlots = setMultiInternalSlots;

@@ -126,3 +127,3 @@ function getInternalSlot(map, pl, field) {

return all;
}, {});
}, Object.create(null));
}

@@ -129,0 +130,0 @@ exports.getMultiInternalSlots = getMultiInternalSlots;

export declare type CompactSignPattern = Record<DecimalFormatNum, SignPattern>;
export declare function createResolveLocale<K extends string, D extends {

@@ -179,4 +181,4 @@ [k in K]: any;

scientific: SignPattern;
compactShort: SignPattern;
compactLong: SignPattern;
compactShort: CompactSignPattern;
compactLong: CompactSignPattern;
}

@@ -234,5 +236,5 @@

unitSymbols: Record<string, {
unitSymbol: LDMLPluralRuleMap<string>;
unitNarrowSymbol: LDMLPluralRuleMap<string>;
unitName: LDMLPluralRuleMap<string>;
unitSymbol: LDMLPluralRuleMap<string[]>;
unitNarrowSymbol: LDMLPluralRuleMap<string[]>;
unitName: LDMLPluralRuleMap<string[]>;
}>;

@@ -308,3 +310,3 @@ }

pattern: string;
symbol: string;
symbol: string[];
}

@@ -335,5 +337,5 @@

export declare function setInternalSlot<Instance extends object, Internal extends object, Field extends keyof Internal>(map: WeakMap<Instance, Internal>, pl: Instance, field: Field, value: Internal[Field]): void;
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;
export declare function setMultiInternalSlots<Instance extends object, Internal extends object, K extends keyof Internal>(map: WeakMap<Instance, Internal>, pl: Instance, props: Pick<Internal, K>): void;
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;

@@ -340,0 +342,0 @@ /**

@@ -42,7 +42,8 @@ import { LDMLPluralRule } from './plural-rules-types';

}
export declare type CompactSignPattern = Record<DecimalFormatNum, SignPattern>;
export interface NotationPattern {
standard: SignPattern;
scientific: SignPattern;
compactShort: SignPattern;
compactLong: SignPattern;
compactShort: CompactSignPattern;
compactLong: CompactSignPattern;
}

@@ -99,5 +100,5 @@ export interface SignDisplayPattern {

unitSymbols: Record<string, {
unitSymbol: LDMLPluralRuleMap<string>;
unitNarrowSymbol: LDMLPluralRuleMap<string>;
unitName: LDMLPluralRuleMap<string>;
unitSymbol: LDMLPluralRuleMap<string[]>;
unitNarrowSymbol: LDMLPluralRuleMap<string[]>;
unitName: LDMLPluralRuleMap<string[]>;
}>;

@@ -132,3 +133,3 @@ }

pattern: string;
symbol: string;
symbol: string[];
}

@@ -135,0 +136,0 @@ export interface CurrencyData {

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

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: Internal[Field]): void;
export declare function setMultiInternalSlots<Instance extends object, Internal extends object, K extends keyof Internal>(map: WeakMap<Instance, Internal>, pl: Instance, props: Pick<Internal, K>): void;
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;
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;
export declare function getInternalSlot<Instance extends object, Internal extends object, Field extends keyof Internal>(map: WeakMap<Instance, Internal>, pl: Instance, field: Field): Internal[Field];

@@ -39,0 +39,0 @@ export declare function getMultiInternalSlots<Instance extends object, Internal extends object, Field extends keyof Internal>(map: WeakMap<Instance, Internal>, pl: Instance, ...fields: Field[]): Pick<Internal, Field>;

@@ -88,6 +88,2 @@ import aliases from './aliases';

export function setInternalSlot(map, pl, field, value) {
var _a;
setMultiInternalSlots(map, pl, (_a = {}, _a[field] = value, _a));
}
export function setMultiInternalSlots(map, pl, props) {
if (!map.get(pl)) {

@@ -97,4 +93,9 @@ map.set(pl, Object.create(null));

var slots = map.get(pl);
Object.assign(slots, props);
slots[field] = value;
}
export function setMultiInternalSlots(map, pl, props) {
for (var k in props) {
setInternalSlot(map, pl, k, props[k]);
}
}
export function getInternalSlot(map, pl, field) {

@@ -115,3 +116,3 @@ return getMultiInternalSlots(map, pl, field)[field];

return all;
}, {});
}, Object.create(null));
}

@@ -118,0 +119,0 @@ export function isLiteralPart(patternPart) {

{
"name": "@formatjs/intl-utils",
"version": "2.0.1",
"version": "2.0.2",
"description": "Smartly determine best unit for relative time format",

@@ -38,3 +38,3 @@ "keywords": [

"license": "MIT",
"gitHead": "3f4ea0305b68d709d5a5bf9570a99ba6d103f545"
"gitHead": "4143ae3da624e6f117d177cee70e57dac5444bd0"
}

@@ -58,7 +58,9 @@ import {LDMLPluralRule} from './plural-rules-types';

export type CompactSignPattern = Record<DecimalFormatNum, SignPattern>;
export interface NotationPattern {
standard: SignPattern;
scientific: SignPattern;
compactShort: SignPattern;
compactLong: SignPattern;
compactShort: CompactSignPattern;
compactLong: CompactSignPattern;
}

@@ -129,5 +131,5 @@

{
unitSymbol: LDMLPluralRuleMap<string>;
unitNarrowSymbol: LDMLPluralRuleMap<string>;
unitName: LDMLPluralRuleMap<string>;
unitSymbol: LDMLPluralRuleMap<string[]>;
unitNarrowSymbol: LDMLPluralRuleMap<string[]>;
unitName: LDMLPluralRuleMap<string[]>;
}

@@ -172,3 +174,5 @@ >;

pattern: string;
symbol: string;
// An array bc {0} can be in the middle,
// e.g: celsius in https://github.com/unicode-cldr/cldr-units-full/blob/master/main/ja/units.json
symbol: string[];
}

@@ -175,0 +179,0 @@

@@ -130,5 +130,9 @@ import aliases from './aliases';

field: Field,
value: Internal[Field]
value: NonNullable<Internal>[Field]
) {
setMultiInternalSlots(map, pl, {[field]: value} as Pick<Internal, Field>);
if (!map.get(pl)) {
map.set(pl, Object.create(null));
}
const slots = map.get(pl)!;
slots[field] = value;
}

@@ -140,8 +144,10 @@

K extends keyof Internal
>(map: WeakMap<Instance, Internal>, pl: Instance, props: Pick<Internal, K>) {
if (!map.get(pl)) {
map.set(pl, Object.create(null));
>(
map: WeakMap<Instance, Internal>,
pl: Instance,
props: Pick<NonNullable<Internal>, K>
) {
for (const k in props) {
setInternalSlot(map, pl, k, props[k]);
}
const slots = map.get(pl)!;
Object.assign(slots, props);
}

@@ -177,3 +183,3 @@

return all;
}, {} as Pick<Internal, Field>);
}, Object.create(null) as Pick<Internal, Field>);
}

@@ -180,0 +186,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