Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

leveldown

Package Overview
Dependencies
Maintainers
4
Versions
108
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

leveldown - npm Package Compare versions

Comparing version 3.0.2 to 4.0.0

12

chained-batch.js

@@ -1,5 +0,4 @@

const util = require('util')
, AbstractChainedBatch = require('abstract-leveldown').AbstractChainedBatch
const util = require('util')
const AbstractChainedBatch = require('abstract-leveldown').AbstractChainedBatch
function ChainedBatch (db) {

@@ -10,3 +9,2 @@ AbstractChainedBatch.call(this, db)

ChainedBatch.prototype._put = function (key, value) {

@@ -16,3 +14,2 @@ this.binding.put(key, value)

ChainedBatch.prototype._del = function (key) {

@@ -22,3 +19,2 @@ this.binding.del(key)

ChainedBatch.prototype._clear = function (key) {

@@ -28,3 +24,2 @@ this.binding.clear(key)

ChainedBatch.prototype._write = function (options, callback) {

@@ -36,3 +31,2 @@ this.binding.write(options, callback)

module.exports = ChainedBatch
module.exports = ChainedBatch

@@ -5,2 +5,21 @@ # Changelog

## [4.0.0] - 2018-05-16
### Added
* Import and fix gc test from `levelup` (@vweevers)
* Add `standard` (@ralphtheninja)
* Add a note on upgrading to 2.0.1/3.0.1 (@ralphtheninja)
### Changed
* Upgrade to `verify-travis-appveyor@^3.0.0` (@ralphtheninja)
* Change deprecated `node-uuid` to `uuid` (@ralphtheninja)
* Update `README` format (@ralphtheninja)
### Fixed
* Fix docs for `approximateSize()` (@ralphtheninja)
### Removed
* Remove node 4 from Travis and AppVeyor (@ralphtheninja)
* Remove TypeScript typings (@meirionhughes)
## [3.0.2] - 2018-05-05

@@ -673,3 +692,4 @@

[Unreleased]: https://github.com/level/leveldown/compare/v3.0.2...HEAD
[Unreleased]: https://github.com/level/leveldown/compare/v4.0.0...HEAD
[4.0.0]: https://github.com/level/leveldown/compare/v3.0.2...v4.0.0
[3.0.2]: https://github.com/level/leveldown/compare/v3.0.1...v3.0.2

@@ -676,0 +696,0 @@ [3.0.1]: https://github.com/level/leveldown/compare/v3.0.0...v3.0.1

@@ -1,12 +0,11 @@

const util = require('util')
, AbstractIterator = require('abstract-leveldown').AbstractIterator
, fastFuture = require('fast-future')
const util = require('util')
const AbstractIterator = require('abstract-leveldown').AbstractIterator
const fastFuture = require('fast-future')
function Iterator (db, options) {
AbstractIterator.call(this, db)
this.binding = db.binding.iterator(options)
this.cache = null
this.finished = false
this.binding = db.binding.iterator(options)
this.cache = null
this.finished = false
this.fastFuture = fastFuture()

@@ -18,11 +17,14 @@ }

Iterator.prototype.seek = function (target) {
if (this._ended)
if (this._ended) {
throw new Error('cannot call seek() after end()')
if (this._nexting)
}
if (this._nexting) {
throw new Error('cannot call seek() before next() has completed')
if (typeof target !== 'string' && !Buffer.isBuffer(target))
}
if (typeof target !== 'string' && !Buffer.isBuffer(target)) {
throw new Error('seek() requires a string or buffer key')
if (target.length == 0)
}
if (target.length === 0) {
throw new Error('cannot seek() to an empty key')
}

@@ -36,7 +38,7 @@ this.cache = null

var that = this
, key
, value
var key
var value
if (this.cache && this.cache.length) {
key = this.cache.pop()
key = this.cache.pop()
value = this.cache.pop()

@@ -47,3 +49,2 @@

})
} else if (this.finished) {

@@ -57,3 +58,3 @@ this.fastFuture(function () {

that.cache = array
that.cache = array
that.finished = finished

@@ -67,3 +68,2 @@ that._next(callback)

Iterator.prototype._end = function (callback) {

@@ -74,3 +74,2 @@ delete this.cache

module.exports = Iterator

@@ -1,13 +0,11 @@

const util = require('util')
, AbstractLevelDOWN = require('abstract-leveldown').AbstractLevelDOWN
const util = require('util')
const AbstractLevelDOWN = require('abstract-leveldown').AbstractLevelDOWN
const binding = require('bindings')('leveldown').leveldown
const ChainedBatch = require('./chained-batch')
const Iterator = require('./iterator')
, binding = require('bindings')('leveldown').leveldown
, ChainedBatch = require('./chained-batch')
, Iterator = require('./iterator')
function LevelDOWN (location) {
if (!(this instanceof LevelDOWN))
if (!(this instanceof LevelDOWN)) {
return new LevelDOWN(location)
}

@@ -20,3 +18,2 @@ AbstractLevelDOWN.call(this, location)

LevelDOWN.prototype._open = function (options, callback) {

@@ -26,3 +23,2 @@ this.binding.open(options, callback)

LevelDOWN.prototype._close = function (callback) {

@@ -32,3 +28,2 @@ this.binding.close(callback)

LevelDOWN.prototype._put = function (key, value, options, callback) {

@@ -38,3 +33,2 @@ this.binding.put(key, value, options, callback)

LevelDOWN.prototype._get = function (key, options, callback) {

@@ -44,3 +38,2 @@ this.binding.get(key, options, callback)

LevelDOWN.prototype._del = function (key, options, callback) {

@@ -50,3 +43,2 @@ this.binding.del(key, options, callback)

LevelDOWN.prototype._chainedBatch = function () {

@@ -56,3 +48,2 @@ return new ChainedBatch(this)

LevelDOWN.prototype._batch = function (operations, options, callback) {

@@ -62,3 +53,2 @@ return this.binding.batch(operations, options, callback)

LevelDOWN.prototype.approximateSize = function (start, end, callback) {

@@ -82,3 +72,2 @@ if (start == null ||

LevelDOWN.prototype.compactRange = function (start, end, callback) {

@@ -88,6 +77,6 @@ this.binding.compactRange(start, end, callback)

LevelDOWN.prototype.getProperty = function (property) {
if (typeof property != 'string')
if (typeof property !== 'string') {
throw new Error('getProperty() requires a valid `property` argument')
}

@@ -97,3 +86,2 @@ return this.binding.getProperty(property)

LevelDOWN.prototype._iterator = function (options) {

@@ -103,12 +91,12 @@ return new Iterator(this, options)

LevelDOWN.destroy = function (location, callback) {
if (arguments.length < 2)
if (arguments.length < 2) {
throw new Error('destroy() requires `location` and `callback` arguments')
if (typeof location != 'string')
}
if (typeof location !== 'string') {
throw new Error('destroy() requires a location string argument')
if (typeof callback != 'function')
}
if (typeof callback !== 'function') {
throw new Error('destroy() requires a callback function argument')
}

@@ -118,12 +106,12 @@ binding.destroy(location, callback)

LevelDOWN.repair = function (location, callback) {
if (arguments.length < 2)
if (arguments.length < 2) {
throw new Error('repair() requires `location` and `callback` arguments')
if (typeof location != 'string')
}
if (typeof location !== 'string') {
throw new Error('repair() requires a location string argument')
if (typeof callback != 'function')
}
if (typeof callback !== 'function') {
throw new Error('repair() requires a callback function argument')
}

@@ -133,3 +121,2 @@ binding.repair(location, callback)

module.exports = LevelDOWN.default = LevelDOWN
{
"name": "leveldown",
"description": "A low-level Node.js LevelDB binding",
"version": "3.0.2",
"version": "4.0.0",
"contributors": [

@@ -33,3 +33,2 @@ "Rod Vagg <r@va.gg> (https://github.com/rvagg)",

"main": "leveldown.js",
"typings": "leveldown.d.ts",
"dependencies": {

@@ -43,3 +42,2 @@ "abstract-leveldown": "~4.0.0",

"devDependencies": {
"@types/node": "^8.0.31",
"async": "^2.0.1",

@@ -53,3 +51,2 @@ "delayed": "~1.0.1",

"monotonic-timestamp": "~0.0.8",
"node-uuid": "~1.4.3",
"optimist": "~0.6.1",

@@ -61,8 +58,10 @@ "prebuild": "^7.0.0",

"slump": "~2.0.0",
"standard": "^11.0.1",
"tape": "^4.5.1",
"verify-travis-appveyor": "^2.0.0"
"uuid": "^3.2.1",
"verify-travis-appveyor": "^3.0.0"
},
"scripts": {
"install": "prebuild-install || node-gyp rebuild",
"test": "verify-travis-appveyor && (tape test/*-test.js | faucet) && prebuild-ci",
"test": "standard && verify-travis-appveyor && (tape test/*-test.js | faucet) && prebuild-ci",
"rebuild": "prebuild --compile",

@@ -74,9 +73,4 @@ "prebuild": "prebuild --all --strip --verbose"

"engines": {
"node": ">=4"
},
"greenkeeper": {
"ignore": [
"@types/node"
]
"node": ">=6"
}
}

@@ -1,3 +0,2 @@

leveldown
=========
# leveldown

@@ -11,17 +10,16 @@ [![level badge][level-badge]](https://github.com/level/awesome)

[![npm](https://img.shields.io/npm/dm/leveldown.svg)](https://www.npmjs.com/package/leveldown)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
* <a href="#intro">Introduction</a>
* <a href="#platforms">Supported platforms</a>
* <a href="#api">API</a>
* <a href="#safety">Safety</a>
* <a href="#snapshots">Snapshots</a>
* <a href="#support">Getting support</a>
* <a href="#contributing">Contributing</a>
* <a href="#license">Licence &amp; copyright</a>
* [Introduction](#introduction)
* [Supported Platforms](#supported-platforms)
* [API](#api)
* [Safety](#safety)
* [Snapshots](#snapshots)
* [Getting Support](#getting-support)
* [Contributing](#contributing)
* [License](#license)
**If you are upgrading:** please see [UPGRADING.md](UPGRADING.md).
<a name="intro"></a>
Introduction
----------------------------
## Introduction

@@ -34,5 +32,3 @@ This module was originally part of [`levelup`](https://github.com/level/levelup) but was later extracted and now serves as a stand-alone binding for LevelDB.

<a name="platforms"></a>
Supported platforms
----------------------------
## Supported Platforms

@@ -51,32 +47,28 @@ We aim to support *at least* Active LTS and Current Node.js releases. `leveldown` ships with prebuilt binaries for [many platforms](https://github.com/Level/leveldown/releases) and is known to work on:

<a name="api"></a>
## API
* <a href="#ctor"><code><b>leveldown()</b></code></a>
* <a href="#leveldown_open"><code><b>leveldown#open()</b></code></a>
* <a href="#leveldown_close"><code><b>leveldown#close()</b></code></a>
* <a href="#leveldown_put"><code><b>leveldown#put()</b></code></a>
* <a href="#leveldown_get"><code><b>leveldown#get()</b></code></a>
* <a href="#leveldown_del"><code><b>leveldown#del()</b></code></a>
* <a href="#leveldown_batch"><code><b>leveldown#batch()</b></code></a>
* <a href="#leveldown_approximateSize"><code><b>leveldown#approximateSize()</b></code></a>
* <a href="#leveldown_compactRange"><code><b>leveldown#compactRange()</b></code></a>
* <a href="#leveldown_getProperty"><code><b>leveldown#getProperty()</b></code></a>
* <a href="#leveldown_iterator"><code><b>leveldown#iterator()</b></code></a>
* <a href="#iterator_next"><code><b>iterator#next()</b></code></a>
* <a href="#iterator_seek"><code><b>iterator#seek()</b></code></a>
* <a href="#iterator_end"><code><b>iterator#end()</b></code></a>
* <a href="#leveldown_destroy"><code><b>leveldown.destroy()</b></code></a>
* <a href="#leveldown_repair"><code><b>leveldown.repair()</b></code></a>
* [<code><b>leveldown()</b></code>](#ctor)
* [<code>db.<b>open()</b></code>](#leveldown_open)
* [<code>db.<b>close()</b></code>](#leveldown_close)
* [<code>db.<b>put()</b></code>](#leveldown_put)
* [<code>db.<b>get()</b></code>](#leveldown_get)
* [<code>db.<b>del()</b></code>](#leveldown_del)
* [<code>db.<b>batch()</b></code>](#leveldown_batch)
* [<code>db.<b>approximateSize()</b></code>](#leveldown_approximateSize)
* [<code>db.<b>compactRange()</b></code>](#leveldown_compactRange)
* [<code>db.<b>getProperty()</b></code>](#leveldown_getProperty)
* [<code>db.<b>iterator()</b></code>](#leveldown_iterator)
* [<code>iterator.<b>next()</b></code>](#iterator_next)
* [<code>iterator.<b>seek()</b></code>](#iterator_seek)
* [<code>iterator.<b>end()</b></code>](#iterator_end)
* [<code>leveldown.<b>destroy()</b></code>](#leveldown_destroy)
* [<code>leveldown.<b>repair()</b></code>](#leveldown_repair)
--------------------------------------------------------
<a name="ctor"></a>
### leveldown(location)
### `db = leveldown(location)`
<code>leveldown()</code> returns a new `leveldown` instance. `location` is a String pointing to the LevelDB location to be opened.
--------------------------------------------------------
<a name="leveldown_open"></a>
### leveldown#open([options, ]callback)
### `db.open([options, ]callback)`
<code>open()</code> is an instance method on an existing database object.

@@ -116,11 +108,8 @@

--------------------------------------------------------
<a name="leveldown_close"></a>
### leveldown#close(callback)
### `db.close(callback)`
<code>close()</code> is an instance method on an existing database object. The underlying LevelDB database will be closed and the `callback` function will be called with no arguments if the operation is successful or with a single `error` argument if the operation failed for any reason.
--------------------------------------------------------
<a name="leveldown_put"></a>
### leveldown#put(key, value[, options], callback)
### `db.put(key, value[, options], callback)`
<code>put()</code> is an instance method on an existing database object, used to store new entries, or overwrite existing entries in the LevelDB store.

@@ -138,6 +127,4 @@

--------------------------------------------------------
<a name="leveldown_get"></a>
### leveldown#get(key[, options], callback)
### `db.get(key[, options], callback)`
<code>get()</code> is an instance method on an existing database object, used to fetch individual entries from the LevelDB store.

@@ -159,6 +146,4 @@

--------------------------------------------------------
<a name="leveldown_del"></a>
### leveldown#del(key[, options], callback)
### `db.del(key[, options], callback)`
<code>del()</code> is an instance method on an existing database object, used to delete entries from the LevelDB store.

@@ -174,6 +159,4 @@

--------------------------------------------------------
<a name="leveldown_batch"></a>
### leveldown#batch(operations[, options], callback)
### `db.batch(operations[, options], callback)`
<code>batch()</code> is an instance method on an existing database object. Used for very fast bulk-write operations (both *put* and *delete*). The `operations` argument should be an `Array` containing a list of operations to be executed sequentially, although as a whole they are performed as an atomic operation inside LevelDB.

@@ -191,6 +174,4 @@

--------------------------------------------------------
<a name="leveldown_approximateSize"></a>
### leveldown#approximateSize(start, end, callback)
### `db.approximateSize(start, end, callback)`
<code>approximateSize()</code> is an instance method on an existing database object. Used to get the approximate number of bytes of file system space used by the range `[start..end)`. The result may not include recently written data.

@@ -200,8 +181,6 @@

The `callback` function will be called with no arguments if the operation is successful or with a single `error` argument if the operation failed for any reason.
The `callback` function will be called with a single `error` if the operation failed for any reason. If successful the first argument will be `null` and the second argument will be the approximate size as a Number.
--------------------------------------------------------
<a name="leveldown_compactRange"></a>
### leveldown#compactRange(start, end, callback)
### `db.compactRange(start, end, callback)`
<code>compactRange()</code> is an instance method on an existing database object. Used to manually trigger a database compaction in the range `[start..end)`.

@@ -213,6 +192,4 @@

--------------------------------------------------------
<a name="leveldown_getProperty"></a>
### leveldown#getProperty(property)
### `db.getProperty(property)`
<code>getProperty</code> can be used to get internal details from LevelDB. When issued with a valid property string, a readable string will be returned (this method is synchronous).

@@ -228,6 +205,4 @@

--------------------------------------------------------
<a name="leveldown_iterator"></a>
### leveldown#iterator([options])
### `iterator = db.iterator([options])`
<code>iterator()</code> is an instance method on an existing database object. It returns a new **Iterator** instance.

@@ -259,6 +234,4 @@

--------------------------------------------------------
<a name="iterator_next"></a>
### iterator#next(callback)
### `iterator.next(callback)`
<code>next()</code> is an instance method on an existing iterator object, used to increment the underlying LevelDB iterator and return the entry at that location.

@@ -279,6 +252,4 @@

--------------------------------------------------------
<a name="iterator_seek"></a>
### iterator#seek(key)
### `iterator.seek(key)`
<code>seek()</code> is an instance method on an existing iterator object, used to seek the underlying LevelDB iterator to a given key.

@@ -288,11 +259,8 @@

--------------------------------------------------------
<a name="iterator_end"></a>
### iterator#end(callback)
### `iterator.end(callback)`
<code>end()</code> is an instance method on an existing iterator object. The underlying LevelDB iterator will be deleted and the `callback` function will be called with no arguments if the operation is successful or with a single `error` argument if the operation failed for any reason.
--------------------------------------------------------
<a name="leveldown_destroy"></a>
### leveldown.destroy(location, callback)
### `leveldown.destroy(location, callback)`
<code>destroy()</code> is used to completely remove an existing LevelDB database directory. You can use this function in place of a full directory *rm* if you want to be sure to only remove LevelDB-related files. If the directory only contains LevelDB files, the directory itself will be removed as well. If there are additional, non-LevelDB files in the directory, those files, and the directory, will be left alone.

@@ -302,5 +270,4 @@

--------------------------------------------------------
<a name="leveldown_repair"></a>
### leveldown.repair(location, callback)
### `leveldown.repair(location, callback)`
<code>repair()</code> can be used to attempt a restoration of a damaged LevelDB store. From the LevelDB documentation:

@@ -316,9 +283,6 @@

## Safety
<a name="safety"></a>
Safety
------
### Database State
### Database state
Currently `leveldown` does not track the state of the underlying LevelDB instance. This means that calling `open()` on an already open database may result in an error. Likewise, calling any other operation on a non-open database may result in an error.

@@ -328,11 +292,7 @@

<a name="snapshots"></a>
Snapshots
---------------
## Snapshots
`leveldown` exposes a feature of LevelDB called [snapshots](https://github.com/google/leveldb/blob/master/doc/index.md#snapshots). This means that when you do e.g. `createReadStream` and `createWriteStream` at the same time, any data modified by the write stream will not affect data emitted from the read stream. In other words, a LevelDB Snapshot captures the latest state at the time the snapshot was created, enabling the snapshot to iterate or read the data without seeing any subsequent writes. Any read not performed on a snapshot will implicitly use the latest state.
<a name="support"></a>
Getting support
---------------
## Getting Support

@@ -345,5 +305,3 @@ There are multiple ways you can find help in using LevelDB in Node.js:

<a name="contributing"></a>
Contributing
------------
## Contributing

@@ -360,5 +318,3 @@ `leveldown` is an **OPEN Open Source Project**. This means that:

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

@@ -365,0 +321,0 @@ Copyright &copy; 2012-2018 `leveldown` [contributors](https://github.com/level/community#contributors).

@@ -5,2 +5,10 @@ # Upgrade Guide

## v4
Dropped support for node 4. No other breaking changes.
## v3.0.1
If you're using node v10 you'll need at least `leveldown@2.0.1` to successfully compile. In addition, if you want prebuilt binaries you'll need at least `leveldown@3.0.1`.
## v3

@@ -7,0 +15,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc