UNPKG

@argdown/node

Version:

Async Argdown application for node.js

33 lines 1.25 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.StdOutPlugin = void 0; const lodash_defaultsdeep_1 = __importDefault(require("lodash.defaultsdeep")); class StdOutPlugin { constructor(config) { this.name = "StdOutPlugin"; this.prepare = request => { (0, lodash_defaultsdeep_1.default)(this.getSettings(request), this.defaults); }; this.run = (request, response) => { const settings = this.getSettings(request); if (settings.dataKey) { let content = !settings.isRequestData ? response[settings.dataKey] : request[settings.dataKey]; if (content !== undefined) { process.stdout.write(content); } } }; this.defaults = (0, lodash_defaultsdeep_1.default)({}, config, {}); } getSettings(request) { request.stdout = request.stdout || {}; return request.stdout; } } exports.StdOutPlugin = StdOutPlugin; //# sourceMappingURL=StdOutPlugin.js.map