UNPKG

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

78 lines (60 loc) 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ExtensionConfigList = void 0; function _ramda() { const data = require("ramda"); _ramda = function () { return data; }; return data; } function _bitId() { const data = require("../../bit-id"); _bitId = function () { return data; }; return data; } class ExtensionConfigList extends Array { get ids() { return this.map(entry => entry.id); } findExtension(extensionId, ignoreVersion = false) { return (0, _ramda().find)(extEntry => { if (!ignoreVersion) { return extEntry.id === extensionId; } return _bitId().BitId.getStringWithoutVersion(extEntry.id) === _bitId().BitId.getStringWithoutVersion(extensionId); }, this); } toObject() { const res = {}; this.forEach(entry => res[entry.id] = entry.config); return res; } remove(id) { return ExtensionConfigList.fromArray(this.filter(ext => ext.id !== id)); } _filterLegacy() { return ExtensionConfigList.fromArray(this.filter(ext => !ext.config.__legacy)); } static fromObject(obj) { const arr = []; (0, _ramda().forEachObjIndexed)((config, id) => { arr.push({ id, config }); }, obj); return this.fromArray(arr); } static fromArray(entries) { if (!entries || !entries.length) { return new ExtensionConfigList(); } return new ExtensionConfigList(...entries); } } exports.ExtensionConfigList = ExtensionConfigList;