Skip to content

Commit dfc4697

Browse files
authored
fix: return key from put and put many (#196)
Otherwise if operating remotely we have the strange property of sending the data to be put once to the receiver and then again back to the sender.
1 parent 9db13e0 commit dfc4697

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

packages/interface-blockstore-tests/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ export function interfaceBlockstoreTests <B extends Blockstore = Blockstore> (te
8787

8888
let index = 0
8989

90-
for await (const { cid, block } of store.putMany(data)) {
91-
expect(data[index]).to.deep.equal({ cid, block })
90+
for await (const cid of store.putMany(data)) {
91+
expect(data[index].cid).to.deep.equal(cid)
9292
index++
9393
}
9494

packages/interface-datastore-tests/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ export function interfaceDatastoreTests <D extends Datastore = Datastore> (test:
6666

6767
let index = 0
6868

69-
for await (const { key, value } of store.putMany(data)) {
70-
expect(data[index]).to.deep.equal({ key, value })
69+
for await (const key of store.putMany(data)) {
70+
expect(data[index].key).to.deep.equal(key)
7171
index++
7272
}
7373

packages/interface-store/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export interface Store<Key, Value, Pair, HasOptionsExtension = {},
4545
* await store.put([{ key: new Key('awesome'), value: new Uint8Array([0, 1, 2, 3]) }])
4646
* ```
4747
*/
48-
put: (key: Key, val: Value, options?: AbortOptions & PutOptionsExtension) => Await<void>
48+
put: (key: Key, val: Value, options?: AbortOptions & PutOptionsExtension) => Await<Key>
4949

5050
/**
5151
* Store the given key/value pairs
@@ -62,7 +62,7 @@ export interface Store<Key, Value, Pair, HasOptionsExtension = {},
6262
putMany: (
6363
source: AwaitIterable<Pair>,
6464
options?: AbortOptions & PutManyOptionsExtension
65-
) => AwaitIterable<Pair>
65+
) => AwaitIterable<Key>
6666

6767
/**
6868
* Retrieve the value stored under the given key

0 commit comments

Comments
 (0)