Skip to content

Commit

Permalink
Fix TypeScript types of get, getMany, nextv and all (#91)
Browse files Browse the repository at this point in the history
Fixes: #86
Category: fix
  • Loading branch information
yoursunny authored Dec 9, 2024
1 parent c46178b commit bbcfb04
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
16 changes: 8 additions & 8 deletions types/abstract-iterator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ export class AbstractKeyIterator<TDatabase, K> extends CommonIterator<TDatabase,
* @param size Get at most this many keys. Has a soft minimum of 1.
* @param options Options (none at the moment, reserved for future use).
*/
nextv (size: number, options: {}): Promise<[K]>
nextv (size: number): Promise<[K]>
nextv (size: number, options: {}): Promise<K[]>
nextv (size: number): Promise<K[]>

/**
* Advance repeatedly and get all (remaining) keys as an array, automatically closing
Expand All @@ -165,8 +165,8 @@ export class AbstractKeyIterator<TDatabase, K> extends CommonIterator<TDatabase,
*
* @param options Options (none at the moment, reserved for future use).
*/
all (options: {}): Promise<[K]>
all (): Promise<[K]>
all (options: {}): Promise<K[]>
all (): Promise<K[]>

/**
* Seek to the key closest to {@link target}. Subsequent calls to {@link next()},
Expand Down Expand Up @@ -198,8 +198,8 @@ export class AbstractValueIterator<TDatabase, K, V> extends CommonIterator<TData
* @param size Get at most this many values. Has a soft minimum of 1.
* @param options Options (none at the moment, reserved for future use).
*/
nextv (size: number, options: {}): Promise<[V]>
nextv (size: number): Promise<[V]>
nextv (size: number, options: {}): Promise<V[]>
nextv (size: number): Promise<V[]>

/**
* Advance repeatedly and get all (remaining) values as an array, automatically closing
Expand All @@ -210,8 +210,8 @@ export class AbstractValueIterator<TDatabase, K, V> extends CommonIterator<TData
*
* @param options Options (none at the moment, reserved for future use).
*/
all (options: {}): Promise<[V]>
all (): Promise<[V]>
all (options: {}): Promise<V[]>
all (): Promise<V[]>

/**
* Seek to the key closest to {@link target}. Subsequent calls to {@link next()},
Expand Down
8 changes: 4 additions & 4 deletions types/abstract-level.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,22 @@ declare class AbstractLevel<TFormat, KDefault = string, VDefault = string>
/**
* Get a value from the database by {@link key}.
*/
get (key: KDefault): Promise<VDefault>
get (key: KDefault): Promise<VDefault | undefined>

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

/**
* Get multiple values from the database by an array of {@link keys}.
*/
getMany (keys: KDefault[]): Promise<VDefault[]>
getMany (keys: KDefault[]): Promise<(VDefault | undefined)[]>

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

/**
* Add a new entry or overwrite an existing entry.
Expand Down

0 comments on commit bbcfb04

Please sign in to comment.