@barchart/common-js
Version:
Library of common JavaScript utilities
92 lines (86 loc) • 2.2 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var Edge_exports = {};
__export(Edge_exports, {
default: () => Edge
});
module.exports = __toCommonJS(Edge_exports);
class Edge {
#from;
#to;
#data;
/**
* @param {Vertex} from
* @param {Vertex} to
* @param {*=} data
*/
constructor(from, to, data) {
this.#from = from;
this.#to = to;
this.#data = data || null;
}
/**
* The starting vertex.
*
* @public
* @returns {Vertex}
*/
get from() {
return this.#from;
}
/**
* The end vertex.
*
* @public
* @returns {Vertex}
*/
get to() {
return this.#to;
}
/**
* Ad hoc data associated with the edge (in other words the "value"
* of the edge).
*
* @public
* @returns {*|null}
*/
get data() {
return this.#data;
}
/**
* Returns a string representation.
*
* @public
* @returns {string}
*/
toString() {
return `[Edge (from=${this.from.data.toString()}, to=${this.to.data.toString()}})]`;
}
}
{
const cjsExports = module.exports;
const cjsDefaultExport = cjsExports && cjsExports.__esModule ? cjsExports.default : cjsExports;
if (cjsDefaultExport && (typeof cjsDefaultExport === 'function' || typeof cjsDefaultExport === 'object')) {
Object.keys(cjsExports).forEach((key) => {
if (key !== 'default' && key !== '__esModule') {
cjsDefaultExport[key] = cjsExports[key];
}
});
}
module.exports = cjsDefaultExport;
}