@medflyt/test-db-service
Version:
Developer tool to instantly provision test PostgreSQL databases from a template
35 lines • 1.04 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.DatabaseTemplateMap = void 0;
/**
* A "Map"-like class with a compound key
*/
class DatabaseTemplateMap {
constructor() {
this.map = new Map();
}
get(postgresVersion, hash) {
return this.map.get(keyToString(postgresVersion, hash));
}
set(postgresVersion, hash, value) {
this.map.set(keyToString(postgresVersion, hash), value);
}
forEach(callbackfn) {
this.map.forEach((value, key) => {
const [postgresVersion, hash] = stringToKey(key);
callbackfn(value, postgresVersion, hash, this);
});
}
values() {
return this.map.values();
}
}
exports.DatabaseTemplateMap = DatabaseTemplateMap;
function keyToString(postgresVersion, hash) {
return `${postgresVersion}\t${hash}`;
}
function stringToKey(key) {
const [postgresVersion, hash] = key.split("\t", 2);
return [postgresVersion, hash];
}
//# sourceMappingURL=DatabaseTemplateMap.js.map