Skip to content

Commit

Permalink
fix: return key from put and put many (#196)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
achingbrain authored Mar 23, 2023
1 parent 9db13e0 commit dfc4697
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/interface-blockstore-tests/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ export function interfaceBlockstoreTests <B extends Blockstore = Blockstore> (te

let index = 0

for await (const { cid, block } of store.putMany(data)) {
expect(data[index]).to.deep.equal({ cid, block })
for await (const cid of store.putMany(data)) {
expect(data[index].cid).to.deep.equal(cid)
index++
}

Expand Down
4 changes: 2 additions & 2 deletions packages/interface-datastore-tests/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export function interfaceDatastoreTests <D extends Datastore = Datastore> (test:

let index = 0

for await (const { key, value } of store.putMany(data)) {
expect(data[index]).to.deep.equal({ key, value })
for await (const key of store.putMany(data)) {
expect(data[index].key).to.deep.equal(key)
index++
}

Expand Down
4 changes: 2 additions & 2 deletions packages/interface-store/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export interface Store<Key, Value, Pair, HasOptionsExtension = {},
* await store.put([{ key: new Key('awesome'), value: new Uint8Array([0, 1, 2, 3]) }])
* ```
*/
put: (key: Key, val: Value, options?: AbortOptions & PutOptionsExtension) => Await<void>
put: (key: Key, val: Value, options?: AbortOptions & PutOptionsExtension) => Await<Key>

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

/**
* Retrieve the value stored under the given key
Expand Down

0 comments on commit dfc4697

Please sign in to comment.