abstract-leveldown
Advanced tools
Comparing version 0.1.0 to 0.2.0
@@ -61,6 +61,6 @@ /* Copyright (c) 2013 Rod Vagg, MIT License */ | ||
if (!arguments.length || location === undefined) | ||
throw new Error('leveldown() requires at least a location argument') | ||
throw new Error('constructor requires at least a location argument') | ||
if (typeof location != 'string') | ||
throw new Error('leveldown() requires a location string argument') | ||
throw new Error('constructor requires a location string argument') | ||
@@ -67,0 +67,0 @@ this.location = location |
@@ -50,3 +50,3 @@ var db | ||
if (err) message = err.message | ||
t.like(message, /NotFound/) | ||
t.ok(message.match(/NotFound/), 'returned NotFound') | ||
t.end() | ||
@@ -53,0 +53,0 @@ }) |
@@ -46,13 +46,31 @@ var db | ||
t.notOk(err, 'no error') | ||
t.type(value, Buffer) | ||
t.equal(value.toString(), 'bar') | ||
t.ok(typeof value !== 'string', 'should not be string by default') | ||
var result | ||
if (value instanceof ArrayBuffer) { | ||
result = String.fromCharCode.apply(null, new Uint16Array(value)) | ||
} else { | ||
t.ok(typeof Buffer != 'undefined' && value instanceof Buffer) | ||
result= value.toString() | ||
} | ||
t.equal(result, 'bar') | ||
db.get('foo', {}, function (err, value) { // same but with {} | ||
t.notOk(err, 'no error') | ||
t.type(value, Buffer) | ||
t.equal(value.toString(), 'bar') | ||
t.ok(typeof value !== 'string', 'should not be string by default') | ||
var result | ||
if (value instanceof ArrayBuffer) { | ||
result = String.fromCharCode.apply(null, new Uint16Array(value)) | ||
} else { | ||
t.ok(typeof Buffer != 'undefined' && value instanceof Buffer) | ||
result= value.toString() | ||
} | ||
t.equal(result, 'bar') | ||
db.get('foo', { asBuffer: false }, function (err, value) { | ||
t.notOk(err, 'no error') | ||
t.type(value, 'string') | ||
t.ok(typeof value === 'string', 'should be string if not buffer') | ||
t.equal(value, 'bar') | ||
@@ -59,0 +77,0 @@ t.end() |
@@ -115,3 +115,2 @@ var db | ||
t.notOk(err, 'no error') | ||
var iterator = db.iterator() | ||
@@ -126,5 +125,5 @@ , fn = function (err, key, value) { | ||
} else { // end | ||
t.type(err, 'undefined', 'err argument is undefined') | ||
t.type(key, 'undefined', 'key argument is undefined') | ||
t.type(value, 'undefined', 'value argument is undefined') | ||
t.ok(typeof err === 'undefined', 'err argument is undefined') | ||
t.ok(typeof key === 'undefined', 'key argument is undefined') | ||
t.ok(typeof value === 'undefined', 'value argument is undefined') | ||
t.equal(idx, data.length, 'correct number of entries') | ||
@@ -397,8 +396,14 @@ iterator.end(function () { | ||
} | ||
if (!process.browser) { | ||
// Can't use buffers as query keys in indexeddb (I think :P) | ||
testIteratorCollectsFullDatabase( | ||
'test iterator with start as empty buffer' | ||
, { start: new Buffer(0) } | ||
) | ||
testIteratorCollectsFullDatabase( | ||
'test iterator with end as empty buffer' | ||
, { end: new Buffer(0) } | ||
) | ||
} | ||
testIteratorCollectsFullDatabase( | ||
'test iterator with start as empty buffer' | ||
, { start: new Buffer(0) } | ||
) | ||
testIteratorCollectsFullDatabase( | ||
'test iterator with start as empty string' | ||
@@ -412,6 +417,2 @@ , { start: '' } | ||
testIteratorCollectsFullDatabase( | ||
'test iterator with end as empty buffer' | ||
, { end: new Buffer(0) } | ||
) | ||
testIteratorCollectsFullDatabase( | ||
'test iterator with end as empty string' | ||
@@ -418,0 +419,0 @@ , { end: '' } |
@@ -5,3 +5,3 @@ module.exports.args = function (leveldown, test) { | ||
leveldown | ||
, { name: 'Error', message: 'leveldown() requires at least a location argument' } | ||
, { name: 'Error', message: 'constructor requires at least a location argument' } | ||
, 'no-arg leveldown() throws' | ||
@@ -15,5 +15,5 @@ ) | ||
t.ok(db, 'database object returned') | ||
t.isa(db.open, 'function', 'open() function exists') | ||
t.ok(typeof db.open === 'function', 'open() function exists') | ||
t.end() | ||
}) | ||
} |
@@ -10,4 +10,4 @@ /**** SETUP & UTILITY STUFF ****/ | ||
t.ok(err, 'has error') | ||
t.type(err, Error) | ||
t.like(err.message, expectedError, 'correct error message') | ||
t.ok(err instanceof Error) | ||
t.ok(err.message.match(expectedError), 'correct error message') | ||
t.end() | ||
@@ -20,4 +20,4 @@ }) | ||
t.ok(err, 'has error') | ||
t.type(err, Error) | ||
t.like(err.message, expectedError, 'correct error message') | ||
t.ok(err instanceof Error) | ||
t.ok(err.message.match(expectedError), 'correct error message') | ||
t.end() | ||
@@ -32,4 +32,4 @@ }) | ||
t.ok(err, 'has error') | ||
t.type(err, Error) | ||
t.like(err.message, expectedError, 'correct error message') | ||
t.ok(err instanceof Error) | ||
t.ok(err.message.match(expectedError), 'correct error message') | ||
t.end() | ||
@@ -46,3 +46,8 @@ }) | ||
t.notOk(err, 'no error, has key/value for `' + key + '`') | ||
t.equals(_value.toString(), value.toString()) | ||
var result = _value.toString() | ||
if (_value instanceof ArrayBuffer) | ||
result = String.fromCharCode.apply(null, new Uint16Array(_value)) | ||
t.equals(result, value.toString()) | ||
db.del(key, function (err) { | ||
@@ -52,3 +57,3 @@ t.notOk(err, 'no error, deleted key/value for `' + key + '`') | ||
t.ok(err, 'entry propertly deleted') | ||
t.like(err.message, /NotFound/) | ||
t.ok(err.message.match(/NotFound/)) | ||
t.end() | ||
@@ -84,3 +89,4 @@ }) | ||
makeErrorKeyTest('empty String key', '', /key cannot be an empty String/) | ||
makeErrorKeyTest('empty Buffer key', new Buffer(0), /key cannot be an empty Buffer/) | ||
if (process.browser) makeErrorKeyTest('empty ArrayBuffer key', new ArrayBuffer(0), /key cannot be an empty ArrayBuffer/) | ||
else makeErrorKeyTest('empty Buffer key', new Buffer(0), /key cannot be an empty Buffer/) | ||
makeErrorKeyTest('empty Array key', [], /key cannot be an empty String/) | ||
@@ -117,3 +123,4 @@ } | ||
makePutErrorTest('empty String value', 'foo', '', /value cannot be an empty String/) | ||
makePutErrorTest('empty Buffer value', 'foo', new Buffer(0), /value cannot be an empty Buffer/) | ||
if (process.browser) makePutErrorTest('empty ArrayBuffer value', 'foo', new ArrayBuffer(0), /value cannot be an empty ArrayBuffer/) | ||
else makePutErrorTest('empty Buffer value', 'foo', new Buffer(0), /value cannot be an empty Buffer/) | ||
makePutErrorTest('empty Array value', 'foo', [], /value cannot be an empty String/) | ||
@@ -120,0 +127,0 @@ } |
@@ -55,3 +55,6 @@ var db | ||
t.notOk(err, 'no error') | ||
t.equal(value.toString(), 'bar') | ||
var result = value.toString() | ||
if (value instanceof ArrayBuffer) | ||
result = String.fromCharCode.apply(null, new Uint16Array(value)) | ||
t.equal(result, 'bar') | ||
t.end() | ||
@@ -58,0 +61,0 @@ }) |
{ | ||
"name" : "abstract-leveldown" | ||
, "description" : "An abstract prototype matching the LevelDOWN API" | ||
, "version" : "0.1.0" | ||
, "version" : "0.2.0" | ||
, "homepage" : "https://github.com/rvagg/node-abstract-leveldown" | ||
, "contributors" : [ | ||
"Rod Vagg <r@va.gg> (https://github.com/rvagg)" | ||
, "John Chesley <john@chesl.es> (https://github.com/chesles/)" | ||
, "Jake Verbaten <raynos2@gmail.com> (https://github.com/raynos)" | ||
, "Dominic Tarr <dominic.tarr@gmail.com> (https://github.com/dominictarr)" | ||
, "Max Ogden <max@maxogden.com> (https://github.com/maxogden)" | ||
, "Lars-Magnus Skog <lars.magnus.skog@gmail.com> (https://github.com/ralphtheninja)" | ||
, "David Björklund <david.bjorklund@gmail.com> (https://github.com/kesla)" | ||
, "Julian Gruber <julian@juliangruber.com> (https://github.com/juliangruber)" | ||
, "Paolo Fragomeni <paolo@async.ly> (https://github.com/hij1nx)" | ||
] | ||
, "authors" : [ | ||
@@ -26,2 +37,2 @@ "Rod Vagg <rod@vagg.org> (https://github.com/rvagg)" | ||
, "license" : "MIT" | ||
} | ||
} |
@@ -39,3 +39,3 @@ # Abstract LevelDOWN [![Build Status](https://secure.travis-ci.org/rvagg/node-abstract-leveldown.png)](http://travis-ci.org/rvagg/node-abstract-leveldown) | ||
FakeLevelDOWN.prototype._put = function (key, value, options, callback) { | ||
key = '$' + key // safety, to avoid key='__proto__'-type skullduggery | ||
key = '_' + key // safety, to avoid key='__proto__'-type skullduggery | ||
this._store[key] = value | ||
@@ -46,3 +46,3 @@ process.nextTick(callback) | ||
FakeLevelDOWN.prototype._get = function (key, options, callback) { | ||
var value = this._store['$' + key] | ||
var value = this._store['_' + key] | ||
if (value === undefined) { | ||
@@ -58,3 +58,3 @@ // 'NotFound' error, consistent with LevelDOWN API | ||
FakeLevelDOWN.prototype._del = function (key, options, callback) { | ||
delete this._store['$' + key] | ||
delete this._store['_' + key] | ||
process.nextTick(callback) | ||
@@ -111,4 +111,36 @@ } | ||
## Licence | ||
<a name="contributing"></a> | ||
Contributing | ||
------------ | ||
Abstract LevelDOWN is Copyright (c) 2013 Rod Vagg [@rvagg](https://twitter.com/rvagg) and licensed under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details. | ||
Abstract LevelDOWN is an **OPEN Open Source Project**. This means that: | ||
> Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project. | ||
See the [CONTRIBUTING.md](https://github.com/rvagg/node-levelup/blob/master/CONTRIBUTING.md) file for more details. | ||
### Contributors | ||
Abstract LevelDOWN is only possible due to the excellent work of the following contributors: | ||
<table><tbody> | ||
<tr><th align="left">Rod Vagg</th><td><a href="https://github.com/rvagg">GitHub/rvagg</a></td><td><a href="http://twitter.com/rvagg">Twitter/@rvagg</a></td></tr> | ||
<tr><th align="left">John Chesley</th><td><a href="https://github.com/chesles/">GitHub/chesles</a></td><td><a href="http://twitter.com/chesles">Twitter/@chesles</a></td></tr> | ||
<tr><th align="left">Jake Verbaten</th><td><a href="https://github.com/raynos">GitHub/raynos</a></td><td><a href="http://twitter.com/raynos2">Twitter/@raynos2</a></td></tr> | ||
<tr><th align="left">Dominic Tarr</th><td><a href="https://github.com/dominictarr">GitHub/dominictarr</a></td><td><a href="http://twitter.com/dominictarr">Twitter/@dominictarr</a></td></tr> | ||
<tr><th align="left">Max Ogden</th><td><a href="https://github.com/maxogden">GitHub/maxogden</a></td><td><a href="http://twitter.com/maxogden">Twitter/@maxogden</a></td></tr> | ||
<tr><th align="left">Lars-Magnus Skog</th><td><a href="https://github.com/ralphtheninja">GitHub/ralphtheninja</a></td><td><a href="http://twitter.com/ralphtheninja">Twitter/@ralphtheninja</a></td></tr> | ||
<tr><th align="left">David Björklund</th><td><a href="https://github.com/kesla">GitHub/kesla</a></td><td><a href="http://twitter.com/david_bjorklund">Twitter/@david_bjorklund</a></td></tr> | ||
<tr><th align="left">Julian Gruber</th><td><a href="https://github.com/juliangruber">GitHub/juliangruber</a></td><td><a href="http://twitter.com/juliangruber">Twitter/@juliangruber</a></td></tr> | ||
<tr><th align="left">Paolo Fragomeni</th><td><a href="https://github.com/hij1nx">GitHub/hij1nx</a></td><td><a href="http://twitter.com/hij1nx">Twitter/@hij1nx</a></td></tr> | ||
<tr><th align="left">Anton Whalley</th><td><a href="https://github.com/No9">GitHub/No9</a></td><td><a href="https://twitter.com/antonwhalley">Twitter/@antonwhalley</a></td></tr> | ||
<tr><th align="left">Matteo Collina</th><td><a href="https://github.com/mcollina">GitHub/mcollina</a></td><td><a href="https://twitter.com/matteocollina">Twitter/@matteocollina</a></td></tr> | ||
</tbody></table> | ||
<a name="licence"></a> | ||
Licence & copyright | ||
------------------- | ||
Copyright (c) 2012-2013 Abstract LevelDOWN contributors (listed above). | ||
Abstract LevelDOWN is licensed under an MIT +no-false-attribs license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE file for more details. |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No contributors or author data
MaintenancePackage does not specify a list of contributors or an author in package.json.
Found 1 instance in 1 package
70236
19
1454
1
142
0