UNPKG

log4js2

Version:

[![Build Status](https://travis-ci.org/anigenero/log4js2.svg?branch=master)](https://travis-ci.org/anigenero/log4js2) [![codecov](https://codecov.io/gh/anigenero/log4js2/branch/master/graph/badge.svg)](https://codecov.io/gh/anigenero/log4js2)

69 lines 1.78 kB
Object.defineProperty(exports, "__esModule", { value: true }); class Marker { /** * Hide the constructor. We don't want people to arbitrarily make these without access to Marker#getMarker * @param {string} name */ constructor(name) { this._parents = null; this._name = name; } /** * Gets the marker for the specified name * @param {string} name * @returns {Marker} */ static getMarker(name) { if (!Marker._markers.hasOwnProperty(name)) { Marker._markers[name] = new Marker(name); } return Marker._markers[name]; } /** * The name of the marker * @returns {string} */ get name() { return this._name; } /** * Gets the parents of the marker. This converts the WeakSet into an array * @returns {Marker[]} */ getParents() { if (this._parents === null) { return []; } const result = []; this._parents.forEach((marker) => result.push(marker)); return result; } /** * Returns whether or not the marker has parents * @returns {boolean} */ hasParents() { return this._parents !== null; } /** * Removes the specified marker as a parent * @param {Marker} marker */ remove(marker) { this._parents.delete(marker); } /** * Sets the parent markers by replacing the current set * @param {Marker} markers */ setParents(...markers) { this._parents = new Set(); let index = markers.length; while (index--) { this._parents.add(markers[index]); } } } Marker._markers = {}; exports.default = Marker; //# sourceMappingURL=marker.js.map