rc-js-util
Version:
A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.
22 lines (20 loc) • 437 B
text/typescript
import { IIdentifierFactory } from "./i-identifier-factory.js";
/**
* @public
* Provides an incrementing integer identifier.
*
* @remarks
* By default the first ID will be 1, this may be configured at construction.
*/
export class IncrementingIdentifierFactory implements IIdentifierFactory
{
public constructor(
private id = 1,
)
{
}
public getNextId(): number
{
return this.id++;
}
}