From 39e3ca34864c9fc55a70bb3359e99341752ed041 Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Fri, 9 Apr 2021 23:41:10 +0200 Subject: [PATCH] Bump standard from 15.x to 16.x --- .github/dependabot.yml | 1 - chained-batch.js | 2 ++ iterator.js | 12 ++++++------ leveldown.js | 2 ++ package.json | 2 +- test/approximate-size-test.js | 6 +++--- test/cleanup-hanging-iterators-test.js | 10 +++++----- test/compact-range-test.js | 12 ++++++------ test/compression-test.js | 8 ++++---- test/destroy-test.js | 14 +++++++------- test/getproperty-test.js | 4 ++-- test/iterator-recursion-test.js | 14 +++++++------- test/iterator-test.js | 18 +++++++++--------- test/leak-tester-iterator.js | 2 +- test/make.js | 4 ++-- test/port-libuv-fix-test.js | 5 ++--- test/repair-test.js | 4 ++-- test/stack-blower.js | 4 ++-- 18 files changed, 63 insertions(+), 61 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index becce3fe..809d16bc 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -8,5 +8,4 @@ updates: - dependency-name: dependency-check - dependency-name: cross-env - dependency-name: node-gyp - - dependency-name: standard - dependency-name: tempy diff --git a/chained-batch.js b/chained-batch.js index 0bd9a673..ab7a743c 100644 --- a/chained-batch.js +++ b/chained-batch.js @@ -1,3 +1,5 @@ +'use strict' + const util = require('util') const AbstractChainedBatch = require('abstract-leveldown').AbstractChainedBatch const binding = require('./binding') diff --git a/iterator.js b/iterator.js index 2115eef2..2805c331 100644 --- a/iterator.js +++ b/iterator.js @@ -1,3 +1,5 @@ +'use strict' + const util = require('util') const AbstractIterator = require('abstract-leveldown').AbstractIterator const binding = require('./binding') @@ -23,19 +25,17 @@ Iterator.prototype._seek = function (target) { } Iterator.prototype._next = function (callback) { - var that = this - if (this.cache && this.cache.length) { process.nextTick(callback, null, this.cache.pop(), this.cache.pop()) } else if (this.finished) { process.nextTick(callback) } else { - binding.iterator_next(this.context, function (err, array, finished) { + binding.iterator_next(this.context, (err, array, finished) => { if (err) return callback(err) - that.cache = array - that.finished = finished - that._next(callback) + this.cache = array + this.finished = finished + this._next(callback) }) } diff --git a/leveldown.js b/leveldown.js index efb31f62..ad7d0abe 100644 --- a/leveldown.js +++ b/leveldown.js @@ -1,3 +1,5 @@ +'use strict' + const util = require('util') const AbstractLevelDOWN = require('abstract-leveldown').AbstractLevelDOWN const binding = require('./binding') diff --git a/package.json b/package.json index bf8e4f26..d3e4e171 100644 --- a/package.json +++ b/package.json @@ -49,7 +49,7 @@ "prebuildify-cross": "^4.0.0", "readfiletree": "^1.0.0", "rimraf": "^3.0.0", - "standard": "^15.0.0", + "standard": "^16.0.3", "tape": "^5.0.1", "tempy": "^0.3.0" }, diff --git a/test/approximate-size-test.js b/test/approximate-size-test.js index 159bd92a..e1adc4d4 100644 --- a/test/approximate-size-test.js +++ b/test/approximate-size-test.js @@ -1,7 +1,7 @@ const test = require('tape') const testCommon = require('./common') -var db +let db test('setUp common for approximate size', testCommon.setUp) @@ -66,7 +66,7 @@ test('test 1-arg + callback approximateSize() throws', function (t) { test('test custom _serialize*', function (t) { t.plan(4) - var db = testCommon.factory() + const db = testCommon.factory() db._serializeKey = function (data) { return data } db.approximateSize = function (start, end, callback) { t.deepEqual(start, { foo: 'bar' }) @@ -82,7 +82,7 @@ test('test custom _serialize*', function (t) { }) test('test approximateSize()', function (t) { - var data = Array.apply(null, Array(10000)).map(function () { + const data = Array.apply(null, Array(10000)).map(function () { return 'aaaaaaaaaa' }).join('') diff --git a/test/cleanup-hanging-iterators-test.js b/test/cleanup-hanging-iterators-test.js index 5ff54103..89578a28 100644 --- a/test/cleanup-hanging-iterators-test.js +++ b/test/cleanup-hanging-iterators-test.js @@ -3,7 +3,7 @@ const repeats = 200 makeTest('test ended iterator', function (db, t, done) { // First test normal and proper usage: calling it.end() before db.close() - var it = db.iterator({ keyAsBuffer: false, valueAsBuffer: false }) + const it = db.iterator({ keyAsBuffer: false, valueAsBuffer: false }) it.next(function (err, key, value) { t.ifError(err, 'no error from next()') @@ -19,7 +19,7 @@ makeTest('test ended iterator', function (db, t, done) { makeTest('test likely-ended iterator', function (db, t, done) { // Test improper usage: not calling it.end() before db.close(). Cleanup of the // database will crash Node if not handled properly. - var it = db.iterator({ keyAsBuffer: false, valueAsBuffer: false }) + const it = db.iterator({ keyAsBuffer: false, valueAsBuffer: false }) it.next(function (err, key, value) { t.ifError(err, 'no error from next()') @@ -33,7 +33,7 @@ makeTest('test non-ended iterator', function (db, t, done) { // Same as the test above but with a highWaterMark of 0 so that we don't // preemptively fetch all records, to ensure that the iterator is still // active when we (attempt to) close the database. - var it = db.iterator({ + const it = db.iterator({ highWaterMark: 0, keyAsBuffer: false, valueAsBuffer: false @@ -84,10 +84,10 @@ global.gc && makeTest('test multiple non-ended iterators with forced gc', functi makeTest('test ending iterators', function (db, t, done) { // At least one end() should be in progress when we try to close the db. - var it1 = db.iterator().next(function () { + const it1 = db.iterator().next(function () { it1.end(function () {}) }) - var it2 = db.iterator().next(function () { + const it2 = db.iterator().next(function () { it2.end(function () {}) done() }) diff --git a/test/compact-range-test.js b/test/compact-range-test.js index f4fe4d57..286da619 100644 --- a/test/compact-range-test.js +++ b/test/compact-range-test.js @@ -11,10 +11,10 @@ test('setUp db', function (t) { }) test('test compactRange() frees disk space after key deletion', function (t) { - var key1 = '000000' - var key2 = '000001' - var val1 = Buffer.allocUnsafe(64).fill(1) - var val2 = Buffer.allocUnsafe(64).fill(1) + const key1 = '000000' + const key2 = '000001' + const val1 = Buffer.allocUnsafe(64).fill(1) + const val2 = Buffer.allocUnsafe(64).fill(1) db.batch().put(key1, val1).put(key2, val2).write(function (err) { t.ifError(err, 'no batch put error') @@ -46,8 +46,8 @@ test('test compactRange() frees disk space after key deletion', function (t) { test('test compactRange() serializes start and end', function (t) { t.plan(3) - var clone = Object.create(db) - var count = 0 + const clone = Object.create(db) + let count = 0 clone._serializeKey = function (key) { t.is(key, count++) diff --git a/test/compression-test.js b/test/compression-test.js index 63c715da..e233f0d8 100644 --- a/test/compression-test.js +++ b/test/compression-test.js @@ -26,7 +26,7 @@ const verify = function (location, compression, t) { // close, open, close again.. 'compaction' is also performed on open()s const cycle = function (db, compression, t, callback) { - var location = db.location + const location = db.location db.close(function (err) { t.error(err) db = leveldown(location) @@ -45,7 +45,7 @@ test('compression', function (t) { t.test('set up', testCommon.setUp) t.test('test data is compressed by default (db.put())', function (t) { - var db = testCommon.factory() + const db = testCommon.factory() db.open(function (err) { t.error(err) each( @@ -59,7 +59,7 @@ test('compression', function (t) { }) t.test('test data is not compressed with compression=false on open() (db.put())', function (t) { - var db = testCommon.factory() + const db = testCommon.factory() db.open({ compression: false }, function (err) { t.error(err) each( @@ -73,7 +73,7 @@ test('compression', function (t) { }) t.test('test data is compressed by default (db.batch())', function (t) { - var db = testCommon.factory() + const db = testCommon.factory() db.open(function (err) { t.error(err) db.batch( diff --git a/test/destroy-test.js b/test/destroy-test.js index 68029f48..be1dc2e8 100644 --- a/test/destroy-test.js +++ b/test/destroy-test.js @@ -27,8 +27,8 @@ test('test callback-less, 1-arg, destroy() throws', function (t) { test('test destroy non-existent directory', function (t) { t.plan(4) - var location = tempy.directory() - var parent = path.dirname(location) + const location = tempy.directory() + const parent = path.dirname(location) // For symmetry with the opposite test below. t.ok(fs.existsSync(parent), 'parent exists before') @@ -50,8 +50,8 @@ test('test destroy non-existent directory', function (t) { test('test destroy non-existent parent directory', function (t) { t.plan(3) - var location = '/1/2/3/4' - var parent = path.dirname(location) + const location = '/1/2/3/4' + const parent = path.dirname(location) t.notOk(fs.existsSync(parent), 'parent does not exist before') @@ -62,7 +62,7 @@ test('test destroy non-existent parent directory', function (t) { }) test('test destroy non leveldb directory', function (t) { - var tree = { + const tree = { foo: 'FOO', bar: { one: 'ONE', two: 'TWO', three: 'THREE' } } @@ -87,7 +87,7 @@ test('test destroy non leveldb directory', function (t) { }) makeTest('test destroy() cleans and removes leveldb-only dir', function (db, t, done) { - var location = db.location + const location = db.location db.close(function (err) { t.ifError(err, 'no error from close()') @@ -101,7 +101,7 @@ makeTest('test destroy() cleans and removes leveldb-only dir', function (db, t, }) makeTest('test destroy() cleans and removes only leveldb parts of a dir', function (db, t, done) { - var location = db.location + const location = db.location fs.writeFileSync(path.join(location, 'foo'), 'FOO') db.close(function (err) { diff --git a/test/getproperty-test.js b/test/getproperty-test.js index fa072c63..d27b1de0 100644 --- a/test/getproperty-test.js +++ b/test/getproperty-test.js @@ -33,7 +33,7 @@ test('test invalid getProperty() returns empty string', function (t) { }) test('test invalid getProperty("leveldb.num-files-at-levelN") returns numbers', function (t) { - for (var i = 0; i < 7; i++) { + for (let i = 0; i < 7; i++) { t.equal(db.getProperty('leveldb.num-files-at-level' + i), '0', '"leveldb.num-files-at-levelN" === "0"') } @@ -46,7 +46,7 @@ test('test invalid getProperty("leveldb.stats")', function (t) { }) test('test invalid getProperty("leveldb.sstables")', function (t) { - var expected = [0, 1, 2, 3, 4, 5, 6].map(function (l) { + const expected = [0, 1, 2, 3, 4, 5, 6].map(function (l) { return '--- level ' + l + ' ---' }).join('\n') + '\n' t.equal(db.getProperty('leveldb.sstables'), expected, 'leveldb.sstables') diff --git a/test/iterator-recursion-test.js b/test/iterator-recursion-test.js index 84b40f0b..aa4b96e1 100644 --- a/test/iterator-recursion-test.js +++ b/test/iterator-recursion-test.js @@ -6,9 +6,9 @@ const path = require('path') let db const sourceData = (function () { - var d = [] - var i = 0 - var k + const d = [] + let i = 0 + let k for (; i < 100000; i++) { k = (i < 10 ? '0' : '') + i d.push({ @@ -37,8 +37,8 @@ test.skip('try to create an iterator with a blown stack', function (t) { // Reducing the stack size down from the default 984 for the child node // process makes it easier to trigger the bug condition. But making it too low // causes the child process to die for other reasons. - var opts = { execArgv: ['--stack-size=128'] } - var child = fork(path.join(__dirname, 'stack-blower.js'), ['run'], opts) + const opts = { execArgv: ['--stack-size=128'] } + const child = fork(path.join(__dirname, 'stack-blower.js'), ['run'], opts) child.on('message', function (m) { t.ok(true, m) @@ -64,10 +64,10 @@ test('setUp db', function (t) { }) test('iterate over a large iterator with a large watermark', function (t) { - var iterator = db.iterator({ + const iterator = db.iterator({ highWaterMark: 10000000 }) - var read = function () { + const read = function () { iterator.next(function () { if (!arguments.length) { t.end() diff --git a/test/iterator-test.js b/test/iterator-test.js index 1a03b7cf..760e7360 100644 --- a/test/iterator-test.js +++ b/test/iterator-test.js @@ -3,12 +3,12 @@ const make = require('./make') // This test isn't included in abstract-leveldown because // the empty-check is currently performed by leveldown. make('iterator#seek throws if target is empty', function (db, t, done) { - var targets = ['', Buffer.alloc(0), []] - var pending = targets.length + const targets = ['', Buffer.alloc(0), []] + let pending = targets.length targets.forEach(function (target) { - var ite = db.iterator() - var error + const ite = db.iterator() + let error try { ite.seek(target) @@ -27,7 +27,7 @@ make('iterator#seek throws if target is empty', function (db, t, done) { }) make('iterator optimized for seek', function (db, t, done) { - var batch = db.batch() + const batch = db.batch() batch.put('a', 1) batch.put('b', 1) batch.put('c', 1) @@ -36,7 +36,7 @@ make('iterator optimized for seek', function (db, t, done) { batch.put('f', 1) batch.put('g', 1) batch.write(function (err) { - var ite = db.iterator() + const ite = db.iterator() t.ifError(err, 'no error from batch()') ite.next(function (err, key, value) { t.ifError(err, 'no error from next()') @@ -65,9 +65,9 @@ make('iterator optimized for seek', function (db, t, done) { }) make('close db with open iterator', function (db, t, done) { - var ite = db.iterator() - var cnt = 0 - var hadError = false + const ite = db.iterator() + let cnt = 0 + let hadError = false ite.next(function loop (err, key, value) { if (cnt++ === 0) { diff --git a/test/leak-tester-iterator.js b/test/leak-tester-iterator.js index 5e2cc593..604d7754 100644 --- a/test/leak-tester-iterator.js +++ b/test/leak-tester-iterator.js @@ -8,7 +8,7 @@ if (!global.gc) { } function run () { - var it = db.iterator() + const it = db.iterator() it.next(function (err) { if (err) throw err diff --git a/test/make.js b/test/make.js index 61fff6d3..ba260d3b 100644 --- a/test/make.js +++ b/test/make.js @@ -3,8 +3,8 @@ const testCommon = require('./common') function makeTest (name, testFn) { test(name, function (t) { - var db = testCommon.factory() - var done = function (err, close) { + const db = testCommon.factory() + const done = function (err, close) { t.ifError(err, 'no error from done()') if (close === false) { diff --git a/test/port-libuv-fix-test.js b/test/port-libuv-fix-test.js index 496d76a7..c928681f 100644 --- a/test/port-libuv-fix-test.js +++ b/test/port-libuv-fix-test.js @@ -3,13 +3,12 @@ const path = require('path') const fs = require('fs') test('test port-libuv is being used', function (t) { - var version = fs.readFileSync(path.join(__dirname, '../deps/leveldb/leveldb.gyp'), 'utf8') + const version = fs.readFileSync(path.join(__dirname, '../deps/leveldb/leveldb.gyp'), 'utf8') .match(/"ldbversion": "([^"]+)"/)[1] - var porth t.ok(version, 'matched current leveldb version') - porth = fs.readFileSync(path.join(__dirname, '../deps/leveldb/leveldb-' + version + '/port/port.h'), 'utf8') + const porth = fs.readFileSync(path.join(__dirname, '../deps/leveldb/leveldb-' + version + '/port/port.h'), 'utf8') t.ok(/"port_uv\.h"/.test(porth), 'port.h includes reference to port_uv.h') diff --git a/test/repair-test.js b/test/repair-test.js index 9dc03d48..6112c262 100644 --- a/test/repair-test.js +++ b/test/repair-test.js @@ -32,12 +32,12 @@ test('test repair non-existent directory returns error', function (t) { // a proxy indicator that RepairDB is being called and doing its thing makeTest('test repair() compacts', function (db, t, done) { - var location = db.location + const location = db.location db.close(function (err) { t.ifError(err, 'no error from close()') - var files = fs.readdirSync(location) + let files = fs.readdirSync(location) t.ok(files.some(function (f) { return (/\.log$/).test(f) }), 'directory contains log file(s)') t.notOk(files.some(function (f) { return (/\.ldb$/).test(f) }), 'directory does not contain ldb file(s)') diff --git a/test/stack-blower.js b/test/stack-blower.js index b802b0eb..24f0a18c 100644 --- a/test/stack-blower.js +++ b/test/stack-blower.js @@ -8,8 +8,8 @@ const testCommon = require('./common') if (process.argv[2] === 'run') { - var db = testCommon.factory() - var depth = 0 + const db = testCommon.factory() + let depth = 0 db.open(function () { function recurse () {