Skip to content

Commit 5d7cc6d

Browse files
committed
Breaking: modernize syntax and bump standard
Drops support of node 6, node 8 and old browsers. Ref Level/community#98
1 parent 7e7692a commit 5d7cc6d

File tree

8 files changed

+42
-45
lines changed

8 files changed

+42
-45
lines changed

.airtap.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
providers:
2+
- airtap-playwright
3+
4+
browsers:
5+
- name: chromium
6+
- name: firefox
7+
- name: webkit

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
language: node_js
22

33
node_js:
4-
- 6
5-
- 8
64
- 10
75
- 12
6+
- 14
87

98
after_success: npm run coverage

index.js

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

3-
// For (old) browser support
4-
var xtend = require('xtend')
5-
var assign = require('xtend/mutable')
3+
module.exports = function supports (...manifests) {
4+
const manifest = manifests.reduce((acc, m) => Object.assign(acc, m), {})
65

7-
module.exports = function supports () {
8-
var manifest = xtend.apply(null, arguments)
9-
10-
return assign(manifest, {
6+
return Object.assign(manifest, {
117
// Features of abstract-leveldown
128
bufferKeys: manifest.bufferKeys || false,
139
snapshots: manifest.snapshots || false,
@@ -30,6 +26,6 @@ module.exports = function supports () {
3026
encodings: manifest.encodings || false,
3127

3228
// Methods that are not part of abstract-leveldown or levelup
33-
additionalMethods: xtend(manifest.additionalMethods)
29+
additionalMethods: Object.assign({}, manifest.additionalMethods)
3430
})
3531
}

package.json

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,26 @@
55
"license": "MIT",
66
"scripts": {
77
"test": "standard && hallmark && (nyc -s node test/self.js | faucet) && nyc report",
8-
"test-browser-local": "airtap --coverage --local test/self.js",
8+
"test-browsers-local": "airtap --coverage test/self.js",
99
"coverage": "nyc report --reporter=text-lcov | coveralls",
10-
"hallmark": "hallmark --fix",
11-
"dependency-check": "dependency-check --no-dev . test/*.js",
12-
"prepublishOnly": "npm run dependency-check"
10+
"hallmark": "hallmark --fix"
1311
},
1412
"files": [
1513
"test",
1614
"CHANGELOG.md",
1715
"CONTRIBUTORS.md",
1816
"index.js"
1917
],
20-
"dependencies": {
21-
"xtend": "^4.0.2"
22-
},
18+
"dependencies": {},
2319
"devDependencies": {
24-
"airtap": "^3.0.0",
20+
"airtap": "^4.0.3",
21+
"airtap-playwright": "^1.0.1",
2522
"coveralls": "^3.0.6",
26-
"dependency-check": "^4.1.0",
2723
"faucet": "^0.0.1",
2824
"hallmark": "^3.1.0",
2925
"level-community": "^3.0.0",
3026
"nyc": "^14.1.1",
31-
"standard": "^14.3.1",
27+
"standard": "^16.0.3",
3228
"tape": "^5.0.1"
3329
},
3430
"hallmark": {
@@ -48,6 +44,6 @@
4844
"manifest"
4945
],
5046
"engines": {
51-
"node": ">=6"
47+
"node": ">=10"
5248
}
5349
}

test/cloneable.js

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

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

55
// Every object in a manifest must have a unique identity, to avoid accidental
66
// mutation. In supports() we only shallowly clone the manifest object itself
77
// and additionalMethods. If in the future we add more objects to manifests,
88
// this test will break and we'll know to start performing a deep clone.
99
module.exports = function cloneable (t, manifest) {
10-
var copy = supports(manifest)
10+
const copy = supports(manifest)
1111
verifyUnique(t, 'manifest', manifest, copy)
1212
}
1313

test/index.js

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

3-
var xtend = require('xtend')
4-
var shape = require('./shape')
5-
var cloneable = require('./cloneable')
3+
const shape = require('./shape')
4+
const cloneable = require('./cloneable')
65

76
module.exports = function suite (test, testCommon) {
87
test('db has manifest', function (t) {
9-
var db = testCommon.factory()
10-
var manifest = db.supports
8+
const db = testCommon.factory()
9+
const manifest = db.supports
1110

1211
shape(t, manifest)
1312
cloneable(t, manifest)
1413

15-
var before = xtend(manifest, {
16-
additionalMethods: xtend(manifest.additionalMethods)
14+
const before = Object.assign({}, manifest, {
15+
additionalMethods: Object.assign({}, manifest.additionalMethods)
1716
})
1817

1918
db.open(function (err) {

test/self.js

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

3-
var test = require('tape')
4-
var supports = require('..')
5-
var shape = require('./shape')
6-
var cloneable = require('./cloneable')
3+
const test = require('tape')
4+
const supports = require('..')
5+
const shape = require('./shape')
6+
const cloneable = require('./cloneable')
77

88
test('no options', function (t) {
99
shape(t, supports())
@@ -13,7 +13,7 @@ test('no options', function (t) {
1313

1414
test('falsy options', function (t) {
1515
;[null, false, undefined, 0, ''].forEach(function (value) {
16-
var manifest = supports({
16+
const manifest = supports({
1717
bufferKeys: value,
1818
additionalMethods: {
1919
foo: value
@@ -29,7 +29,7 @@ test('falsy options', function (t) {
2929

3030
test('truthy options', function (t) {
3131
;[true, {}, 'yes', 1, []].forEach(function (value) {
32-
var manifest = supports({
32+
const manifest = supports({
3333
streams: value,
3434
additionalMethods: {
3535
foo: value
@@ -45,9 +45,9 @@ test('truthy options', function (t) {
4545
})
4646

4747
test('merges input objects without mutating them', function (t) {
48-
var input1 = { bufferKeys: null, streams: false }
49-
var input2 = { streams: true, additionalMethods: {} }
50-
var manifest = supports(input1, input2)
48+
const input1 = { bufferKeys: null, streams: false }
49+
const input2 = { streams: true, additionalMethods: {} }
50+
const manifest = supports(input1, input2)
5151

5252
manifest.foobar = true
5353
manifest.additionalMethods.baz = true
@@ -61,15 +61,15 @@ test('merges input objects without mutating them', function (t) {
6161
})
6262

6363
test('inherits additionalMethods', function (t) {
64-
var manifest = supports({ additionalMethods: { foo: true } }, {})
64+
const manifest = supports({ additionalMethods: { foo: true } }, {})
6565
t.same(manifest.additionalMethods, { foo: true })
6666
t.end()
6767
})
6868

6969
test('does not merge additionalMethods', function (t) {
70-
var input1 = { additionalMethods: { foo: true } }
71-
var input2 = { additionalMethods: { bar: true } }
72-
var manifest = supports(input1, input2)
70+
const input1 = { additionalMethods: { foo: true } }
71+
const input2 = { additionalMethods: { bar: true } }
72+
const manifest = supports(input1, input2)
7373
t.same(manifest.additionalMethods, { bar: true })
7474
t.end()
7575
})

test/shape.js

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

3-
var hasOwnProperty = Object.prototype.hasOwnProperty
3+
const hasOwnProperty = Object.prototype.hasOwnProperty
44

55
module.exports = function shape (t, manifest) {
66
t.ok(isObject(manifest), 'manifest is object')
77
t.ok(isObject(manifest.additionalMethods), 'additionalMethods is object')
88

9-
for (var k in manifest) {
9+
for (const k in manifest) {
1010
if (!hasOwnProperty.call(manifest, k)) continue
1111

1212
if (manifest[k]) {

0 commit comments

Comments
 (0)