Skip to main content

calculateResourceScore

Callable

  • calculateResourceScore(selector: Map<string, string | string[]>, envConfig: Record<string, string>, weights: Record<string, number>): number

  • Give a selector and environment variable, return the score of the selector.

    @example
    const selector = ['lang:zh-Hans', 'category:image', 'client:web'];
    const envConfig = {
    lang: 'zh-Hans',
    category: 'image',
    client: 'app',
    };
    const weights = {
    lang: 1,
    };
    const score = calculateResourceScore(selector, envConfig);

    Parameters

    • selector: Map<string, string | string[]>

      Selector of this resource.

    • envConfig: Record<string, string>

      Environment variable of current system.

    • weights: Record<string, number>

      Weights of each environment variable entry.

    Returns number

    the score of the selector.