@cyclonedx/cyclonedx-library
Version:
Core functionality of CycloneDX for JavaScript (Node.js or WebBrowser).
76 lines (72 loc) • 2.71 kB
JavaScript
/*!
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.ServiceRepository = exports.Service = void 0;
const sortable_1 = require("../_helpers/sortable");
const tree_1 = require("../_helpers/tree");
const bomRef_1 = require("./bomRef");
const externalReference_1 = require("./externalReference");
const license_1 = require("./license");
const property_1 = require("./property");
class Service {
provider;
group;
name;
version;
description;
licenses;
externalReferences;
services;
properties;
#bomRef;
dependencies;
constructor(name, op = {}) {
this.#bomRef = new bomRef_1.BomRef(op.bomRef);
this.provider = op.provider;
this.group = op.group;
this.name = name;
this.version = op.version;
this.description = op.description;
this.licenses = op.licenses ?? new license_1.LicenseRepository();
this.externalReferences = op.externalReferences ?? new externalReference_1.ExternalReferenceRepository();
this.services = op.services ?? new ServiceRepository();
this.properties = op.properties ?? new property_1.PropertyRepository();
this.dependencies = op.dependencies ?? new bomRef_1.BomRefRepository();
}
get bomRef() {
return this.#bomRef;
}
compare(other) {
const bomRefCompare = this.bomRef.compare(other.bomRef);
if (bomRefCompare !== 0) {
return bomRefCompare;
}
return (this.group ?? '').localeCompare(other.group ?? '') ||
this.name.localeCompare(other.name) ||
(this.version ?? '').localeCompare(other.version ?? '');
}
}
exports.Service = Service;
class ServiceRepository extends sortable_1.SortableComparables {
*[tree_1.treeIteratorSymbol]() {
for (const service of this) {
yield service;
yield* service.services[tree_1.treeIteratorSymbol]();
}
}
}
exports.ServiceRepository = ServiceRepository;
//# sourceMappingURL=service.js.map
;