Skip to content

Commit

Permalink
Breaking: modernize syntax (Level/community#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
vweevers committed Apr 25, 2021
1 parent 0d06caf commit 012d3a9
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 44 deletions.
7 changes: 7 additions & 0 deletions .airtap.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
providers:
- airtap-playwright

browsers:
- name: chromium
- name: firefox
- name: webkit
4 changes: 0 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,3 @@ updates:
interval: monthly
ignore:
- dependency-name: dependency-check
- dependency-name: uuid
- dependency-name: tempy
- dependency-name: airtap
- dependency-name: standard
16 changes: 8 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict'

var compose = require('level-compose')
var leveldown = require('leveldown')
var memdown = require('memdown')
var encode = require('encoding-down')
var levelup = require('levelup')
var getLocation = require('./location')
const compose = require('level-compose')
const leveldown = require('leveldown')
const memdown = require('memdown')
const encode = require('encoding-down')
const levelup = require('levelup')
const getLocation = require('./location')

module.exports = function factory (down, defaults) {
if (typeof down !== 'function') {
Expand All @@ -17,8 +17,8 @@ module.exports = function factory (down, defaults) {
down = down || (defaults.mem ? memdown : leveldown)

// The layers option is experimental and undocumented. Use at your own risk.
var layers = defaults.layers || [encode, levelup]
var shell = compose([locationFallback, down, layers], defaults)
const layers = defaults.layers || [encode, levelup]
const shell = compose([locationFallback, down, layers], defaults)

return shell
}
Expand Down
2 changes: 1 addition & 1 deletion location-browser.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
'use strict'

module.exports = require('uuid/v4')
module.exports = require('uuid').v4
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"scripts": {
"test": "standard && hallmark && (nyc -s node test/node.js | faucet) && nyc report",
"coverage": "nyc report -r lcovonly",
"test-browser-local": "airtap --local test/browser.js",
"test-browsers-local": "airtap test/browser.js",
"hallmark": "hallmark --fix",
"dependency-check": "dependency-check . browser.js test/*.js",
"prepublishOnly": "npm run dependency-check"
Expand All @@ -22,12 +22,13 @@
"level-js": "^5.0.0",
"levelup": "^4.3.1",
"memdown": "^5.1.0",
"tempy": "^0.3.0",
"tempy": "^1.0.1",
"uuid": "^3.3.2"
},
"devDependencies": {
"abstract-leveldown": "^6.0.0",
"airtap": "^3.0.0",
"airtap": "^4.0.3",
"airtap-playwright": "^1.0.1",
"dependency-check": "^3.3.0",
"faucet": "^0.0.1",
"hallmark": "^3.1.0",
Expand All @@ -36,7 +37,7 @@
"level-packager": "^5.0.3",
"nyc": "^15.0.0",
"reachdown": "^1.0.0",
"standard": "^14.0.0",
"standard": "^16.0.3",
"tape": "^5.0.1"
},
"optionalDependencies": {
Expand Down
12 changes: 6 additions & 6 deletions test/browser.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
'use strict'

var leveljs = require('level-js')
var memdown = require('memdown')
var encode = require('encoding-down')
var levelup = require('levelup')
var levelTest = require('../')
var suite = require('./suite')
const leveljs = require('level-js')
const memdown = require('memdown')
const encode = require('encoding-down')
const levelup = require('levelup')
const levelTest = require('../')
const suite = require('./suite')

suite.args(levelTest(), leveljs)
suite.args(levelTest({ mem: true }), memdown)
Expand Down
14 changes: 7 additions & 7 deletions test/node.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
'use strict'

var leveldown = require('leveldown')
var memdown = require('memdown')
var jsondown = require('jsondown')
var encode = require('encoding-down')
var levelup = require('levelup')
var levelTest = require('../')
var suite = require('./suite')
const leveldown = require('leveldown')
const memdown = require('memdown')
const jsondown = require('jsondown')
const encode = require('encoding-down')
const levelup = require('levelup')
const levelTest = require('../')
const suite = require('./suite')

suite.args(levelTest(), leveldown)
suite.args(levelTest({ mem: true }), memdown)
Expand Down
28 changes: 14 additions & 14 deletions test/suite.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
'use strict'

var test = require('tape')
var reachdown = require('reachdown')
var packagerTests = require('level-packager/abstract/test')
const test = require('tape')
const reachdown = require('reachdown')
const packagerTests = require('level-packager/abstract/test')

exports.args = function (level, expectedDown) {
test('without arguments', function (t) {
t.plan(3)

var db = level()
const db = level()

db.on('open', function () {
t.ok(reachdown(db) instanceof expectedDown, 'got expected down')
Expand All @@ -28,8 +28,8 @@ exports.args = function (level, expectedDown) {
t.ok(db.isOpen())
t.ok(reachdown(db) instanceof expectedDown, 'got expected down')

var key = '' + Math.random()
var value = { test_key: '' + new Date() }
const key = '' + Math.random()
const value = { test_key: '' + new Date() }

db.put(key, value, function (err) {
t.notOk(err)
Expand All @@ -45,9 +45,9 @@ exports.args = function (level, expectedDown) {
test('with options', function (t) {
t.plan(4)

var db = level({ valueEncoding: 'json' })
var key = '' + Math.random()
var value = { test_key: '' + new Date() }
const db = level({ valueEncoding: 'json' })
const key = '' + Math.random()
const value = { test_key: '' + new Date() }

db.on('open', function () {
t.ok(reachdown(db) instanceof expectedDown, 'got expected down')
Expand Down Expand Up @@ -87,7 +87,7 @@ exports.customLayers = function (level, expectedDown, expectedUp, rawValue) {
test('custom layers with auto-open', function (t) {
t.plan(9)

var ret = level(function (err, db) {
const ret = level(function (err, db) {
t.ifError(err)
t.is(db, ret, 'got db')
t.ok(reachdown(db) instanceof expectedDown, 'got expected down')
Expand All @@ -114,10 +114,10 @@ exports.options = function (levelTest) {
test('opts precedence', function (t) {
t.plan(6)

var level = levelTest({ valueEncoding: 'utf8' })
var db1 = level()
var db2 = level({ valueEncoding: 'json' })
var value = { test: true }
const level = levelTest({ valueEncoding: 'utf8' })
const db1 = level()
const db2 = level({ valueEncoding: 'json' })
const value = { test: true }

db1.put('key', value, function (err) {
t.ifError(err)
Expand Down

0 comments on commit 012d3a9

Please sign in to comment.