New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

level-hooks

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

level-hooks - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

test/intercept.js

28

index.js

@@ -47,7 +47,7 @@

var put = db._db.put
var del = db._db.del
var batch = db._db.batch
var put = db.put
var del = db.del
var batch = db.batch
function callHooks (ch, opts, cb) {
function callHooks (isBatch, ch, opts, cb) {
for (var i in prehooks) {

@@ -57,25 +57,25 @@ ch = prehooks[i](ch)

}
if(ch.length == 1) {
if(ch.length == 1 && !isBatch) {
var change = ch.shift()
return change.type == 'put'
? put.call(db._db, change.key, change.value, opts, cb)
: del.call(db._db, change.key, opts, cb)
? put.call(db, change.key, change.value, opts, cb)
: del.call(db, change.key, opts, cb)
}
return batch.call(db._db, ch, opts, cb)
return batch.call(db, ch, opts, cb)
}
db._db.put = function (key, value, opts, cb ) {
db.put = function (key, value, opts, cb ) {
var batch = [{key: key, value: value, type: 'put'}]
return callHooks(batch, opts, cb)
return callHooks(false, batch, opts, cb)
}
db._db.del = function (key, opts, cb) {
db.del = function (key, opts, cb) {
var batch = [{key: key, type: 'del'}]
return callHooks(batch, opts, cb)
return callHooks(false, batch, opts, cb)
}
db._db.batch = function (batch, opts, cb) {
return callHooks(batch, opts, cb)
db.batch = function (batch, opts, cb) {
return callHooks(true, batch, opts, cb)
}
}
}
{
"name": "level-hooks",
"description": "pre/post hooks for leveldb",
"version": "1.1.0",
"version": "1.1.1",
"homepage": "https://github.com/dominictarr/level-hooks",

@@ -6,0 +6,0 @@ "repository": {

@@ -47,6 +47,5 @@ var rimraf = require('rimraf')

if(--n) return
console.log('go', n)
db.get('~seq', mac(function (err, val) {
console.log(''+val)
console.log('seq=', ''+val)
assert.equal(Number(''+val), 3)

@@ -53,0 +52,0 @@ db.readStream({start: '~log~', end: '~log~~'})

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