abstract-leveldown
Advanced tools
Comparing version 2.6.2 to 2.6.3
@@ -257,5 +257,4 @@ /* Copyright (c) 2017 Rod Vagg, MIT License */ | ||
AbstractLevelDOWN.prototype._serializeValue = function (value) { | ||
return this._isBuffer(value) || process.browser || value == null | ||
? value | ||
: String(value) | ||
if (value == null) return '' | ||
return this._isBuffer(value) || process.browser ? value : String(value) | ||
} | ||
@@ -262,0 +261,0 @@ |
@@ -185,9 +185,7 @@ var db | ||
ops.forEach(function (op) { | ||
if (Buffer.isBuffer(op.key)) op.key = String(op.key) | ||
if (Buffer.isBuffer(op.value)) op.value = String(op.value) | ||
t.ok(op.key, '.key is set for .put and .del operations') | ||
if (op.type === 'put') { | ||
t.ok(op.value, '.value is set for .put operation') | ||
} | ||
}) | ||
t.deepEqual(ops, [ | ||
{ type: 'put', key: '[object Object]', value: '[object Object]' } | ||
, { type: 'del', key: '[object Object]' } | ||
]) | ||
t.end() | ||
@@ -194,0 +192,0 @@ }) |
{ | ||
"name": "abstract-leveldown", | ||
"description": "An abstract prototype matching the LevelDOWN API", | ||
"version": "2.6.2", | ||
"version": "2.6.3", | ||
"contributors": [ | ||
@@ -37,3 +37,3 @@ "Rod Vagg <r@va.gg> (https://github.com/rvagg)", | ||
"rimraf": "^2.6.1", | ||
"sinon": "^2.4.1", | ||
"sinon": "^3.2.0", | ||
"tape": "^4.7.0" | ||
@@ -40,0 +40,0 @@ }, |
@@ -7,2 +7,3 @@ # Abstract LevelDOWN | ||
[![dependencies](https://david-dm.org/Level/abstract-leveldown.svg)](https://david-dm.org/level/abstract-leveldown) | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/Level/abstract-leveldown.svg)](https://greenkeeper.io/) | ||
@@ -94,2 +95,12 @@ [![NPM](https://nodei.co/npm/abstract-leveldown.png?downloads=true&downloadRank=true)](https://nodei.co/npm/abstract-leveldown/) | ||
### AbstractLevelDOWN(location) | ||
### AbstractLevelDOWN#status | ||
An `AbstractLevelDOWN` based database can be in one of the following states: | ||
* `'new'` - newly created, not opened or closed | ||
* `'opening'` - waiting for the database to be opened | ||
* `'open'` - successfully opened the database, available for use | ||
* `'closing'` - waiting for the database to be closed | ||
* `'closed'` - database has been successfully closed, should not be used | ||
### AbstractLevelDOWN#_open(options, callback) | ||
@@ -96,0 +107,0 @@ ### AbstractLevelDOWN#_close(callback) |
30
test.js
@@ -65,2 +65,32 @@ var test = require('tape') | ||
test('test key/value serialization', function (t) { | ||
function Test (location) { | ||
AbstractLevelDOWN.call(this, location) | ||
} | ||
util.inherits(Test, AbstractLevelDOWN) | ||
var buffer = new Buffer(0) | ||
var test = new Test('foobar') | ||
t.equal(test._serializeKey(1), '1', '_serializeKey converts to string') | ||
t.ok(test._serializeKey(buffer) === buffer, '_serializeKey returns Buffer as is') | ||
t.equal(test._serializeValue(null), '', '_serializeValue converts null to empty string') | ||
t.equal(test._serializeValue(undefined), '', '_serializeValue converts undefined to empty string') | ||
var browser = !! process.browser | ||
process.browser = false | ||
t.equal(test._serializeValue(1), '1', '_serializeValue converts to string') | ||
t.ok(test._serializeValue(buffer) === buffer, '_serializeValue returns Buffer as is') | ||
process.browser = true | ||
t.equal(test._serializeValue(1), 1, '_serializeValue returns value as is when process.browser') | ||
process.browser = browser | ||
t.end() | ||
}) | ||
test('test open() extensibility', function (t) { | ||
@@ -67,0 +97,0 @@ var spy = sinon.spy() |
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
131968
3094
164