UNPKG

@jbrowse/core

Version:

JBrowse 2 core libraries used by plugins

62 lines (61 loc) 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); class CompositeMap { constructor(submaps) { this.submaps = submaps; } has(id) { for (const submap of this.submaps.values()) { if (submap.has(id)) { return true; } } return false; } get(id) { for (const submap of this.submaps.values()) { if (submap.has(id)) { return submap.get(id); } } return undefined; } *values() { for (const key of this.keys()) { yield this.get(key); } } *keys() { const keys = new Set(); for (const submap of this.submaps.values()) { for (const key of submap.keys()) { keys.add(key); } } for (const key of keys) { yield key; } } find(f) { for (const submap of this.submaps.values()) { for (const value of submap.values()) { const found = f(value); if (found) { return value; } } } return undefined; } *[Symbol.iterator]() { for (const key of this.keys()) { yield [key, this.get(key)]; } } *entries() { for (const k of this.keys()) { yield [k, this.get(k)]; } } } exports.default = CompositeMap;