UNPKG

@cyclonedx/cyclonedx-library

Version:

Core functionality of CycloneDX for JavaScript (Node.js or WebBrowser).

83 lines (79 loc) 2.81 kB
"use strict"; /*! This file is part of CycloneDX JavaScript Library. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. SPDX-License-Identifier: Apache-2.0 Copyright (c) OWASP Foundation. All Rights Reserved. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.Tools = exports.ToolRepository = exports.Tool = void 0; const sortable_1 = require("../_helpers/sortable"); const component_1 = require("./component"); const externalReference_1 = require("./externalReference"); const hash_1 = require("./hash"); const service_1 = require("./service"); class Tool { vendor; name; version; hashes; externalReferences; constructor(op = {}) { this.vendor = op.vendor; this.name = op.name; this.version = op.version; this.hashes = op.hashes ?? new hash_1.HashDictionary(); this.externalReferences = op.externalReferences ?? new externalReference_1.ExternalReferenceRepository(); } compare(other) { return (this.vendor ?? '').localeCompare(other.vendor ?? '') || (this.name ?? '').localeCompare(other.name ?? '') || (this.version ?? '').localeCompare(other.version ?? ''); } static fromComponent(component) { return new Tool({ vendor: component.group, name: component.name, version: component.version, hashes: component.hashes, externalReferences: component.externalReferences }); } static fromService(service) { return new Tool({ vendor: service.group, name: service.name, version: service.version, externalReferences: service.externalReferences }); } } exports.Tool = Tool; class ToolRepository extends sortable_1.SortableComparables { } exports.ToolRepository = ToolRepository; class Tools { components; services; tools; constructor(op = {}) { this.components = op.components ?? new component_1.ComponentRepository(); this.services = op.services ?? new service_1.ServiceRepository(); this.tools = op.tools ?? new ToolRepository(); } get size() { return this.components.size + this.services.size + this.tools.size; } } exports.Tools = Tools; //# sourceMappingURL=tool.js.map