1+ import type { AbortOptions } from 'abort-error'
12import type { Blockstore , InputPair , Pair } from 'interface-blockstore'
2- import type { AbortOptions , Await , AwaitGenerator , AwaitIterable } from 'interface-store'
33import type { CID } from 'multiformats/cid'
44
55export class BaseBlockstore implements Blockstore {
6- has ( key : CID , options ?: AbortOptions ) : Await < boolean > {
6+ has ( key : CID , options ?: AbortOptions ) : boolean | Promise < boolean > {
77 return Promise . reject ( new Error ( '.has is not implemented' ) )
88 }
99
10- put ( key : CID , val : Uint8Array | AwaitIterable < Uint8Array > , options ?: AbortOptions ) : Await < CID > {
10+ put ( key : CID , val : Uint8Array | Iterable < Uint8Array > | AsyncIterable < Uint8Array > , options ?: AbortOptions ) : CID | Promise < CID > {
1111 return Promise . reject ( new Error ( '.put is not implemented' ) )
1212 }
1313
14- async * putMany ( source : AwaitIterable < InputPair > , options ?: AbortOptions ) : AwaitGenerator < CID > {
14+ async * putMany ( source : Iterable < InputPair > | AsyncIterable < InputPair > , options ?: AbortOptions ) : Generator < CID > | AsyncGenerator < CID > {
1515 for await ( const { cid, bytes } of source ) {
1616 await this . put ( cid , bytes , options )
1717 yield cid
1818 }
1919 }
2020
21- get ( key : CID , options ?: AbortOptions ) : AwaitGenerator < Uint8Array > {
21+ get ( key : CID , options ?: AbortOptions ) : Generator < Uint8Array > | AsyncGenerator < Uint8Array > {
2222 throw new Error ( '.get is not implemented' )
2323 }
2424
25- async * getMany ( source : AwaitIterable < CID > , options ?: AbortOptions ) : AwaitGenerator < Pair > {
25+ async * getMany ( source : Iterable < CID > | AsyncIterable < CID > , options ?: AbortOptions ) : Generator < Pair > | AsyncGenerator < Pair > {
2626 for await ( const key of source ) {
2727 yield {
2828 cid : key ,
@@ -31,11 +31,11 @@ export class BaseBlockstore implements Blockstore {
3131 }
3232 }
3333
34- delete ( key : CID , options ?: AbortOptions ) : Await < void > {
34+ delete ( key : CID , options ?: AbortOptions ) : void | Promise < void > {
3535 return Promise . reject ( new Error ( '.delete is not implemented' ) )
3636 }
3737
38- async * deleteMany ( source : AwaitIterable < CID > , options ?: AbortOptions ) : AwaitGenerator < CID > {
38+ async * deleteMany ( source : Iterable < CID > | AsyncIterable < CID > , options ?: AbortOptions ) : Generator < CID > | AsyncGenerator < CID > {
3939 for await ( const key of source ) {
4040 await this . delete ( key , options )
4141 yield key
@@ -45,7 +45,7 @@ export class BaseBlockstore implements Blockstore {
4545 /**
4646 * Extending classes should override `query` or implement this method
4747 */
48- async * getAll ( options ?: AbortOptions ) : AwaitGenerator < Pair > { // eslint-disable-line require-yield
48+ async * getAll ( options ?: AbortOptions ) : Generator < Pair > | AsyncGenerator < Pair > { // eslint-disable-line require-yield
4949 throw new Error ( '.getAll is not implemented' )
5050 }
5151}
0 commit comments