Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • UniqueNameFinder

Index

Constructors

constructor

  • new UniqueNameFinder(separator?: Separator, alreadyUsedNames?: string[]): UniqueNameFinder
  • Parameters

    • Default value separator: Separator = "_"

      The separator to be used

    • Default value alreadyUsedNames: string[] = []

      Sets the already used names considered in the finding process. Reserved TS keywords are always checked.

    Returns UniqueNameFinder

Methods

addToAlreadyUsedNames

  • addToAlreadyUsedNames(...names: string[]): this

findUniqueName

  • findUniqueName(name: string): string
  • Find a unique name by appending a suffix of the form this.separator\d+ if necessary. If the name is already unique nothing is appended.

    Parameters

    • name: string

      The name to get a unique name from

    Returns string

    Unique name

findUniqueNameWithSuffixes

  • findUniqueNameWithSuffixes(name: string, suffixes: string[]): string[]
  • Find a unique name by appending a suffix of the form this.separator\d+ if necessary. If the name is already unique nothing is appended. The suffixes are a list of strings appended to the name and these build names are also checked for uniqueness.

    Parameters

    • name: string

      The name to get a unique name from

    • suffixes: string[]

      Additional name suffixed to be considered

    Returns string[]

    Unique names. The length of this array is one plus the number of suffixes provided. The first entry corresponds to the given name.