UNPKG

nope-js-node

Version:

NoPE Runtime for Nodejs. For Browser-Support please use nope-browser

69 lines (68 loc) 2.63 kB
"use strict"; /** * @author Martin Karkowski * @email m.karkowski@zema.de */ Object.defineProperty(exports, "__esModule", { value: true }); exports.nopeEmitter = exports.nopeProperty = exports.nopeMethod = void 0; const objectMethods_1 = require("../helpers/objectMethods"); const container_1 = require("./container"); const CONTAINER = (0, container_1.getCentralDecoratedContainer)(); /** * Decorator, used to export the Method as Service to Nope.. * @param options The options used for linking. */ function nopeMethod(options) { // Now lets make shure, we are using the correct type // provide inputs and outputs. (0, objectMethods_1.rsetattr)(options, "schema/type", "function"); (0, objectMethods_1.rsetattr)(options, "schema/inputs", (0, objectMethods_1.rgetattr)(options, "schema/inputs", [])); (0, objectMethods_1.rsetattr)(options, "schema/outputs", (0, objectMethods_1.rgetattr)(options, "schema/outputs", [])); return function (target, methodName, descriptor) { // Add the Target to the class. CONTAINER.classes.set(target.constructor.name, target); target._markedElements = target._markedElements || []; target._markedElements.push({ accessor: methodName, options, type: "method", }); }; } exports.nopeMethod = nopeMethod; /** * Decorator, will link the Parameter to Nope and make it available. it available as * Nope-Property. * @param options The Options, describing the settings for linking. */ function nopeProperty(options) { return function (target, propertyKey, descriptor) { // Add the Target to the class. CONTAINER.classes.set(target.constructor.name, target); target._markedElements = target._markedElements || []; target._markedElements.push({ accessor: propertyKey, options, type: "prop", }); }; } exports.nopeProperty = nopeProperty; /** * Decorator, that will link the Parameter to Nope and make it available as * Event Emitter. * @param options The Options, describing the settings for linking. */ function nopeEmitter(options) { return function (target, propertyKey, descriptor) { // Add the Target to the class. CONTAINER.classes.set(target.constructor.name, target); target._markedElements = target._markedElements || []; target._markedElements.push({ accessor: propertyKey, options, type: "event", }); }; } exports.nopeEmitter = nopeEmitter;