Skip to content
This repository has been archived by the owner on Dec 1, 2024. It is now read-only.

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
dominictarr committed Aug 1, 2014
2 parents e3ab0eb + 89c1420 commit 6178d69
Show file tree
Hide file tree
Showing 48 changed files with 155 additions and 170 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ notifications:
- pedro.teixeira@gmail.com
- mail@substack.net
script: npm run-script alltests

39 changes: 0 additions & 39 deletions LICENSE

This file was deleted.

13 changes: 13 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
The MIT License (MIT)
=====================

Copyright (c) 2014 LevelUP contributors
---------------------------------------

*LevelUP contributors listed at <https://github.com/rvagg/node-levelup#contributors>*

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,13 @@ The standard `pause()`, `resume()` and `destroy()` methods are implemented on th

Additionally, you can supply an options object as the first parameter to `createReadStream()` with the following options:

* `'start'`: the key you wish to start the read at. By default it will start at the beginning of the store. Note that the *start* doesn't have to be an actual key that exists, LevelDB will simply find the *next* key, greater than the key you provide.
* `'gt'` (greater than), `'gte'` (greater than or equal) define the lower bound of the range to be streamed. Only records where the key is greater than (or equal to) this option will be included in the range. When `reverse=true` the order will be reversed, but the records streamed will be the same.

* `'end'`: the key you wish to end the read on. By default it will continue until the end of the store. Again, the *end* doesn't have to be an actual key as an (inclusive) `<=`-type operation is performed to detect the end. You can also use the `destroy()` method instead of supplying an `'end'` parameter to achieve the same effect.
* `'lt'` (less than), `'lte'` (less than or equal) define the higher bound of the range to be streamed. Only key/value pairs where the key is less than (or equal to) this option will be included in the range. When `reverse=true` the order will be reversed, but the records streamed will be the same.

* `'reverse'` *(boolean, default: `false`)*: a boolean, set to true if you want the stream to go in reverse order. Beware that due to the way LevelDB works, a reverse seek will be slower than a forward seek.
* `'start', 'end'` legacy ranges - instead use `'gte', 'lte'`

* `'reverse'` *(boolean, default: `false`)*: a boolean, set true and the stream output will be reversed. Beware that due to the way LevelDB works, a reverse seek will be slower than a forward seek.

* `'keys'` *(boolean, default: `true`)*: whether the `'data'` event should contain keys. If set to `true` and `'values'` set to `false` then `'data'` events will simply be keys, rather than objects with a `'key'` property. Used internally by the `createKeyStream()` method.

Expand Down Expand Up @@ -652,13 +654,11 @@ A custom encoding may be provided by passing in an object as an value for `keyEn
{
encode : function (val) { ... }
, decode : function (val) { ... }
, buffer : boolean // encode returns a buffer-like and decode accepts a buffer
, buffer : boolean // encode returns a buffer and decode accepts a buffer
, type : String // name of this encoding type.
}
```

