From 7ba3ea658fb4c4f04a27f432944a9e8bfdf3ebdb Mon Sep 17 00:00:00 2001 From: ale Date: Fri, 15 Nov 2024 21:05:18 +0100 Subject: [PATCH] refactor blockcount --- lib/apiswagger.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/apiswagger.js b/lib/apiswagger.js index dcee05c..dcb9bbe 100644 --- a/lib/apiswagger.js +++ b/lib/apiswagger.js @@ -473,12 +473,12 @@ module.exports = (app, client) => { parser(), pick({ filter: 'hits.hits' }), streamArray(), - data => ({ instance: data.value._source.instance, comment: data.value._source.blocks.find(block => block.domain === clean(req.params.instance)).comment }), - stringer() + data => ({ instance: data.value._source.instance, comment: data.value._source.blocks.find(block => block.domain === clean(req.params.instance)).comment }) ]) - res.once('data', data => '[' + data.toString()) - res.on('finish', () => res.end(']')) - result.pipe(pipeline).pipe(res) + result.on('readable', () => res.write('[')) + pipeline.on('data', data => res.write(data.toString() + ',')) + pipeline.on('finish', () => res.end(']')) + result.pipe(pipeline) } else { res.status(404).end() }