Socket
Socket
Sign inDemoInstall

abstract-leveldown

Package Overview
Dependencies
Maintainers
1
Versions
79
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abstract-leveldown - npm Package Compare versions

Comparing version 0.12.4 to 1.0.0

25

abstract-leveldown.js

@@ -130,2 +130,5 @@ /* Copyright (c) 2013 Rod Vagg, MIT License */

if (typeof array == 'function')
callback = array
if (typeof callback != 'function')

@@ -137,3 +140,3 @@ throw new Error('batch(array) requires a callback argument')

if (typeof options != 'object')
if (!options || typeof options != 'object')
options = {}

@@ -206,17 +209,9 @@

options.reverse = !!options.reverse
options.keys = 'keys' in options ? !!options.keys : true
options.values = 'values' in options ? !!options.values : true
options.limit = 'limit' in options ? options.limit : -1
options.fillCache = !!options.fillCache
options.keyAsBuffer = 'keyAsBuffer' in options ? !!options.keyAsBuffer : true
options.valueAsBuffer = 'valueAsBuffer' in options ? !!options.valueAsBuffer : true
// fix `start` so it takes into account gt, gte, lt, lte as appropriate
if (options.reverse && options.lt)
options.start = options.lt
if (options.reverse && options.lte)
options.start = options.lte
if (!options.reverse && options.gt)
options.start = options.gt
if (!options.reverse && options.gte)
options.start = options.gte
if ((options.reverse && options.lt && !options.lte)
|| (!options.reverse && options.gt && !options.gte))
options.exclusiveStart = true // start should *not* include matching key
return options

@@ -223,0 +218,0 @@ }

@@ -53,2 +53,30 @@ var db

})
test('test batch() with missing array', function (t) {
db.batch(function (err) {
t.equal(err.message, 'batch(array) requires an array argument', 'correct error message')
t.end()
})
})
test('test batch() with undefined array', function (t) {
db.batch(void 0, function (err) {
t.equal(err.message, 'batch(array) requires an array argument', 'correct error message')
t.end()
})
})
test('test batch() with null array', function (t) {
db.batch(null, function (err) {
t.equal(err.message, 'batch(array) requires an array argument', 'correct error message')
t.end()
})
})
test('test batch() with null options', function (t) {
db.batch([], null, function (err) {
t.notOk(err, 'no error')
t.end()
})
})
}

@@ -55,0 +83,0 @@

@@ -362,2 +362,10 @@ var db

test('test iterator with limit=0 should not iterate over anything', function (t) {
collectEntries(db.iterator({ keyAsBuffer: false, valueAsBuffer: false, limit: 0 }), function (err, data) {
t.notOk(err, 'no error')
t.equal(data.length, 0, 'correct number of entries')
t.end()
})
})
test('test iterator with end after limit', function (t) {

@@ -364,0 +372,0 @@ collectEntries(db.iterator({ keyAsBuffer: false, valueAsBuffer: false, limit: 20, end: '50' }), function (err, data) {

@@ -10,2 +10,12 @@ module.exports.args = function (leveldown, test) {

})
test('test database creation non-string location throws', function (t) {
t.throws(
function () {
leveldown({})
}
, { name: 'Error', message: 'constructor requires a location string argument' }
, 'non-string location leveldown() throws'
)
t.end()
})

@@ -12,0 +22,0 @@ test('test database open no-arg throws', function (t) {

@@ -51,2 +51,18 @@ module.exports.setUp = function (test, testCommon) {

})
test('test database open, close and open', function (t) {
var db = leveldown(testCommon.location())
db.open(function (err) {
t.notOk(err, 'no error')
db.close(function (err) {
t.notOk(err, 'no error')
db.open(function (err) {
t.notOk(err, 'no error')
db.close(function () {
t.end()
})
})
})
})
})
}

@@ -53,0 +69,0 @@

2

package.json
{
"name": "abstract-leveldown",
"description": "An abstract prototype matching the LevelDOWN API",
"version": "0.12.4",
"version": "1.0.0",
"contributors": [

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

@@ -293,2 +293,10 @@ const tap = require('tap')

test.batch(expectedArray, null, expectedCb)
t.equal(spy.callCount, 3, 'got _batch() call')
t.equal(spy.getCall(2).thisValue, test, '`this` on _batch() was correct')
t.equal(spy.getCall(2).args.length, 3, 'got three arguments')
t.equal(spy.getCall(2).args[0], expectedArray, 'got expected array argument')
t.ok(spy.getCall(2).args[1], 'options should not be null')
t.equal(spy.getCall(2).args[2], expectedCb, 'got expected callback argument')
t.end()

@@ -479,3 +487,3 @@ })

var spy = sinon.spy()
, expectedOptions = { options: 1, reverse: false } // reverse now explicitly set
, expectedOptions = { options: 1, reverse: false, keys: true, values: true, limit: -1, fillCache: false, keyAsBuffer: true, valueAsBuffer: true }
, test

@@ -482,0 +490,0 @@

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