Skip to content

Commit bbcfb04

Browse files
authored
Fix TypeScript types of get, getMany, nextv and all (#91)
Fixes: #86 Category: fix
1 parent c46178b commit bbcfb04

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

types/abstract-iterator.d.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ export class AbstractKeyIterator<TDatabase, K> extends CommonIterator<TDatabase,
153153
* @param size Get at most this many keys. Has a soft minimum of 1.
154154
* @param options Options (none at the moment, reserved for future use).
155155
*/
156-
nextv (size: number, options: {}): Promise<[K]>
157-
nextv (size: number): Promise<[K]>
156+
nextv (size: number, options: {}): Promise<K[]>
157+
nextv (size: number): Promise<K[]>
158158

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

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

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

216216
/**
217217
* Seek to the key closest to {@link target}. Subsequent calls to {@link next()},

types/abstract-level.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,22 @@ declare class AbstractLevel<TFormat, KDefault = string, VDefault = string>
7171
/**
7272
* Get a value from the database by {@link key}.
7373
*/
74-
get (key: KDefault): Promise<VDefault>
74+
get (key: KDefault): Promise<VDefault | undefined>
7575

7676
get<K = KDefault, V = VDefault> (
7777
key: K,
7878
options: AbstractGetOptions<K, V>
79-
): Promise<V>
79+
): Promise<V | undefined>
8080

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

8686
getMany<K = KDefault, V = VDefault> (
8787
keys: K[],
8888
options: AbstractGetManyOptions<K, V>
89-
): Promise<V[]>
89+
): Promise<(V | undefined)[]>
9090

9191
/**
9292
* Add a new entry or overwrite an existing entry.

0 commit comments

Comments
 (0)