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

aolog

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aolog - npm Package Compare versions

Comparing version 2.0.6 to 3.0.0

94

index.js

@@ -21,2 +21,3 @@ 'use strict'

var offset = (typeof opts.offset !== 'undefined' ? opts.offset : def)
var index = offset

@@ -30,2 +31,6 @@ var stack = [{obj: over}]

if (stack.length === 0) {
return cb(null, { eof: true })
}
if (typeof stack[0].idx === 'undefined') {

@@ -41,24 +46,37 @@ if (offset !== 'resolved') {

stack[0].obj.get(stack[0].idx, fullfilter, function (err, element, status) {
if (err) return cb(err)
stack[0].obj.get(stack[0].idx, fullfilter, function (err, res) {
if (err) return cb(err)
if (status === EOF) {
stack.shift()
// toplevel eof?
if (stack.length === 0) return cb(null, null, EOF)
reverse ? stack[0].idx-- : stack[0].idx++
self.next(cb)
} else if (status === SKIP) {
reverse ? stack[0].idx-- : stack[0].idx++
self.next(cb)
} else if (typeof element.get === 'function') {
self.pushcount++
stack.unshift({obj: element})
self.next(cb)
} else { // leaf
offset = 'resolved'
reverse ? stack[0].idx-- : stack[0].idx++
cb(null, element)
}
})
// console.log('res')
// console.log(res)
if (res.eof) {
// console.log('eof')
stack.shift()
if (!stack[0]) return cb(null, { eof: true })
reverse ? stack[0].idx-- : stack[0].idx++
self.next(cb)
} else if (res.skip) {
// console.log('skip')
reverse ? stack[0].idx-- : stack[0].idx++
reverse ? index -= res.skip : index += res.skip
self.next(cb)
} else if (res.push) {
// console.log('push')
self.pushcount++
// console.log(res.push)
stack.unshift({obj: res.push})
self.next(cb)
} else if (typeof res.element !== 'undefined') {
// console.log('element yo')
offset = 'resolved'
reverse ? stack[0].idx-- : stack[0].idx++
cb(null, { element: res.element, index: index })
reverse ? index-- : index++
} else {
console.log('eh')
}
})
},

@@ -69,7 +87,7 @@ take: function (nr, cb) {

async.forever(function (next) {
self.next(function (err, value, status) {
self.next(function (err, res) {
if (err) return cb(err)
if (status === EOF) return cb(null, accum)
if (res.eof) return cb(null, accum)
if (!nr--) return cb(null, accum)
accum.push(value)
accum.push(res.element)
next()

@@ -122,2 +140,3 @@ })

get: function (idx, filter, cb) {
// console.log('get in ref')
var self = this

@@ -127,5 +146,5 @@

if (!subsetMatches(self.filters, filter.blooms)) {
cb(null, null, SKIP)
cb(null, { skip: self.count })
} else if (self.ref) {
return cb(null, self.ref)
return cb(null, { push: self.ref })
} else {

@@ -139,3 +158,3 @@ restore(self.persisted.Hash, function (err, res) {

} else {
cb(null, null, EOF)
cb(null, { eof: true })
}

@@ -194,9 +213,10 @@ },

get: function (idx, filter, cb) {
// console.log('get in bucket')
var el = this.elements[idx]
if (typeof el === 'undefined') return cb(null, null, EOF)
if (typeof el === 'undefined') return cb(null, { eof: true })
if (matches(el, filter.words)) {
return cb(null, el)
return cb(null, { element: el })
} else {
return cb(null, null, SKIP)
return cb(null, { skip: 1 })
}

@@ -264,7 +284,8 @@ },

get: function (idx, filter, cb) {
// console.log('get in branch')
var ref = this.refs[idx]
if (ref) {
cb(null, ref)
cb(null, { push: ref })
} else {
cb(null, null, EOF)
cb(null, { eof: true })
}

@@ -373,6 +394,7 @@ },

get: function (idx, filter, cb) {
if (idx === 0) return cb(null, head)
if (idx === 1) return cb(null, rest)
if (idx === 2) return cb(null, tail)
cb(null, null, EOF)
// console.log('get in finger')
if (idx === 0) return cb(null, { push: head })
if (idx === 1) return cb(null, { push: rest })
if (idx === 2) return cb(null, { push: tail })
cb(null, { eof: true})
},

@@ -379,0 +401,0 @@ iterator: function (opts) {

{
"name": "aolog",
"version": "2.0.6",
"version": "3.0.0",
"description": "Append only log",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -109,7 +109,7 @@ 'use strict'

async.forever(function (next) {
iter.next(function (err, value, status) {
iter.next(function (err, res) {
if (err) throw (err)
if (status === aolog.eof) return next(1)
if (res.eof) return next(1)
result.push(value)
result.push(res.element)
next()

@@ -150,7 +150,7 @@ })

async.forever(function (next) {
iter.next(function (err, value, status) {
iter.next(function (err, res) {
if (err) throw (err)
if (status === aolog.eof) return next(1)
if (res.eof) return next(1)
result.push(value)
result.push(res.element)
next()

@@ -259,3 +259,3 @@ })

if (err) throw err
assert.deepEqual(res, reference[ofs])
assert.deepEqual(res.element, reference[ofs])
if (++count === SIZE) done()

@@ -286,3 +286,3 @@ })

if (err) throw err
assert.deepEqual(res, reference[ofs])
assert.deepEqual(res.element, reference[ofs])
if (++count === SIZE) done()

@@ -317,7 +317,7 @@ })

async.forever(function (next) {
iter.next(function (err, value, status) {
iter.next(function (err, res) {
if (err) throw (err)
if (status === aolog.eof) return next(1)
if (res.eof) return next(1)
result.push(value)
result.push(res.element)
next()

@@ -431,8 +431,8 @@ })

async.forever(function (next) {
iter.next(function (err, value, status) {
iter.next(function (err, res) {
if (err) throw (err)
if (status === aolog.eof) return next(1)
if (res.eof) return next(1)
count++
if (!value.msg.match('buzz')) {
if (!res.element.msg.match('buzz')) {
throw new Error('no buzz!')

@@ -459,4 +459,7 @@ }

}
haystack.push({is: 'needle'})
var needle = {is: 'needle'}
haystack.push(needle)
haystack = _.shuffle(haystack)
var needleidx = haystack.indexOf(needle)

@@ -481,6 +484,6 @@ var result = []

async.forever(function (next) {
iter.next(function (err, value, status) {
iter.next(function (err, res) {
if (err) throw (err)
if (status === aolog.eof) return next(1)
result.push(value)
if (res.eof) return next(1)
result.push(res)
next()

@@ -491,5 +494,10 @@ })

it('should have found the needle', function () {
it('should have found the needle at ' + needleidx, function () {
assert.equal(result.length, 1)
assert.deepEqual(result[0], {is: 'needle'})
assert.deepEqual(result[0], {
element: {
is: 'needle'
},
index: needleidx
})
})

@@ -570,6 +578,6 @@ })

async.forever(function (next) {
iterA.next(function (err, value, status) {
iterA.next(function (err, res) {
if (err) throw (err)
if (status === aolog.eof) return next(1)
resultA.push(value)
if (res.eof) return next(1)
resultA.push(res.element)
next()

@@ -580,6 +588,6 @@ })

async.forever(function (next) {
iterB.next(function (err, value, status) {
iterB.next(function (err, res) {
if (err) throw (err)
if (status === aolog.eof) return next(1)
resultB.push(value)
if (res.eof) return next(1)
resultB.push(res.element)
next()

@@ -603,3 +611,3 @@ })

before(function (done) {
this.timeout(40000)
this.timeout(10000)
add_many(aolog.empty(), SIZE, function (i) { return { is: 'i = ' + i } },

@@ -614,3 +622,3 @@ function (err, res) {

before(function (done) {
this.timeout(40000)
this.timeout(10000)
log.persist(function (err, res) {

@@ -636,3 +644,3 @@ if (err) throw err

before(function (done) {
this.timeout(40000)
this.timeout(10000)
var iterA = log.iterator()

@@ -648,6 +656,6 @@ var iterB = restored.iterator()

async.forever(function (next) {
iterA.next(function (err, value, status) {
iterA.next(function (err, res) {
if (err) throw (err)
if (status === aolog.eof) return next(1)
resultA.push(value)
if (res.eof) return next(1)
resultA.push(res.element)
next()

@@ -657,6 +665,6 @@ })

async.forever(function (next) {
iterB.next(function (err, value, status) {
iterB.next(function (err, res) {
if (err) throw (err)
if (status === aolog.eof) return next(1)
resultB.push(value)
if (res.eof) return next(1)
resultB.push(res.element)
next()

@@ -715,5 +723,5 @@ })

async.forever(function (next) {
iter.next(function (err, value, status) {
iter.next(function (err, res) {
if (err) throw (err)
if (status === aolog.eof) return next(1)
if (res.eof) return next(1)
next()

@@ -720,0 +728,0 @@ })

Sorry, the diff of this file is too big to display

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