Skip to content
This repository was archived by the owner on Mar 23, 2023. It is now read-only.

Commit 32e0e52

Browse files
authored
deps: update interface-store to 5.x.x (#74)
1 parent f3dde0a commit 32e0e52

File tree

3 files changed

+27
-22
lines changed

3 files changed

+27
-22
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,12 @@
172172
},
173173
"dependencies": {
174174
"err-code": "^3.0.1",
175-
"interface-blockstore": "^5.0.0",
176-
"interface-store": "^4.0.0",
175+
"interface-blockstore": "^5.1.1",
176+
"interface-store": "^5.0.1",
177177
"multiformats": "^11.0.0"
178178
},
179179
"devDependencies": {
180180
"aegir": "^38.1.7",
181-
"interface-blockstore-tests": "^5.0.0"
181+
"interface-blockstore-tests": "^6.0.0"
182182
}
183183
}

src/base.ts

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,41 @@
1-
import type { Blockstore, Options, Pair } from 'interface-blockstore'
1+
import type { Blockstore, Pair } from 'interface-blockstore'
2+
import type { AbortOptions, Await, AwaitIterable } from 'interface-store'
23
import type { CID } from 'multiformats/cid'
3-
import type { AwaitIterable } from 'interface-store'
44

55
export class BaseBlockstore implements Blockstore {
6-
async has (key: CID, options?: Options): Promise<boolean> {
7-
return await Promise.reject(new Error('.has is not implemented'))
6+
has (key: CID, options?: AbortOptions): Await<boolean> {
7+
return Promise.reject(new Error('.has is not implemented'))
88
}
99

10-
async put (key: CID, val: Uint8Array, options?: Options): Promise<void> {
11-
await Promise.reject(new Error('.put is not implemented'))
10+
put (key: CID, val: Uint8Array, options?: AbortOptions): Await<CID> {
11+
return Promise.reject(new Error('.put is not implemented'))
1212
}
1313

14-
async * putMany (source: AwaitIterable<Pair>, options?: Options): AsyncIterable<Pair> {
14+
async * putMany (source: AwaitIterable<Pair>, options?: AbortOptions): AwaitIterable<CID> {
1515
for await (const { cid, block } of source) {
1616
await this.put(cid, block, options)
17-
yield { cid, block }
17+
yield cid
1818
}
1919
}
2020

21-
async get (key: CID, options?: Options): Promise<Uint8Array> {
22-
return await Promise.reject(new Error('.get is not implemented'))
21+
get (key: CID, options?: AbortOptions): Await<Uint8Array> {
22+
return Promise.reject(new Error('.get is not implemented'))
2323
}
2424

25-
async * getMany (source: AwaitIterable<CID>, options?: Options): AsyncIterable<Uint8Array> {
25+
async * getMany (source: AwaitIterable<CID>, options?: AbortOptions): AwaitIterable<Pair> {
2626
for await (const key of source) {
27-
yield this.get(key, options)
27+
yield {
28+
cid: key,
29+
block: await this.get(key, options)
30+
}
2831
}
2932
}
3033

31-
async delete (key: CID, options?: Options): Promise<void> {
34+
async delete (key: CID, options?: AbortOptions): Promise<void> {
3235
await Promise.reject(new Error('.delete is not implemented'))
3336
}
3437

35-
async * deleteMany (source: AwaitIterable<CID>, options?: Options): AsyncIterable<CID> {
38+
async * deleteMany (source: AwaitIterable<CID>, options?: AbortOptions): AwaitIterable<CID> {
3639
for await (const key of source) {
3740
await this.delete(key, options)
3841
yield key
@@ -42,7 +45,7 @@ export class BaseBlockstore implements Blockstore {
4245
/**
4346
* Extending classes should override `query` or implement this method
4447
*/
45-
async * getAll (options?: Options): AwaitIterable<Pair> { // eslint-disable-line require-yield
48+
async * getAll (options?: AbortOptions): AwaitIterable<Pair> { // eslint-disable-line require-yield
4649
throw new Error('.getAll is not implemented')
4750
}
4851
}

src/memory.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import * as raw from 'multiformats/codecs/raw'
44
import { CID } from 'multiformats/cid'
55
import * as Digest from 'multiformats/hashes/digest'
66
import * as Errors from './errors.js'
7-
import type { AwaitIterable } from 'interface-store'
7+
import type { Await, AwaitIterable } from 'interface-store'
88
import type { Pair } from 'interface-blockstore'
99

1010
export class MemoryBlockstore extends BaseBlockstore {
@@ -16,11 +16,13 @@ export class MemoryBlockstore extends BaseBlockstore {
1616
this.data = new Map()
1717
}
1818

19-
async put (key: CID, val: Uint8Array): Promise<void> { // eslint-disable-line require-await
19+
put (key: CID, val: Uint8Array): Await<CID> { // eslint-disable-line require-await
2020
this.data.set(base32.encode(key.multihash.bytes), val)
21+
22+
return key
2123
}
2224

23-
async get (key: CID): Promise<Uint8Array> {
25+
get (key: CID): Await<Uint8Array> {
2426
const buf = this.data.get(base32.encode(key.multihash.bytes))
2527

2628
if (buf == null) {
@@ -30,7 +32,7 @@ export class MemoryBlockstore extends BaseBlockstore {
3032
return buf
3133
}
3234

33-
async has (key: CID): Promise<boolean> {
35+
has (key: CID): Await<boolean> {
3436
return this.data.has(base32.encode(key.multihash.bytes))
3537
}
3638

0 commit comments

Comments
 (0)