*"buffer-like"* means either a `Buffer` if running in Node, or a Uint8Array if in a browser. Use [bops](https://github.com/chrisdickinson/bops) to get portable binary operations.

<a name="extending"></a>
Extending LevelUP
-----------------
Expand Down Expand Up @@ -720,13 +720,13 @@ LevelUP is only possible due to the excellent work of the following contributors
A large portion of the Windows support comes from code by [Krzysztof Kowalczyk](http://blog.kowalczyk.info/) [@kjk](https://twitter.com/kjk), see his Windows LevelDB port [here](http://code.google.com/r/kkowalczyk-leveldb/). If you're using LevelUP on Windows, you should give him your thanks!


<a name="licence"></a>
Licence &amp; copyright
<a name="license"></a>
License &amp; copyright
-------------------

Copyright (c) 2012-2013 LevelUP contributors (listed above).
Copyright (c) 2012-2014 LevelUP contributors (listed above).

LevelUP 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.
LevelUP is licensed under the MIT license. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details.

=======
*LevelUP builds on the excellent work of the LevelDB and Snappy teams from Google and additional contributors. LevelDB and Snappy are both issued under the [New BSD Licence](http://opensource.org/licenses/BSD-3-Clause).*
6 changes: 3 additions & 3 deletions lib/batch.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Copyright (c) 2012-2013 LevelUP contributors
/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT +no-false-attribs License
* <https://github.com/rvagg/node-levelup/blob/master/LICENSE>
* MIT License
* <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
*/

var util = require('./util')
Expand Down
13 changes: 12 additions & 1 deletion lib/encodings.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ module.exports = (function () {
, buffer : false
, type : 'json'
}
encodings.binary = {
encode : function (data) {
return isBinary(data) ? data : new Buffer(data)
}
, decode : function (data) {
return data
}
, buffer : true
, type : 'binary'
}

encodingNames.forEach(function (type) {
if (encodings[type])
return
Expand All @@ -45,7 +56,7 @@ module.exports = (function () {
return isBinary(data) ? data : new Buffer(data, type)
}
, decode : function (buffer) {
return new Buffer(buffer, type)
return buffer.toString(type)
}
, buffer : true
, type : type // useful for debugging purposes
Expand Down
8 changes: 4 additions & 4 deletions lib/errors.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Copyright (c) 2012-2013 LevelUP contributors
/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT +no-false-attribs License
* <https://github.com/rvagg/node-levelup/blob/master/LICENSE>
* MIT License
* <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
*/

var createError = require('errno').create
Expand All @@ -19,4 +19,4 @@ module.exports = {
, WriteError : createError('WriteError', LevelUPError)
, NotFoundError : NotFoundError
, EncodingError : createError('EncodingError', LevelUPError)
}
}
6 changes: 3 additions & 3 deletions lib/levelup.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Copyright (c) 2012-2013 LevelUP contributors
/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT +no-false-attribs License
* <https://github.com/rvagg/node-levelup/blob/master/LICENSE>
* MIT License
* <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
*/

var EventEmitter = require('events').EventEmitter
Expand Down
4 changes: 2 additions & 2 deletions lib/read-stream.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Copyright (c) 2012-2013 LevelUP contributors
/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT +no-false-attribs License <https://github.com/rvagg/node-levelup/blob/master/LICENSE>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
*/

// NOTE: we are fixed to readable-stream@1.0.x for now
Expand Down
7 changes: 3 additions & 4 deletions lib/util.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Copyright (c) 2012-2013 LevelUP contributors
/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT +no-false-attribs License
* <https://github.com/rvagg/node-levelup/blob/master/LICENSE>
* MIT License
* <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
*/

var extend = require('xtend')
Expand All @@ -16,7 +16,6 @@ var extend = require('xtend')
}

, leveldown

, encodingOpts = (function () {
var eo = {}
for(var e in encodings)
Expand Down
12 changes: 6 additions & 6 deletions lib/write-stream.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
/* Copyright (c) 2012-2013 LevelUP contributors
/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT +no-false-attribs License
* <https://github.com/rvagg/node-levelup/blob/master/LICENSE>
* MIT License
* <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
*/

var Stream = require('stream').Stream
, inherits = require('util').inherits
, extend = require('xtend')
, concatStream = require('concat-stream')
, bl = require('bl')

, setImmediate = global.setImmediate || process.nextTick

Expand Down Expand Up @@ -157,7 +157,7 @@ WriteStream.prototype._write = function (entry) {
if (!key)
return

entry.pipe(concatStream(function (err, data) {
entry.pipe(bl(function (err, data) {
if (err) {
self.writable = false
return self.emit('error', err)
Expand All @@ -167,7 +167,7 @@ WriteStream.prototype._write = function (entry) {
key.indexOf(self._options.fstreamRoot) > -1)
key = key.substr(self._options.fstreamRoot.length + 1)

self.write({ key: key, value: data })
self.write({ key: key, value: data.slice(0) })
}))
}

Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "levelup",
"description": "Fast & simple storage - a Node.js-style LevelDB wrapper",
"version": "0.18.3",
"version": "0.18.6",
"contributors": [
"Rod Vagg <r@va.gg> (https://github.com/rvagg)",
"John Chesley <john@chesl.es> (https://github.com/chesles/)",
Expand Down Expand Up @@ -33,13 +33,13 @@
],
"main": "lib/levelup.js",
"dependencies": {
"concat-stream": "~0.1.1",
"bl": "~0.8.1",
"deferred-leveldown": "~0.2.0",
"errno": "~0.1.0",
"errno": "~0.1.1",
"prr": "~0.0.0",
"readable-stream": "~1.0.17",
"semver": "~2.2.1",
"xtend": "~2.1.1"
"readable-stream": "~1.0.26",
"semver": "~2.3.1",
"xtend": "~3.0.0"
},
"devDependencies": {
"leveldown": "~0.10.0",
Expand Down
6 changes: 3 additions & 3 deletions test/approximate-size-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Copyright (c) 2012-2013 LevelUP contributors
/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT +no-false-attribs License <https://github.com/rvagg/node-levelup/blob/master/LICENSE>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
*/

var levelup = require('../lib/levelup.js')
Expand Down Expand Up @@ -77,4 +77,4 @@ buster.testCase('approximateSize()', {
, done
)
}
})
})
4 changes: 2 additions & 2 deletions test/argument-checking-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Copyright (c) 2012-2013 LevelUP contributors
/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT +no-false-attribs License <https://github.com/rvagg/node-levelup/blob/master/LICENSE>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
*/

var common = require('./common')
Expand Down
6 changes: 3 additions & 3 deletions test/batch-test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Copyright (c) 2012-2013 LevelUP contributors
/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT +no-false-attribs License <https://github.com/rvagg/node-levelup/blob/master/LICENSE>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
*/

var errors = require('../lib/errors.js')
Expand Down Expand Up @@ -369,4 +369,4 @@ buster.testCase('batch()', {
}
}
}
})
})
6 changes: 3 additions & 3 deletions test/benchmarks/engines/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Copyright (c) 2012-2013 LevelUP contributors
/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT +no-false-attribs License <https://github.com/rvagg/node-levelup/blob/master/LICENSE>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
*/

module.exports.LevelUP = require('./levelup')
Expand All @@ -16,4 +16,4 @@ module.exports.Leveled = require('./leveled')
module.exports.Leveled.color = 'cyan'

module.exports.SQLite3 = require('./sqlite3')
module.exports.SQLite3.color = 'blue'
module.exports.SQLite3.color = 'blue'
6 changes: 3 additions & 3 deletions test/benchmarks/engines/leveled.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Copyright (c) 2012-2013 LevelUP contributors
/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT +no-false-attribs License <https://github.com/rvagg/node-levelup/blob/master/LICENSE>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
*/

var leveled = require('leveled')
Expand All @@ -18,4 +18,4 @@ var leveled = require('leveled')
module.exports = {
createDb : createDb
, closeDb : closeDb
}
}
6 changes: 3 additions & 3 deletions test/benchmarks/engines/levelup-nosnappy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Copyright (c) 2012-2013 LevelUP contributors
/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT +no-false-attribs License <https://github.com/rvagg/node-levelup/blob/master/LICENSE>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
*/

var levelup = require('../../../')
Expand All @@ -18,4 +18,4 @@ var levelup = require('../../../')
module.exports = {
createDb : createDb
, closeDb : closeDb
}
}
6 changes: 3 additions & 3 deletions test/benchmarks/engines/levelup-release.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Copyright (c) 2012-2013 LevelUP contributors
/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT +no-false-attribs License <https://github.com/rvagg/node-levelup/blob/master/LICENSE>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
*/

var levelup = require('levelup')
Expand All @@ -18,4 +18,4 @@ var levelup = require('levelup')
module.exports = {
createDb : createDb
, closeDb : closeDb
}
}
6 changes: 3 additions & 3 deletions test/benchmarks/engines/levelup.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Copyright (c) 2012-2013 LevelUP contributors
/* Copyright (c) 2012-2014 LevelUP contributors
* See list at <https://github.com/rvagg/node-levelup#contributing>
* MIT +no-false-attribs License <https://github.com/rvagg/node-levelup/blob/master/LICENSE>
* MIT License <https://github.com/rvagg/node-levelup/blob/master/LICENSE.md>
*/

var levelup = require('../../../')
Expand All @@ -18,4 +18,4 @@ var levelup = require('../../../')
module.exports = {
createDb : createDb
, closeDb : closeDb
}
}
Loading

0 comments on commit 6178d69

Please sign in to comment.