Skip to content

Commit

Permalink
Fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
vweevers committed Jan 27, 2025
1 parent 081a741 commit 2cd5b94
Showing 1 changed file with 30 additions and 7 deletions.
37 changes: 30 additions & 7 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {
AbstractOpenOptions,
AbstractGetOptions,
AbstractGetManyOptions,
AbstractHasOptions,
AbstractHasManyOptions,
AbstractPutOptions,
AbstractDelOptions,
AbstractBatchOperation,
Expand All @@ -16,6 +18,7 @@ import {
AbstractKeyIteratorOptions,
AbstractValueIterator,
AbstractValueIteratorOptions,
AbstractSnapshot,
Transcoder
} from 'abstract-level'

Expand Down Expand Up @@ -48,11 +51,17 @@ declare class ClassicLevel<KDefault = string, VDefault = string>
open (): Promise<void>
open (options: OpenOptions): Promise<void>

get (key: KDefault): Promise<VDefault>
get<K = KDefault, V = VDefault> (key: K, options: GetOptions<K, V>): Promise<V>
get (key: KDefault): Promise<VDefault | undefined>
get<K = KDefault, V = VDefault> (key: K, options: GetOptions<K, V>): Promise<V | undefined>

getMany (keys: KDefault[]): Promise<VDefault[]>
getMany<K = KDefault, V = VDefault> (keys: K[], options: GetManyOptions<K, V>): Promise<V[]>
getMany (keys: KDefault[]): Promise<(VDefault | undefined)[]>
getMany<K = KDefault, V = VDefault> (keys: K[], options: GetManyOptions<K, V>): Promise<(V | undefined)[]>

has (key: KDefault): Promise<boolean>
has<K = KDefault> (key: K, options: HasOptions<K>): Promise<boolean>

hasMany (keys: KDefault[]): Promise<boolean[]>
hasMany<K = KDefault> (keys: K[], options: HasManyOptions<K>): Promise<boolean[]>

put (key: KDefault, value: VDefault): Promise<void>
put<K = KDefault, V = VDefault> (key: K, value: V, options: PutOptions<K, V>): Promise<void>
Expand All @@ -73,6 +82,8 @@ declare class ClassicLevel<KDefault = string, VDefault = string>
values (): ValueIterator<typeof this, KDefault, VDefault>
values<K = KDefault, V = VDefault> (options: ValueIteratorOptions<K, V>): ValueIterator<typeof this, K, V>

snapshot (options?: any | undefined): Snapshot

/**
* Get the approximate number of bytes of file system space used by the range
* `[start..end)`.
Expand Down Expand Up @@ -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 {
/**
Expand All @@ -229,6 +240,16 @@ export interface GetOptions<K, V> extends AbstractGetOptions<K, V>, ReadOptions
*/
export interface GetManyOptions<K, V> extends AbstractGetManyOptions<K, V>, ReadOptions {}

/**
* Options for the {@link ClassicLevel.has} method.
*/
export interface HasOptions<K> extends AbstractHasOptions<K>, ReadOptions {}

/**
* Options for the {@link ClassicLevel.hasMany} method.
*/
export interface HasManyOptions<K> extends AbstractHasManyOptions<K>, ReadOptions {}

/**
* Additional options for the {@link ClassicLevel.iterator}, {@link ClassicLevel.keys}
* and {@link ClassicLevel.values} methods.
Expand Down Expand Up @@ -315,3 +336,5 @@ export type ValueIterator<TDatabase, K, V> = AbstractValueIterator<TDatabase, K,
export type IteratorOptions<K, V> = AbstractIteratorOptions<K, V> & AdditionalIteratorOptions
export type KeyIteratorOptions<K> = AbstractKeyIteratorOptions<K> & AdditionalIteratorOptions
export type ValueIteratorOptions<K, V> = AbstractValueIteratorOptions<K, V> & AdditionalIteratorOptions

export type Snapshot = AbstractSnapshot

0 comments on commit 2cd5b94

Please sign in to comment.