From a2a5f6bfe268726212a95993beaf678dbd09e828 Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Wed, 4 Jul 2018 12:35:44 +0200 Subject: [PATCH] Refactor collectEntries() into level-concat-iterator --- package.json | 1 + testCommon.js | 18 +----------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 97063874..12f0af5b 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ }, "devDependencies": { "airtap": "0.0.8", + "level-concat-iterator": "^2.0.0", "rimraf": "^2.6.1", "sinon": "^6.0.0", "standard": "^11.0.0", diff --git a/testCommon.js b/testCommon.js index 787eb9fa..b907d197 100644 --- a/testCommon.js +++ b/testCommon.js @@ -1,6 +1,7 @@ var path = require('path') var fs = !process.browser && require('fs') var rimraf = !process.browser && require('rimraf') +var collectEntries = require('level-concat-iterator') var dbidx = 0 @@ -46,23 +47,6 @@ var tearDown = function (t) { setUp(t) // same cleanup! } -var collectEntries = function (iterator, callback) { - var data = [] - var next = function () { - iterator.next(function (err, key, value) { - if (err) return callback(err) - if (!arguments.length) { - return iterator.end(function (err) { - callback(err, data) - }) - } - data.push({ key: key, value: value }) - setTimeout(next, 0) - }) - } - next() -} - module.exports = { location: location, cleanup: cleanup,