UNPKG

@log4js2/core

Version:

log4js2 is a fast and lightweight logging library that enables logging flexibility within JavaScript/TypeScript applications, similar to Apache's [Log4j2 library](https://logging.apache.org/log4j/2.x/). It can also serve as a drop-in replacement for log4

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