@k8ts/instruments
Version:
A collection of utilities and core components for k8ts.
38 lines • 916 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PortMap = void 0;
const error_1 = require("./error");
class PortMap {
_map;
constructor(_map) {
this._map = _map;
}
_apply(f) {
return new PortMap(f(this._map));
}
pick(...name) {
return this._apply(map => map.filter((_, key) => name.includes(key)));
}
get values() {
return this._map;
}
map(mapping) {
return new PortMap(this._map.map(entry => {
return {
...entry,
frontend: mapping[entry.name]
};
}));
}
get(name) {
if (!this._map.has(name)) {
throw new error_1.PortError(`Port ${name} not found`);
}
return this._map.get(name);
}
toMap() {
return this._map;
}
}
exports.PortMap = PortMap;
//# sourceMappingURL=map.js.map