An identifier mangler that leverages character frequency analysis to determine identifier precedence.

interface WeightedIdentifierMangler {
    consider(chars, delta): number;
    get(n): string;
    reset(): void;
    sort(): void;
}

Hierarchy (view full)

Methods

  • Modifies the internal weighting of the input characters by the specified delta. Will be invoked on the entire printed AST, and then deduct mangleable identifiers.

    Parameters

    • chars: string

      The characters to modify the weighting of.

    • delta: number

      The numeric weight to add to the characters.

    Returns number

  • Obtains the nth most favored (usually shortest) identifier to rename a variable to. The mangler will increment n and retry until the return value is not in use in scope, and is not a reserved word. This function is expected to be stable; Evaluating get(n) === get(n) should always return true.

    Parameters

    • n: number

      The ordinal of the identifier.

    Returns string

  • Resets character weights.

    Returns void

  • Sorts identifiers by character frequency, in preparation for calls to get(n).

    Returns void