// const pool = require('./pool'); /** * Send all received {Object} to a host command * * Script: * * ```ini * [fasttext] * ``` * * @name exec * @param {String} [command] host command * @param {String} [args] argument for command * @param {Number} [concurrency = auto] Number of processes to launch concurrency * @returns {Object} */ // async function fasttext(data, feed, ctx) { // const command = [] // .concat(ctx.getParam('command')) // .filter(Boolean) // .shift(); // const args = [] // .concat(ctx.getParam('args')) // .filter(Boolean); // const concurrency = Number([] // .concat(ctx.getParam('concurrency', ctx.settings.concurrency)) // .filter(Boolean) // .shift()); // let handle; // try { // handle = await pool.startup(concurrency, command, args); // if (!this.resource) { // this.input = ctx.createStream(ctx.objectMode()); // this.resource = await handle.acquire(); // this.input.pipe(ctx('pack')).pipe(this.resource.stdin); // const output = this.resource.stdout.pipe(ctx('unpack')); // this.resource.once('error', (err) => feed.stop(err)); // this.resource.once('exit', (exitCode) => { // if (exitCode !== 0) { // handle.destroy(this.resource); // return feed.stop(new Error(`${command} exit with code ${exitCode}`)); // } // return output.end(); // }); // this.whenFinish = feed.flow(output); // } // if (ctx.isLast()) { // this.whenFinish // .then(() => { // handle.destroy(this.resource); // feed.close(); // }) // .catch((e) => feed.stop(e)); // return this.input.end(); // } // return ctx.writeTo(this.input, data, () => feed.end()); // } catch (e) { // /* istanbul ignore next */ // if (this.resource) { // node version < 14.17 // handle.destroy(this.resource); // } // handle.close(); // return feed.stop(e); // } // } // exports.default = { // fasttext, // }; const fasttext = (data, feed, ctx) => { if (ctx.isLast()) { return feed.close(); } const curval = data; return feed.send({ value: curval }); } exports.default = { fasttext, }