abstract-leveldown
Advanced tools
Comparing version 6.2.3 to 6.3.0
@@ -5,2 +5,12 @@ # Changelog | ||
## [6.3.0] - 2020-04-11 | ||
### Changed | ||
- Upgrade devDependency `dependency-check` from `^3.3.0` to `^4.1.0` ([`9193656`](https://github.com/Level/abstract-leveldown/commit/9193656)) ([**@vweevers**](https://github.com/vweevers)) | ||
### Added | ||
- Support running test suite on a `levelup` db, as well as skipping `start` and `end` tests (for `multileveldown`) ([#364](https://github.com/Level/abstract-leveldown/issues/364)) ([**@vweevers**](https://github.com/vweevers)) | ||
## [6.2.3] - 2020-04-03 | ||
@@ -813,2 +823,4 @@ | ||
[6.3.0]: https://github.com/Level/abstract-leveldown/compare/v6.2.3...v6.3.0 | ||
[6.2.3]: https://github.com/Level/abstract-leveldown/compare/v6.2.2...v6.2.3 | ||
@@ -815,0 +827,0 @@ |
{ | ||
"name": "abstract-leveldown", | ||
"version": "6.2.3", | ||
"version": "6.3.0", | ||
"description": "An abstract prototype matching the LevelDOWN API", | ||
@@ -16,3 +16,3 @@ "license": "MIT", | ||
"hallmark": "hallmark --fix", | ||
"dependency-check": "dependency-check . test/*.js", | ||
"dependency-check": "dependency-check --no-dev -i buffer -i immediate . test/*.js", | ||
"prepublishOnly": "npm run dependency-check" | ||
@@ -30,3 +30,3 @@ }, | ||
"coveralls": "^3.0.2", | ||
"dependency-check": "^3.3.0", | ||
"dependency-check": "^4.1.0", | ||
"hallmark": "^2.0.0", | ||
@@ -33,0 +33,0 @@ "level-community": "^3.0.0", |
@@ -523,2 +523,3 @@ # abstract-leveldown | ||
- `createIfMissing` and `errorIfExists`: set to `false` if `db._open()` does not support these options. | ||
- `legacyRange`: set to `false` if your iterator does not support the legacy `start` and `end` range options. | ||
@@ -525,0 +526,0 @@ This metadata will be moved to manifests (`db.supports`) in the future. |
@@ -14,3 +14,3 @@ var db | ||
exports.args = function (test, testCommon) { | ||
test('test callback-less, 2-arg, batch() throws', function (t) { | ||
testCommon.promises || test('test callback-less, 2-arg, batch() throws', function (t) { | ||
t.throws( | ||
@@ -219,3 +219,7 @@ db.batch.bind(db, 'foo', {}), | ||
var result | ||
if (isTypedArray(value)) { | ||
if (testCommon.encodings) { | ||
t.is(typeof value, 'string') | ||
result = value | ||
} else if (isTypedArray(value)) { | ||
result = String.fromCharCode.apply(null, new Uint16Array(value)) | ||
@@ -249,3 +253,6 @@ } else { | ||
var result | ||
if (isTypedArray(value)) { | ||
if (testCommon.encodings) { | ||
t.is(typeof value, 'string') | ||
result = value | ||
} else if (isTypedArray(value)) { | ||
result = String.fromCharCode.apply(null, new Uint16Array(value)) | ||
@@ -270,3 +277,6 @@ } else { | ||
var result | ||
if (isTypedArray(value)) { | ||
if (testCommon.encodings) { | ||
t.is(typeof value, 'string') | ||
result = value | ||
} else if (isTypedArray(value)) { | ||
result = String.fromCharCode.apply(null, new Uint16Array(value)) | ||
@@ -273,0 +283,0 @@ } else { |
@@ -126,3 +126,3 @@ var collectEntries = require('level-concat-iterator') | ||
test('test batch#write() with no callback', function (t) { | ||
testCommon.promises || test('test batch#write() with no callback', function (t) { | ||
try { | ||
@@ -190,3 +190,3 @@ db.batch().write() | ||
test('test serialize object', function (t) { | ||
testCommon.serialize && test('test serialize object', function (t) { | ||
var batch = db.batch() | ||
@@ -207,3 +207,3 @@ var ops = collectBatchOps(batch) | ||
test('test custom _serialize*', function (t) { | ||
testCommon.serialize && test('test custom _serialize*', function (t) { | ||
t.plan(4) | ||
@@ -210,0 +210,0 @@ |
@@ -13,3 +13,3 @@ var concat = require('level-concat-iterator') | ||
exports.args = function (test, testCommon) { | ||
test('test argument-less clear() throws', function (t) { | ||
testCommon.promises || test('test argument-less clear() throws', function (t) { | ||
t.throws( | ||
@@ -16,0 +16,0 @@ db.clear.bind(db), |
@@ -13,3 +13,3 @@ var db | ||
test('test close()', function (t) { | ||
t.throws( | ||
testCommon.promises || t.throws( | ||
db.close.bind(db), | ||
@@ -19,3 +19,3 @@ /Error: close\(\) requires a callback argument/, | ||
) | ||
t.throws( | ||
testCommon.promises || t.throws( | ||
db.close.bind(db, 'foo'), | ||
@@ -22,0 +22,0 @@ /Error: close\(\) requires a callback argument/, |
@@ -27,3 +27,21 @@ function testCommon (options) { | ||
seek: options.seek !== false, | ||
clear: !!options.clear | ||
clear: !!options.clear, | ||
// Allow skipping 'start' and 'end' tests | ||
// TODO (next major): drop legacy range options | ||
legacyRange: options.legacyRange !== false, | ||
// Support running test suite on a levelup db. All options below this line | ||
// are undocumented and should not be used by abstract-leveldown db's (yet). | ||
promises: !!options.promises, | ||
status: options.status !== false, | ||
serialize: options.serialize !== false, | ||
// If true, the test suite assumes a default encoding of utf8 (like levelup) | ||
// and that operations return strings rather than buffers by default. | ||
encodings: !!options.encodings, | ||
// Not yet used, only here for symmetry with levelup's test suite. | ||
deferredOpen: !!options.deferredOpen, | ||
streams: !!options.streams | ||
} | ||
@@ -30,0 +48,0 @@ } |
@@ -13,3 +13,3 @@ var db | ||
exports.args = function (test, testCommon) { | ||
test('test argument-less del() throws', function (t) { | ||
testCommon.promises || test('test argument-less del() throws', function (t) { | ||
t.throws( | ||
@@ -23,3 +23,3 @@ db.del.bind(db), | ||
test('test callback-less, 1-arg, del() throws', function (t) { | ||
testCommon.promises || test('test callback-less, 1-arg, del() throws', function (t) { | ||
t.throws( | ||
@@ -33,3 +33,3 @@ db.del.bind(db, 'foo'), | ||
test('test callback-less, 3-arg, del() throws', function (t) { | ||
testCommon.promises || test('test callback-less, 3-arg, del() throws', function (t) { | ||
t.throws( | ||
@@ -43,3 +43,3 @@ db.del.bind(db, 'foo', {}), | ||
test('test custom _serialize*', function (t) { | ||
testCommon.serialize && test('test custom _serialize*', function (t) { | ||
t.plan(3) | ||
@@ -46,0 +46,0 @@ var db = testCommon.factory() |
@@ -14,3 +14,3 @@ var db | ||
exports.args = function (test, testCommon) { | ||
test('test argument-less get() throws', function (t) { | ||
testCommon.promises || test('test argument-less get() throws', function (t) { | ||
t.throws( | ||
@@ -24,3 +24,3 @@ db.get.bind(db), | ||
test('test callback-less, 1-arg, get() throws', function (t) { | ||
testCommon.promises || test('test callback-less, 1-arg, get() throws', function (t) { | ||
t.throws( | ||
@@ -34,3 +34,3 @@ db.get.bind(db, 'foo'), | ||
test('test callback-less, 3-arg, get() throws', function (t) { | ||
testCommon.promises || test('test callback-less, 3-arg, get() throws', function (t) { | ||
t.throws( | ||
@@ -44,3 +44,3 @@ db.get.bind(db, 'foo', {}), | ||
test('test custom _serialize*', function (t) { | ||
testCommon.serialize && test('test custom _serialize*', function (t) { | ||
t.plan(3) | ||
@@ -68,25 +68,8 @@ var db = testCommon.factory() | ||
t.error(err) | ||
t.ok(typeof value !== 'string', 'should not be string by default') | ||
var result | ||
if (isTypedArray(value)) { | ||
result = String.fromCharCode.apply(null, new Uint16Array(value)) | ||
} else { | ||
t.ok(typeof Buffer !== 'undefined' && value instanceof Buffer) | ||
try { | ||
result = value.toString() | ||
} catch (e) { | ||
t.error(e, 'should not throw when converting value to a string') | ||
} | ||
} | ||
t.equal(result, 'bar') | ||
db.get('foo', {}, function (err, value) { // same but with {} | ||
t.error(err) | ||
if (!testCommon.encodings) { | ||
t.ok(typeof value !== 'string', 'should not be string by default') | ||
var result | ||
if (isTypedArray(value)) { | ||
result = String.fromCharCode.apply(null, new Uint16Array(value)) | ||
var result = String.fromCharCode.apply(null, new Uint16Array(value)) | ||
} else { | ||
@@ -100,3 +83,28 @@ t.ok(typeof Buffer !== 'undefined' && value instanceof Buffer) | ||
} | ||
} else { | ||
result = value | ||
} | ||
t.equal(result, 'bar') | ||
db.get('foo', {}, function (err, value) { // same but with {} | ||
t.error(err) | ||
if (!testCommon.encodings) { | ||
t.ok(typeof value !== 'string', 'should not be string by default') | ||
if (isTypedArray(value)) { | ||
var result = String.fromCharCode.apply(null, new Uint16Array(value)) | ||
} else { | ||
t.ok(typeof Buffer !== 'undefined' && value instanceof Buffer) | ||
try { | ||
result = value.toString() | ||
} catch (e) { | ||
t.error(e, 'should not throw when converting value to a string') | ||
} | ||
} | ||
} else { | ||
result = value | ||
} | ||
t.equal(result, 'bar') | ||
@@ -103,0 +111,0 @@ |
@@ -38,2 +38,6 @@ var collectEntries = require('level-concat-iterator') | ||
function rangeTest (name, opts, expected) { | ||
if (!testCommon.legacyRange && ('start' in opts || 'end' in opts)) { | ||
return | ||
} | ||
opts.keyAsBuffer = false | ||
@@ -40,0 +44,0 @@ opts.valueAsBuffer = false |
@@ -14,3 +14,4 @@ var db | ||
var iterator = db.iterator() | ||
t.ok(iterator.db === db) | ||
// For levelup compat: may return iterator of an underlying db, that's okay. | ||
t.ok(iterator.db === db || iterator.db) | ||
iterator.end(t.end.bind(t)) | ||
@@ -136,4 +137,9 @@ }) | ||
if (key && value) { | ||
t.ok(Buffer.isBuffer(key), 'key argument is a Buffer') | ||
t.ok(Buffer.isBuffer(value), 'value argument is a Buffer') | ||
if (testCommon.encodings) { | ||
t.is(typeof key, 'string', 'key argument is a string') | ||
t.is(typeof value, 'string', 'value argument is a string') | ||
} else { | ||
t.ok(Buffer.isBuffer(key), 'key argument is a Buffer') | ||
t.ok(Buffer.isBuffer(value), 'value argument is a Buffer') | ||
} | ||
t.is(key.toString(), data[idx].key, 'correct key') | ||
@@ -144,3 +150,3 @@ t.is(value.toString(), data[idx].value, 'correct value') | ||
} else { // end | ||
t.ok(typeof err === 'undefined', 'err argument is undefined') | ||
t.ok(err == null, 'err argument is nullish') | ||
t.ok(typeof key === 'undefined', 'key argument is undefined') | ||
@@ -147,0 +153,0 @@ t.ok(typeof value === 'undefined', 'value argument is undefined') |
@@ -8,3 +8,3 @@ var suite = require('level-supports/test') | ||
test('manifest has status', function (t) { | ||
testCommon.status && test('manifest has status', function (t) { | ||
var db = testCommon.factory() | ||
@@ -11,0 +11,0 @@ t.is(db.supports.status, true) |
@@ -6,3 +6,3 @@ exports.setUp = function (test, testCommon) { | ||
exports.args = function (test, testCommon) { | ||
test('test database open no-arg throws', function (t) { | ||
testCommon.promises || test('test database open no-arg throws', function (t) { | ||
var db = testCommon.factory() | ||
@@ -17,3 +17,3 @@ t.throws( | ||
test('test callback-less, 1-arg, open() throws', function (t) { | ||
testCommon.promises || test('test callback-less, 1-arg, open() throws', function (t) { | ||
var db = testCommon.factory() | ||
@@ -20,0 +20,0 @@ t.throws( |
@@ -53,4 +53,4 @@ 'use strict' | ||
function makePutGetDelSuccessfulTest (test, type, key, value, expectedResult) { | ||
var hasExpectedResult = arguments.length === 5 | ||
function makePutGetDelSuccessfulTest (test, testCommon, type, key, value, expectedResult) { | ||
var hasExpectedResult = arguments.length === 6 | ||
test('test put()/get()/del() with ' + type, function (t) { | ||
@@ -61,4 +61,11 @@ db.put(key, value, function (err) { | ||
t.error(err, 'no error, has key/value for `' + type + '`') | ||
t.ok(Buffer.isBuffer(_value), 'is a Buffer') | ||
var result = _value | ||
if (!testCommon.encodings) { | ||
t.ok(Buffer.isBuffer(_value), 'is a Buffer') | ||
var result = _value | ||
} else { | ||
t.is(typeof _value, 'string', 'is a string') | ||
result = _value | ||
} | ||
if (hasExpectedResult) { | ||
@@ -119,3 +126,3 @@ t.equal(result.toString(), expectedResult) | ||
// valid falsey keys | ||
makePutGetDelSuccessfulTest(test, '`0` key', 0, 'foo 0') | ||
makePutGetDelSuccessfulTest(test, testCommon, '`0` key', 0, 'foo 0') | ||
@@ -125,2 +132,3 @@ // standard String key | ||
test | ||
, testCommon | ||
, 'long String key' | ||
@@ -132,7 +140,7 @@ , 'some long string that I\'m using as a key for this unit test, cross your fingers human, we\'re going in!' | ||
if (testCommon.bufferKeys) { | ||
makePutGetDelSuccessfulTest(test, 'Buffer key', testBuffer, 'foo') | ||
makePutGetDelSuccessfulTest(test, testCommon, 'Buffer key', testBuffer, 'foo') | ||
} | ||
// non-empty Array as a value | ||
makePutGetDelSuccessfulTest(test, 'Array value', 'foo', [1, 2, 3, 4]) | ||
makePutGetDelSuccessfulTest(test, testCommon, 'Array value', 'foo', [1, 2, 3, 4]) | ||
} | ||
@@ -142,12 +150,12 @@ | ||
// valid falsey values | ||
makePutGetDelSuccessfulTest(test, '`false` value', 'foo false', false) | ||
makePutGetDelSuccessfulTest(test, '`0` value', 'foo 0', 0) | ||
makePutGetDelSuccessfulTest(test, '`NaN` value', 'foo NaN', NaN) | ||
makePutGetDelSuccessfulTest(test, testCommon, '`false` value', 'foo false', false) | ||
makePutGetDelSuccessfulTest(test, testCommon, '`0` value', 'foo 0', 0) | ||
makePutGetDelSuccessfulTest(test, testCommon, '`NaN` value', 'foo NaN', NaN) | ||
// all of the following result in an empty-string value: | ||
makePutGetDelSuccessfulTest(test, 'empty String value', 'foo', '', '') | ||
makePutGetDelSuccessfulTest(test, 'empty Buffer value', 'foo', Buffer.alloc(0), '') | ||
makePutGetDelSuccessfulTest(test, testCommon, 'empty String value', 'foo', '', '') | ||
makePutGetDelSuccessfulTest(test, testCommon, 'empty Buffer value', 'foo', Buffer.alloc(0), '') | ||
// note that an implementation may return the value as an array | ||
makePutGetDelSuccessfulTest(test, 'empty Array value', 'foo', [], '') | ||
makePutGetDelSuccessfulTest(test, testCommon, 'empty Array value', 'foo', [], '') | ||
@@ -157,2 +165,3 @@ // standard String value | ||
test | ||
, testCommon | ||
, 'long String value' | ||
@@ -164,6 +173,6 @@ , 'foo' | ||
// standard Buffer value | ||
makePutGetDelSuccessfulTest(test, 'Buffer value', 'foo', testBuffer) | ||
makePutGetDelSuccessfulTest(test, testCommon, 'Buffer value', 'foo', testBuffer) | ||
// non-empty Array as a key | ||
makePutGetDelSuccessfulTest(test, 'Array key', [1, 2, 3, 4], 'foo') | ||
makePutGetDelSuccessfulTest(test, testCommon, 'Array key', [1, 2, 3, 4], 'foo') | ||
} | ||
@@ -170,0 +179,0 @@ |
@@ -13,3 +13,3 @@ var db | ||
exports.args = function (test, testCommon) { | ||
test('test argument-less put() throws', function (t) { | ||
testCommon.promises || test('test argument-less put() throws', function (t) { | ||
t.throws( | ||
@@ -23,3 +23,3 @@ db.put.bind(db), | ||
test('test callback-less, 1-arg, put() throws', function (t) { | ||
testCommon.promises || test('test callback-less, 1-arg, put() throws', function (t) { | ||
t.throws( | ||
@@ -33,3 +33,3 @@ db.put.bind(db, 'foo'), | ||
test('test callback-less, 2-arg, put() throws', function (t) { | ||
testCommon.promises || test('test callback-less, 2-arg, put() throws', function (t) { | ||
t.throws( | ||
@@ -43,3 +43,3 @@ db.put.bind(db, 'foo', 'bar'), | ||
test('test callback-less, 3-arg, put() throws', function (t) { | ||
testCommon.promises || test('test callback-less, 3-arg, put() throws', function (t) { | ||
t.throws( | ||
@@ -53,3 +53,3 @@ db.put.bind(db, 'foo', 'bar', {}), | ||
test('test _serialize object', function (t) { | ||
testCommon.serialize && test('test _serialize object', function (t) { | ||
t.plan(3) | ||
@@ -67,3 +67,3 @@ var db = testCommon.factory() | ||
test('test custom _serialize*', function (t) { | ||
testCommon.serialize && test('test custom _serialize*', function (t) { | ||
t.plan(4) | ||
@@ -70,0 +70,0 @@ var db = testCommon.factory() |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
219584
3608
631