UNPKG

@hapiness/core

Version:

Project to have a HapiJS (https://hapijs.com/) based framework to create easier NodeJS back-end with some awesome features

49 lines 1.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); require("reflect-metadata"); /** * Helper to extract Metadata * from a decorator * * @todo Filter with the right type * @param {any} type * @returns any */ function extractMetadata(type) { return extractMetadatas(type) .pop(); } exports.extractMetadata = extractMetadata; ; /** * Helper to extract Metadata * with the decorator name provided * * @param {any} type * @param {string} name */ function extractMetadataByDecorator(type, name) { return extractMetadatas(type) .filter(x => x.toString().slice(1) === name) .map(x => x) .pop(); } exports.extractMetadataByDecorator = extractMetadataByDecorator; /** * Helper to extract Metadata * from a decorator * * @todo Filter with the right type * @param {any} decorator * @returns [] */ function extractMetadatas(decorator) { return Reflect.getOwnMetadataKeys(decorator) .filter(x => x === 'annotations') .map(x => Reflect.getOwnMetadata(x, decorator)) .map(x => [].concat(x)) .pop() || []; } exports.extractMetadatas = extractMetadatas; ; //# sourceMappingURL=metadata.js.map