From 2cd5b94d11045a5fb5efae8bfa2b65b62a0cf127 Mon Sep 17 00:00:00 2001 From: Vincent Weevers Date: Mon, 27 Jan 2025 19:16:44 +0100 Subject: [PATCH] Fix types --- index.d.ts | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/index.d.ts b/index.d.ts index 3d1398b..34a6c96 100644 --- a/index.d.ts +++ b/index.d.ts @@ -4,6 +4,8 @@ import { AbstractOpenOptions, AbstractGetOptions, AbstractGetManyOptions, + AbstractHasOptions, + AbstractHasManyOptions, AbstractPutOptions, AbstractDelOptions, AbstractBatchOperation, @@ -16,6 +18,7 @@ import { AbstractKeyIteratorOptions, AbstractValueIterator, AbstractValueIteratorOptions, + AbstractSnapshot, Transcoder } from 'abstract-level' @@ -48,11 +51,17 @@ declare class ClassicLevel open (): Promise open (options: OpenOptions): Promise - get (key: KDefault): Promise - get (key: K, options: GetOptions): Promise + get (key: KDefault): Promise + get (key: K, options: GetOptions): Promise - getMany (keys: KDefault[]): Promise - getMany (keys: K[], options: GetManyOptions): Promise + getMany (keys: KDefault[]): Promise<(VDefault | undefined)[]> + getMany (keys: K[], options: GetManyOptions): Promise<(V | undefined)[]> + + has (key: KDefault): Promise + has (key: K, options: HasOptions): Promise + + hasMany (keys: KDefault[]): Promise + hasMany (keys: K[], options: HasManyOptions): Promise put (key: KDefault, value: VDefault): Promise put (key: K, value: V, options: PutOptions): Promise @@ -73,6 +82,8 @@ declare class ClassicLevel values (): ValueIterator values (options: ValueIteratorOptions): ValueIterator + snapshot (options?: any | undefined): Snapshot + /** * Get the approximate number of bytes of file system space used by the range * `[start..end)`. @@ -198,15 +209,15 @@ export interface OpenOptions extends AbstractOpenOptions { /** * Allows multi-threaded access to a single DB instance for sharing a DB * across multiple worker threads within the same process. - * + * * @defaultValue `false` */ multithreading?: boolean | undefined } /** - * Additional options for the {@link ClassicLevel.get} and {@link ClassicLevel.getMany} - * methods. + * Additional options for the {@link ClassicLevel.get}, {@link ClassicLevel.getMany}, + * {@link ClassicLevel.has} and {@link ClassicLevel.hasMany} methods. */ declare interface ReadOptions { /** @@ -229,6 +240,16 @@ export interface GetOptions extends AbstractGetOptions, ReadOptions */ export interface GetManyOptions extends AbstractGetManyOptions, ReadOptions {} +/** + * Options for the {@link ClassicLevel.has} method. + */ +export interface HasOptions extends AbstractHasOptions, ReadOptions {} + +/** + * Options for the {@link ClassicLevel.hasMany} method. + */ +export interface HasManyOptions extends AbstractHasManyOptions, ReadOptions {} + /** * Additional options for the {@link ClassicLevel.iterator}, {@link ClassicLevel.keys} * and {@link ClassicLevel.values} methods. @@ -315,3 +336,5 @@ export type ValueIterator = AbstractValueIterator = AbstractIteratorOptions & AdditionalIteratorOptions export type KeyIteratorOptions = AbstractKeyIteratorOptions & AdditionalIteratorOptions export type ValueIteratorOptions = AbstractValueIteratorOptions & AdditionalIteratorOptions + +export type Snapshot = AbstractSnapshot