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

deps: update interface-store to 5.x.x #183

Merged
merged 1 commit into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@
"docs": "aegir docs"
},
"dependencies": {
"datastore-core": "^9.0.1",
"datastore-core": "^9.0.4",
"fast-write-atomic": "^0.2.0",
"interface-datastore": "^8.0.0",
"interface-store": "^4.0.0",
"interface-datastore": "^8.1.2",
"interface-store": "^5.0.1",
"it-glob": "^2.0.1",
"it-map": "^2.0.1",
"it-parallel-batch": "^2.0.1"
Expand All @@ -152,7 +152,7 @@
"@types/mkdirp": "^2.0.0",
"@types/rimraf": "^4.0.5",
"aegir": "^38.1.7",
"interface-datastore-tests": "^4.0.0",
"interface-datastore-tests": "^5.0.0",
"ipfs-utils": "^9.0.4"
}
}
15 changes: 10 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,26 +136,28 @@ export class FsDatastore extends BaseDatastore {
/**
* Store the given value under the key
*/
async put (key: Key, val: Uint8Array): Promise<void> {
async put (key: Key, val: Uint8Array): Promise<Key> {
const parts = this._encode(key)

try {
await fs.mkdir(parts.dir, {
recursive: true
})
await writeFile(parts.file, val)

return key
} catch (err: any) {
throw Errors.dbWriteFailedError(err)
}
}

async * putMany (source: AwaitIterable<Pair>): AsyncIterable<Pair> {
async * putMany (source: AwaitIterable<Pair>): AsyncIterable<Key> {
yield * parallel(
map(source, ({ key, value }) => {
return async () => {
await this.put(key, value)

return { key, value }
return key
}
}),
this.putManyConcurrency
Expand All @@ -176,11 +178,14 @@ export class FsDatastore extends BaseDatastore {
return data
}

async * getMany (source: AwaitIterable<Key>): AsyncIterable<Uint8Array> {
async * getMany (source: AwaitIterable<Key>): AsyncIterable<Pair> {
yield * parallel(
map(source, key => {
return async () => {
return await this.get(key)
return {
key,
value: await this.get(key)
}
}
}),
this.getManyConcurrency
Expand Down