mirror of
https://github.com/pezkuwichain/pezkuwi-telemetry.git
synced 2026-05-10 02:47:57 +00:00
16 lines
311 B
TypeScript
16 lines
311 B
TypeScript
import { Opaque } from './helpers';
|
|
|
|
/**
|
|
* Unique type-constrained Id number.
|
|
*/
|
|
export type Id<T> = Opaque<number, T>;
|
|
|
|
/**
|
|
* Higher order function producing new auto-incremented `Id`s.
|
|
*/
|
|
export function idGenerator<I extends Id<any>>(): () => I {
|
|
let current = 0;
|
|
|
|
return () => current++ as I;
|
|
}
|