level-hooks
Advanced tools
Comparing version 4.0.0 to 4.0.1
24
index.js
var ranges = require('string-range') | ||
//this will be used by queue. | ||
module.exports = function (db) { | ||
@@ -23,19 +22,2 @@ | ||
function checker(range) { | ||
if ('string' === typeof range) | ||
return function (key) { | ||
return key.indexOf(range) == 0 | ||
} | ||
else if(range instanceof RegExp) | ||
return function (key) { | ||
return range.test(key) | ||
} | ||
else if('object' === typeof range) | ||
return function (key) { | ||
return key >= range.start && key <= range.end | ||
} | ||
else if('function' === typeof range) | ||
return range | ||
} | ||
function remover (array, item) { | ||
@@ -53,3 +35,3 @@ return function () { | ||
if(!hook) hook = prefix, prefix = '' | ||
var h = {test: checker(prefix), hook: hook} | ||
var h = {test: ranges.checker(prefix), hook: hook} | ||
posthooks.push(h) | ||
@@ -60,3 +42,3 @@ return remover(posthooks, h) | ||
if(!hook) hook = prefix, prefix = '' | ||
var h = {test: checker(prefix), hook: hook} | ||
var h = {test: ranges.checker(prefix), hook: hook} | ||
prehooks.push(h) | ||
@@ -63,0 +45,0 @@ return remover(prehooks, h) |
{ | ||
"name": "level-hooks", | ||
"description": "pre/post hooks for leveldb", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"homepage": "https://github.com/dominictarr/level-hooks", | ||
@@ -11,3 +11,5 @@ "repository": { | ||
"author": "Dominic Tarr <dominic.tarr@gmail.com> (http://bit.ly/dominictarr)", | ||
"dependencies": {}, | ||
"dependencies": { | ||
"string-range": "~1.0.0" | ||
}, | ||
"devDependencies": { | ||
@@ -14,0 +16,0 @@ "levelup": "~0.6", |
14512
1
355
+ Addedstring-range@~1.0.0
+ Addedstring-range@1.0.0(transitive)