How to use the @phensley/cldr-utils.LRU 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 / patterns.ts View on Github external
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);
  }
github phensley / cldr-engine / packages / cldr-core / src / internals / calendars / patterns.ts View on Github external
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);
  }
github phensley / cldr-engine / packages / cldr-core / src / internals / calendars / patterns.ts View on Github external
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);
github phensley / cldr-engine / packages / cldr-core / __tests__ / _helpers / bundle.ts View on Github external
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;
github phensley / cldr-engine / packages / cldr-core / src / cldr.ts View on Github external
constructor(protected options: CLDROptions) {
    this.packCache = new LRU(options.packCacheSize || 2);
    this.loader = options.loader;
    this.asyncLoader = options.asyncLoader;

    const patternCacheSize = options.patternCacheSize || 200;
    this.internals = new InternalsImpl(
      options.config || CLDRFramework.defaultConfig || EMPTY_CONFIG,
      VERSION, options.debug, patternCacheSize);
  }

@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