ew mapping if not found. * * @param {object} object * The object to look up or insert. * * @returns {string} * The id associated with the object. */ getOrInsert(object) { if (this.hasObject(object)) { return this.getId(object); } const id = lazy.generateUUID(); this.#objectToId.set(object, id); this.#idToObject.set(id, object); return id; } /** * Retrieves the id associated with the given object. * * @param {object} object * The object to look up. * * @returns {string} * The id associated with the object, or undefined if not found. */ getId(object) { return this.#objectToId.get(object); } /** * Retrieves the object associated with the given id. * * @param {string} id * The id to look up. * * @returns {object} * The object associated with the id, or undefined if not found. */ getObject(id) { return this.#idToObject.get(id); } /** * Checks whether the BiMap contains the given id. * * @param {string} id * The id to check for. * * @returns {boolean} * True if the id exists in the BiMap, false otherwise. */ hasId(id) { return this.#idToObject.has(id); } /** * Checks whether the BiMap contains the given object. * * @param {object} object * The object to check for. * * @returns {boolean} * True if the object exists in the BiMap, false otherwise. */ hasObject(object) { return this.#objectToId.has(object); } } PK