Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(
protected readonly bundle: Bundle,
protected readonly internals: Internals,
private readonly schema: CalendarSchema,
readonly cacheSize: number = 50
) {
this.language = bundle.language();
this.region = bundle.region();
this.skeletonParser = this.buildSkeletonParser();
this.skeletonRequestCache = new LRU(cacheSize);
this.intervalRequestCache = new LRU(cacheSize);
this.namesCache = new LRU(cacheSize);
// Fetch this locale's main formats
this.dateFormats = schema.dateFormats.mapping(bundle);
this.timeFormats = schema.timeFormats.mapping(bundle);
this.wrapperFormats = schema.dateTimeFormats.mapping(bundle);
// Fetch skeletons and build best-fit matchers
this.rawAvailableFormats = this.schema.availableFormats.mapping(bundle);
this.rawPluralFormats = this.schema.pluralFormats.mapping(bundle);
this.rawIntervalFormats = this.schema.intervalFormats.mapping(bundle);
this.buildAvailableMatcher();
this.buildIntervalMatcher();
this.intervalFallback = this.schema.intervalFormatFallback.get(bundle);
}
constructor(
protected readonly bundle: Bundle,
protected readonly internals: Internals,
private readonly schema: CalendarSchema,
readonly cacheSize: number = 50
) {
this.language = bundle.language();
this.region = bundle.region();
this.skeletonParser = this.buildSkeletonParser();
this.skeletonRequestCache = new LRU(cacheSize);
this.intervalRequestCache = new LRU(cacheSize);
this.namesCache = new LRU(cacheSize);
// Fetch this locale's main formats
this.dateFormats = schema.dateFormats.mapping(bundle);
this.timeFormats = schema.timeFormats.mapping(bundle);
this.wrapperFormats = schema.dateTimeFormats.mapping(bundle);
// Fetch skeletons and build best-fit matchers
this.rawAvailableFormats = this.schema.availableFormats.mapping(bundle);
this.rawPluralFormats = this.schema.pluralFormats.mapping(bundle);
this.rawIntervalFormats = this.schema.intervalFormats.mapping(bundle);
this.buildAvailableMatcher();
this.buildIntervalMatcher();
this.intervalFallback = this.schema.intervalFormatFallback.get(bundle);
}
constructor(
protected readonly bundle: Bundle,
protected readonly internals: Internals,
private readonly schema: CalendarSchema,
readonly cacheSize: number = 50
) {
this.language = bundle.language();
this.region = bundle.region();
this.skeletonParser = this.buildSkeletonParser();
this.skeletonRequestCache = new LRU(cacheSize);
this.intervalRequestCache = new LRU(cacheSize);
this.namesCache = new LRU(cacheSize);
// Fetch this locale's main formats
this.dateFormats = schema.dateFormats.mapping(bundle);
this.timeFormats = schema.timeFormats.mapping(bundle);
this.wrapperFormats = schema.dateTimeFormats.mapping(bundle);
// Fetch skeletons and build best-fit matchers
this.rawAvailableFormats = this.schema.availableFormats.mapping(bundle);
this.rawPluralFormats = this.schema.pluralFormats.mapping(bundle);
this.rawIntervalFormats = this.schema.intervalFormats.mapping(bundle);
this.buildAvailableMatcher();
this.buildIntervalMatcher();
this.intervalFallback = this.schema.intervalFormatFallback.get(bundle);
export const checksumIndices = (version: string, map: KeyIndexMap): string => {
const c = new Checksum();
c.update(version);
// Visit map keys in sorted order
const keys = Object.keys(map).sort();
for (const key of keys) {
c.update(key);
// Mapped values must be visited in their existing order.
for (const val of map[key].keys) {
c.update(val);
}
}
return c.get().toString(16);
};
import * as fs from 'fs';
import { join } from 'path';
import { SchemaConfig } from '@phensley/cldr-schema';
import { LRU } from '@phensley/cldr-utils';
import { LanguageResolver } from '@phensley/locale';
import { Bundle, Pack } from '../../src/resource';
import { CLDRFramework } from '../../src';
import { VERSION } from '../../src/utils/version';
const pkg = require('../../package.json');
const TEMPROOT = join(__dirname, '..', '..', '.custom-packs');
const bundleCache = new LRU(15);
interface PackSpec {
hash: string;
config: string;
}
const makedir = (dir: string) => {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
};
/**
* Configure a framework with a loader that will load a custom resource pack.
* This allows us to test purposefully-mismatched resource pack and framework
* checksums;
constructor(
readonly internals: Internals,
readonly cacheSize: number = 50
) {
this.schema = internals.schema;
this.dayPeriodRules = new DayPeriodRules(cacheSize);
this.patternCache = new Cache(parseDatePattern, cacheSize);
this.availableCalendars = new Set(internals.config.calendars || []);
this.hourPatternCache = new Cache((raw: string): [DateTimeNode[], DateTimeNode[]] => {
const parts = raw.split(';');
return [this.patternCache.get(parts[0]), this.patternCache.get(parts[1])];
}, cacheSize);
this.calendarFormatterCache = new Cache((calendar: string) => {
let s: CalendarSchema | undefined;
if (this.availableCalendars.has(calendar)) {
switch (calendar) {
case 'buddhist':
s = this.schema.Buddhist;
break;
case 'japanese':
s = this.schema.Japanese;
break;
constructor(
readonly internals: Internals,
readonly cacheSize: number = 50
) {
this.schema = internals.schema;
this.dayPeriodRules = new DayPeriodRules(cacheSize);
this.patternCache = new Cache(parseDatePattern, cacheSize);
this.availableCalendars = new Set(internals.config.calendars || []);
this.hourPatternCache = new Cache((raw: string): [DateTimeNode[], DateTimeNode[]] => {
const parts = raw.split(';');
return [this.patternCache.get(parts[0]), this.patternCache.get(parts[1])];
}, cacheSize);
this.calendarFormatterCache = new Cache((calendar: string) => {
let s: CalendarSchema | undefined;
if (this.availableCalendars.has(calendar)) {
switch (calendar) {
case 'buddhist':
s = this.schema.Buddhist;
break;
case 'japanese':
s = this.schema.Japanese;
break;
case 'persian':
s = this.schema.Persian;
break;
}
}
if (s === undefined) {
s = this.schema.Gregorian;
constructor(
readonly internals: Internals,
readonly cacheSize: number = 50
) {
this.schema = internals.schema;
this.dayPeriodRules = new DayPeriodRules(cacheSize);
this.patternCache = new Cache(parseDatePattern, cacheSize);
this.availableCalendars = new Set(internals.config.calendars || []);
this.hourPatternCache = new Cache((raw: string): [DateTimeNode[], DateTimeNode[]] => {
const parts = raw.split(';');
return [this.patternCache.get(parts[0]), this.patternCache.get(parts[1])];
}, cacheSize);
this.calendarFormatterCache = new Cache((calendar: string) => {
let s: CalendarSchema | undefined;
if (this.availableCalendars.has(calendar)) {
switch (calendar) {
case 'buddhist':
s = this.schema.Buddhist;
break;
case 'japanese':
s = this.schema.Japanese;
break;
case 'persian':
s = this.schema.Persian;
constructor(protected cacheSize: number) {
this.cache = new Cache(parseRule, cacheSize);
}
constructor(cacheSize: number = 50) {
this.wrapperPatternCache = new Cache(parseWrapperPattern, cacheSize);
}