UNPKG

dino-core

Version:

A dependency injection framework for NodeJS applications

61 lines 2.01 kB
"use strict"; // Copyright 2018 Quirino Brizi [quirino.brizi@gmail.com] // // 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. Object.defineProperty(exports, "__esModule", { value: true }); exports.State = void 0; /** * A value object responsible to carry information about the runtime of a service or component. * * @typedef State * @public */ class State { constructor() { this.properties = new Map(); } /** * Allows to access the internal property Map * @returns {Map} the properties Map */ getProperties() { return this.properties; } /** * Allows to add a property to the internal Map. * @param {String} name the name of the property * @param {Any} value the value associated with the property * @returns {State} this object */ setProperty(name, value) { this.properties.set(name, value); return this; } static create() { return new State(); } /** * Convenient method to create a State with the provided properties. * @param {Map<String, Any>} properties the properties to add to thi state */ static from(properties) { const state = new State(); (properties ?? new Map()).forEach((value, key) => state.setProperty(key, value)); return state; } static measures() { return Object.freeze({ uptime: 'uptime', state: 'state' }); } } exports.State = State; //# sourceMappingURL=state.js.map