Skip to content

Commit

Permalink
Add async and mapError to TS definition, #304
Browse files Browse the repository at this point in the history
  • Loading branch information
kriszyp committed Sep 15, 2024
1 parent 7e234bf commit eb48cbc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ declare namespace lmdb {
**/
getMany(ids: K[], callback?: (error: any, values: V[]) => any): Promise<(V | undefined)[]>

/**
* @experimental Asynchronously get a value by id.
* @param ids
* @param callback
*/
getAsync(id: K, options?: GetOptions, callback?: (value: V) => any): Promise<(V | undefined)[]>

/**
* Store the provided value, using the provided id/key
* @param id The key for the entry
Expand Down Expand Up @@ -439,6 +446,7 @@ declare namespace lmdb {
filter(callback: (entry: T) => any): RangeIterable<T>
[Symbol.iterator]() : Iterator<T>
forEach(callback: (entry: T) => any): void
mapError<U>(callback: (error: Error) => U): RangeIterable<U>
onDone?: Function
asArray: T[]
}
Expand Down
2 changes: 1 addition & 1 deletion read.js
Original file line number Diff line number Diff line change
Expand Up @@ -818,7 +818,7 @@ export function addReadMethods(

getMany(keys, callback) {
// this is an asynchronous get for multiple keys. It actually works by prefetching asynchronously,
// allowing a separate to absorb the potentially largest cost: hard page faults (and disk I/O).
// allowing a separate thread/task to absorb the potentially largest cost: hard page faults (and disk I/O).
// And then we just do standard sync gets (to deserialized data) to fulfil the callback/promise
// once the prefetch occurs
let promise = callback
Expand Down

0 comments on commit eb48cbc

Please sign in to comment.