MCPcopy Create free account
hub / github.com/angular/angular / uniqueName

Method uniqueName

packages/compiler/src/constant_pool.ts:213–219  ·  view source on GitHub ↗

* Produce a unique name in the context of this pool. * * The name might be unique among different prefixes if any of the prefixes end in * a digit so the prefix should be a constant string (not based on user input) and * must not end in a digit.

(name: string, alwaysIncludeSuffix = true)

Source from the content-addressed store, hash-verified

211 * must not end in a digit.
212 */
213 uniqueName(name: string, alwaysIncludeSuffix = true): string {
214 const count = this._claimedNames.get(name) ?? 0;
215 const result = count === 0 && !alwaysIncludeSuffix ? `${name}` : `${name}${count}`;
216
217 this._claimedNames.set(name, count + 1);
218 return result;
219 }
220
221 private freshName(): string {
222 return this.uniqueName(CONSTANT_PREFIX);

Callers 5

freshNameMethod · 0.95
collectMessageFunction · 0.80
i18nGenerateClosureVarFunction · 0.80
addNamesToViewFunction · 0.80

Calls 2

getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected