From eb48cbcaa5f2f29213d2f02e40b0c85a935499c7 Mon Sep 17 00:00:00 2001 From: Kris Zyp Date: Sun, 15 Sep 2024 14:20:25 -0600 Subject: [PATCH] Add async and mapError to TS definition, #304 --- index.d.ts | 8 ++++++++ read.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index e0354c20d..3ba0ca55c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -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 @@ -439,6 +446,7 @@ declare namespace lmdb { filter(callback: (entry: T) => any): RangeIterable [Symbol.iterator]() : Iterator forEach(callback: (entry: T) => any): void + mapError(callback: (error: Error) => U): RangeIterable onDone?: Function asArray: T[] } diff --git a/read.js b/read.js index 01feaf4c6..0587d5501 100644 --- a/read.js +++ b/read.js @@ -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