Skip to content
This repository was archived by the owner on Dec 20, 2024. It is now read-only.

Commit 4770d17

Browse files
committed
Breaking: modernize syntax and bump standard (Level/community#98)
1 parent ef4b318 commit 4770d17

10 files changed

Lines changed: 52 additions & 47 deletions

File tree

.github/dependabot.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ updates:
77
ignore:
88
- dependency-name: dependency-check
99
- dependency-name: nyc
10-
- dependency-name: standard

abstract/base-test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
var location = require('./location')
3+
const location = require('./location')
44

55
module.exports = function (test, level) {
66
test('test db open and use, level(location, cb)', function (t) {
@@ -24,27 +24,27 @@ module.exports = function (test, level) {
2424
})
2525

2626
test('test db open and use, db=level(location)', function (t) {
27-
var db = level(location)
27+
const db = level(location)
2828
db.put('test3', 'success', function (err) {
2929
t.notOk(err, 'no error')
3030
db.close(t.end.bind(t))
3131
})
3232
})
3333

3434
test('options.keyEncoding and options.valueEncoding are passed on to encoding-down', function (t) {
35-
var db = level(location, { keyEncoding: 'json', valueEncoding: 'json' })
35+
const db = level(location, { keyEncoding: 'json', valueEncoding: 'json' })
3636
db.on('ready', function () {
37-
var codec = db.db.codec
37+
const codec = db.db.codec
3838
t.equal(codec.opts.keyEncoding, 'json', 'keyEncoding correct')
3939
t.equal(codec.opts.valueEncoding, 'json', 'valueEncoding correct')
4040
db.close(t.end.bind(t))
4141
})
4242
})
4343

4444
test('encoding options default to utf8', function (t) {
45-
var db = level(location)
45+
const db = level(location)
4646
db.on('ready', function () {
47-
var codec = db.db.codec
47+
const codec = db.db.codec
4848
t.equal(codec.opts.keyEncoding, 'utf8', 'keyEncoding correct')
4949
t.equal(codec.opts.valueEncoding, 'utf8', 'valueEncoding correct')
5050
db.close(t.end.bind(t))

abstract/db-values-test.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
'use strict'
22

3-
var location = require('./location')
3+
const location = require('./location')
44

55
module.exports = function (test, level, nonPersistent) {
66
test('test db values', function (t) {
7-
var c = 0
8-
var db = level(location)
9-
var setup = nonPersistent ? function (callback) {
10-
db.batch([
11-
{ type: 'put', key: 'test1', value: 'success' },
12-
{ type: 'put', key: 'test2', value: 'success' },
13-
{ type: 'put', key: 'test3', value: 'success' }
14-
], callback)
15-
} : function (callback) { callback() }
7+
let c = 0
8+
const db = level(location)
9+
const setup = nonPersistent
10+
? function (callback) {
11+
db.batch([
12+
{ type: 'put', key: 'test1', value: 'success' },
13+
{ type: 'put', key: 'test2', value: 'success' },
14+
{ type: 'put', key: 'test3', value: 'success' }
15+
], callback)
16+
}
17+
: function (callback) { callback() }
1618

1719
function read (err, value) {
1820
t.notOk(err, 'no error')

abstract/destroy-test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
'use strict'
22

3-
var fs = require('fs')
4-
var path = require('path')
5-
var location = require('./location')
3+
const fs = require('fs')
4+
const path = require('path')
5+
const location = require('./location')
66

77
module.exports = function (test, level) {
88
test('test destroy', function (t) {

abstract/error-if-exists-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
var location = require('./location')
3+
const location = require('./location')
44

55
module.exports = function (test, level) {
66
test('test db open and use, level(location, options, cb) force error', function (t) {

abstract/location.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
var path = require('path')
1+
'use strict'
2+
3+
const path = require('path')
24

35
module.exports = path.join(__dirname, 'level-test-' + process.pid + '.db')

abstract/repair-test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
var location = require('./location')
3+
const location = require('./location')
44

55
module.exports = function (test, level) {
66
test('test repair', function (t) {

level-packager.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
var levelup = require('levelup')
2-
var encode = require('encoding-down')
1+
'use strict'
2+
3+
const levelup = require('levelup')
4+
const encode = require('encoding-down')
35

46
function packager (leveldown) {
57
function Level (location, options, callback) {
@@ -20,13 +22,13 @@ function packager (leveldown) {
2022
return typeof o === 'object' && o !== null
2123
}
2224

23-
['destroy', 'repair'].forEach(function (m) {
25+
for (const m of ['destroy', 'repair']) {
2426
if (typeof leveldown[m] === 'function') {
25-
Level[m] = function () {
26-
leveldown[m].apply(leveldown, arguments)
27+
Level[m] = function (...args) {
28+
leveldown[m](...args)
2729
}
2830
}
29-
})
31+
}
3032

3133
Level.errors = levelup.errors
3234

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"hallmark": "^3.1.0",
2222
"level-community": "^3.0.0",
2323
"nyc": "^14.0.0",
24-
"standard": "^14.0.0",
24+
"standard": "^16.0.3",
2525
"tape": "^5.0.1"
2626
},
2727
"hallmark": {

test.js

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

3-
var test = require('tape')
4-
var packager = require('.')
3+
const test = require('tape')
4+
const packager = require('.')
55

66
test('Level constructor has access to levelup errors', function (t) {
77
function Down () {}
@@ -18,16 +18,16 @@ test('Level constructor relays .destroy and .repair if they exist', function (t)
1818
function test (method) {
1919
function Down () {}
2020

21-
Down[method] = function () {
22-
t.same([].slice.call(arguments), args, 'supports variadic arguments')
21+
Down[method] = function (...actual) {
22+
t.same(actual, expected, 'supports variadic arguments')
2323
}
2424

25-
var level = packager(Down)
26-
var args = []
25+
const level = packager(Down)
26+
const expected = []
2727

28-
for (var i = 0; i < 4; i++) {
29-
args.push(i)
30-
level[method].apply(level, args)
28+
for (let i = 0; i < 4; i++) {
29+
expected.push(i)
30+
level[method](...expected)
3131
}
3232
}
3333
})
@@ -48,7 +48,7 @@ test('Level constructor', function (t) {
4848
}
4949
}
5050
}
51-
var levelup = packager(Down)()
51+
const levelup = packager(Down)()
5252
t.is(levelup.options.keyEncoding, 'utf8')
5353
t.is(levelup.options.valueEncoding, 'utf8')
5454
})
@@ -68,7 +68,7 @@ test('Level constructor with location', function (t) {
6868
}
6969
}
7070
}
71-
var levelup = packager(Down)('location')
71+
const levelup = packager(Down)('location')
7272
t.is(levelup.options.keyEncoding, 'utf8')
7373
t.is(levelup.options.valueEncoding, 'utf8')
7474
})
@@ -134,7 +134,7 @@ test('Level constructor with location & callback', function (t) {
134134

135135
test('Level constructor with location & options passed to levelup', function (t) {
136136
t.plan(4)
137-
var Down = function (location) {
137+
const Down = function (location) {
138138
t.is(location, 'location', 'location is correct')
139139
return {
140140
open: function (opts, cb) {
@@ -147,7 +147,7 @@ test('Level constructor with location & options passed to levelup', function (t)
147147
}
148148
}
149149
}
150-
var levelup = packager(Down)('location', {
150+
const levelup = packager(Down)('location', {
151151
keyEncoding: 'binary',
152152
valueEncoding: 'binary'
153153
})
@@ -157,7 +157,7 @@ test('Level constructor with location & options passed to levelup', function (t)
157157

158158
test('Level constructor with options passed to levelup', function (t) {
159159
t.plan(3)
160-
var Down = function () {
160+
const Down = function () {
161161
return {
162162
open: function (opts, cb) {
163163
t.same(opts, {
@@ -169,7 +169,7 @@ test('Level constructor with options passed to levelup', function (t) {
169169
}
170170
}
171171
}
172-
var levelup = packager(Down)({
172+
const levelup = packager(Down)({
173173
keyEncoding: 'binary',
174174
valueEncoding: 'binary'
175175
})
@@ -179,7 +179,7 @@ test('Level constructor with options passed to levelup', function (t) {
179179

180180
test('Level constructor with options & callback passed to levelup', function (t) {
181181
t.plan(5)
182-
var Down = function () {
182+
const Down = function () {
183183
return {
184184
open: function (opts, cb) {
185185
t.same(opts, {
@@ -192,7 +192,7 @@ test('Level constructor with options & callback passed to levelup', function (t)
192192
}
193193
}
194194
}
195-
var levelup = packager(Down)({
195+
const levelup = packager(Down)({
196196
keyEncoding: 'binary',
197197
valueEncoding: 'binary'
198198
}, function (err, db) {

0 commit comments

Comments
 (0)