Skip to content
This repository was archived by the owner on Dec 2, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = Level

const AbstractLevelDOWN = require('abstract-leveldown').AbstractLevelDOWN
const inherits = require('inherits')
const parallel = require('run-parallel-limit')
const Iterator = require('./iterator')
const serialize = require('./util/serialize')
const deserialize = require('./util/deserialize')
Expand All @@ -22,7 +23,8 @@ function Level (location, opts) {
bufferKeys: support.bufferKeys(indexedDB),
snapshots: true,
permanence: true,
clear: true
clear: true,
getMany: true
})

opts = opts || {}
Expand Down Expand Up @@ -102,6 +104,32 @@ Level.prototype._get = function (key, options, callback) {
})
}

Level.prototype._getMany = function (keys, options, callback) {
const asBuffer = options.asBuffer
const store = this.store('readonly')
const tasks = keys.map((key) => (next) => {
let request

try {
request = store.get(key)
} catch (err) {
return next(err)
}

request.onsuccess = () => {
const value = request.result
next(null, value === undefined ? value : deserialize(value, asBuffer))
}

request.onerror = (ev) => {
ev.stopPropagation()
next(request.error)
}
})

parallel(tasks, 16, callback)
}

Level.prototype._del = function (key, options, callback) {
const store = this.store('readwrite')
let req
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
"sauce-labs.svg"
],
"dependencies": {
"abstract-leveldown": "^7.0.0",
"abstract-leveldown": "^7.2.0",
"buffer": "^6.0.3",
"inherits": "^2.0.3",
"ltgt": "^2.1.2"
"ltgt": "^2.1.2",
"run-parallel-limit": "^1.1.0"
},
"devDependencies": {
"airtap": "^4.0.1",
Expand Down
5 changes: 3 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ const testCommon = suite.common({
// Support of buffer keys depends on environment
bufferKeys: leveljs(uuid()).supports.bufferKeys,

// Opt-in to new clear() tests
clear: true
// Opt-in to new tests
clear: true,
getMany: true
})

// Test abstract-leveldown compliance
Expand Down