bit-bin
Version:
<a href="https://opensource.org/licenses/Apache-2.0"><img alt="apache" src="https://img.shields.io/badge/License-Apache%202.0-blue.svg"></a> <a href="https://github.com/teambit/bit/blob/master/CONTRIBUTING.md"><img alt="prs" src="https://img.shields.io/b
37 lines (29 loc) • 1.02 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
// @todo: it can be improved by extending only Array<Capsule> and the Capsule should have
// ComponentId member
class CapsuleList extends Array {
getCapsule(id) {
const found = this.find(item => item.id._legacy.isEqual(id._legacy));
return found ? found.capsule : null;
}
getCapsuleIgnoreVersion(id) {
const found = this.find(item => item.id._legacy.isEqualWithoutVersion(id._legacy));
return found ? found.capsule : null;
}
getCapsuleIgnoreScopeAndVersion(id) {
const found = this.find(item => item.id._legacy.isEqualWithoutScopeAndVersion(id._legacy));
return found ? found.capsule : null;
}
getAllCapsuleDirs() {
return this.map(capsule => capsule.capsule.wrkDir);
}
getIdByPathInCapsule(pathInCapsule) {
const found = this.find(item => pathInCapsule.startsWith(item.capsule.wrkDir));
return found ? found.id : null;
}
}
exports.default = CapsuleList;
;