UNPKG

dino-core

Version:

A dependency injection framework for NodeJS applications

47 lines 1.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Optional = void 0; const object_helper_1 = require("../helper/object.helper"); /** * Implements the Optional patters * @public * @class */ class Optional { /** * Create a new instance of optional * @param value the value set as optional * @private */ constructor(value) { this.value = value; } /** * Allows to access this optional value * @returns this optional value * @public */ get() { return this.value; } /** * Validate is this optional value is present * @returns true if this optional contains a not null and not undefined value, false otherwise * @public */ isPresent() { return object_helper_1.ObjectHelper.isDefined(this.value); } /** * Create an optional starting from the provided value. * @param value the value to set on this optional. The value can be undefined or null * @returns a new Optional instance * @public * @static */ static from(value) { return new Optional(value); } } exports.Optional = Optional; //# sourceMappingURL=Optional.js.map