@shockpkg/core
Version:
shockpkg core
87 lines (72 loc) • 1.49 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Package = void 0;
/**
* Package constructor.
*
* @param info Package info.
* @param parent Package parent.
*/
class Package extends Object {
/**
* Package name.
*/
/**
* File name.
*/
/**
* File size.
*/
/**
* SHA256 hash of file.
*/
/**
* Source path, URL for root, file path for child packages.
*/
/**
* Child packages.
*/
/**
* The parent package this package is found in.
*/
constructor(info, parent = null) {
super();
this.name = void 0;
this.file = void 0;
this.size = void 0;
this.sha256 = void 0;
this.source = void 0;
this.packages = void 0;
this.parent = void 0;
this.name = info.name;
this.file = info.file;
this.size = info.size;
this.sha256 = info.sha256;
this.source = info.source;
this.parent = parent;
this.packages = this._createPackages(info.packages);
}
/**
* Create child packages list.
*
* @param infos Package infos.
* @returns Package instance.
*/
_createPackages(infos = []) {
return infos.map(info => this._createPackage(info));
}
/**
* Create a child package.
*
* @param info Package info.
* @returns Package instance.
*/
_createPackage(info) {
const Constructor = this.constructor;
return new Constructor(info, this);
}
}
exports.Package = Package;
//# sourceMappingURL=package.js.map