How to use the @phensley/cldr-utils.Cache function in @phensley/cldr-utils

To help you get started, we’ve selected a few @phensley/cldr-utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github phensley / cldr-engine / packages / cldr-core / src / internals / calendars / internal.ts View on Github external
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;
github phensley / cldr-engine / packages / cldr-core / src / internals / calendars / internal.ts View on Github external
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;
github phensley / cldr-engine / packages / cldr-core / src / internals / calendars / internal.ts View on Github external
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;
github phensley / cldr-engine / packages / cldr-core / src / internals / calendars / rules.ts View on Github external
constructor(protected cacheSize: number) {
    this.cache = new Cache(parseRule, cacheSize);
  }
github phensley / cldr-engine / packages / cldr-core / src / internals / wrapper / internal.ts View on Github external
constructor(cacheSize: number = 50) {
    this.wrapperPatternCache = new Cache(parseWrapperPattern, cacheSize);
  }
github phensley / cldr-engine / packages / cldr-core / src / internals / calendars / manager.ts View on Github external
constructor(
    private readonly bundle: Bundle,
    private readonly internals: Internals
  ) {
    this.availableCalendars = new Set(internals.config.calendars || []);
    const schema = internals.schema;
    this.patternCache = new Cache((calendar: string) => {
      if (this.availableCalendars.has(calendar)) {
        switch (calendar) {
        case 'buddhist':
          return new CalendarPatterns(bundle, internals, schema.Buddhist);
        case 'japanese':
          return new CalendarPatterns(bundle, internals, schema.Japanese);
        case 'persian':
          return new CalendarPatterns(bundle, internals, schema.Persian);
        }
      }
      return new GregorianPatterns(bundle, internals, schema.Gregorian);
    }, 20);
  }
github phensley / cldr-engine / packages / cldr-core / src / internals / numbers / internal.ts View on Github external
constructor(readonly internals: Internals, cacheSize: number = 50) {
    const schema = internals.schema;
    this.currencies = schema.Currencies;
    this.numbers = schema.Numbers;
    this.numberPatternCache = new Cache(parseNumberPattern, cacheSize);
  }
github phensley / cldr-engine / packages / cldr-core / src / api / private / numbers.ts View on Github external
constructor(
    protected bundle: Bundle,
    protected internals: Internals
  ) {
    this.numberParamsCache = new Cache((s: string) => this.build(s as NumberSystemName), 20);
    this.numbers = internals.schema.Numbers;
    this.latnSystemInfo = this.numbers.numberSystem.get('latn') as NumberSystemInfo;
    this.latnSystem = this.buildNumberSystem('latn');
  }
github phensley / cldr-engine / packages / messageformat / src / formatter.ts View on Github external
constructor(options: MessageFormatterOptions = { }) {
    this.formatters = options.formatters || {};
    this.plurals = options.plurals || pluralRules.get(options.language || 'root', options.region);
    const size = options.cacheSize || DEFAULT_CACHE_SIZE;
    this.matcher = buildMessageMatcher(Object.keys(this.formatters));
    this.cache = new Cache(s => parseMessagePattern(s, this.matcher), size);
  }
github phensley / cldr-engine / packages / cldr-core / src / internals / general / internal.ts View on Github external
constructor(readonly internals: Internals, cacheSize: number = 50) {
    const schema = internals.schema;
    this.layout = schema.Layout;
    this.names = schema.Names;
    this.listPatterns = schema.ListPatterns;
    this.wrapperPatternCache = new Cache(parseWrapperPattern, cacheSize);
  }

@phensley/cldr-utils

Utilities for cldr-engine packages

Apache-2.0
Latest version published 17 days ago

Package Health Score

60 / 100
Full package analysis

Similar packages