* 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)
| 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); |
no test coverage detected