// Maps a native handle (the integer id the engine returns) back to its JS wrapper, so callbacks
// the host fires by id (animation events, touch hits, media events) can be routed to the owning
// object. Each engine/domain keeps its own Registry instance.

export class Registry<T> {
  private map = new Map<number, T>()

  set(id: number, value: T): void {
    this.map.set(id, value)
  }

  get(id: number): T | undefined {
    return this.map.get(id)
  }

  delete(id: number): void {
    this.map.delete(id)
  }

  has(id: number): boolean {
    return this.map.has(id)
  }
}
