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

Commit 6d0e474

Browse files
authored
chore: rename for consistency (#104)
1 parent db99380 commit 6d0e474

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async function writeFile (path, contents) {
6363
*
6464
* @implements {Datastore}
6565
*/
66-
export class DatastoreFs extends BaseDatastore {
66+
export class FsDatastore extends BaseDatastore {
6767
/**
6868
* @param {string} location
6969
* @param {{ createIfMissing?: boolean, errorIfExists?: boolean, extension?: string, putManyConcurrency?: number } | undefined} [opts]

test/index.spec.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@ import { Key } from 'interface-datastore'
99
import { ShardingDatastore, shard } from 'datastore-core'
1010
import { isNode, isElectronMain } from 'ipfs-utils/src/env.js'
1111
import { interfaceDatastoreTests } from 'interface-datastore-tests'
12-
import { DatastoreFs } from '../src/index.js'
12+
import { FsDatastore } from '../src/index.js'
1313
import tempdir from 'ipfs-utils/src/temp-dir.js'
1414

1515
const rimraf = promisify(rmrf)
1616
const utf8Encoder = new TextEncoder()
1717

18-
describe('DatastoreFs', () => {
18+
describe('FsDatastore', () => {
1919
if (!(isNode || isElectronMain)) {
2020
it('only supports node.js and electron main', () => {
2121

@@ -28,23 +28,23 @@ describe('DatastoreFs', () => {
2828
it('defaults - folder missing', () => {
2929
const dir = tempdir()
3030
expect(
31-
() => new DatastoreFs(dir)
31+
() => new FsDatastore(dir)
3232
).to.not.throw()
3333
})
3434

3535
it('defaults - folder exists', () => {
3636
const dir = tempdir()
3737
mkdirp.sync(dir)
3838
expect(
39-
() => new DatastoreFs(dir)
39+
() => new FsDatastore(dir)
4040
).to.not.throw()
4141
})
4242
})
4343

4444
describe('open', () => {
4545
it('createIfMissing: false - folder missing', () => {
4646
const dir = tempdir()
47-
const store = new DatastoreFs(dir, { createIfMissing: false })
47+
const store = new FsDatastore(dir, { createIfMissing: false })
4848
expect(
4949
() => store.open()
5050
).to.throw()
@@ -53,7 +53,7 @@ describe('DatastoreFs', () => {
5353
it('errorIfExists: true - folder exists', () => {
5454
const dir = tempdir()
5555
mkdirp.sync(dir)
56-
const store = new DatastoreFs(dir, { errorIfExists: true })
56+
const store = new FsDatastore(dir, { errorIfExists: true })
5757
expect(
5858
() => store.open()
5959
).to.throw()
@@ -62,7 +62,7 @@ describe('DatastoreFs', () => {
6262

6363
it('_encode and _decode', () => {
6464
const dir = tempdir()
65-
const fs = new DatastoreFs(dir)
65+
const fs = new FsDatastore(dir)
6666

6767
expect(
6868
// @ts-ignore
@@ -82,7 +82,7 @@ describe('DatastoreFs', () => {
8282

8383
it('deleting files', async () => {
8484
const dir = tempdir()
85-
const fs = new DatastoreFs(dir)
85+
const fs = new FsDatastore(dir)
8686
const key = new Key('1234')
8787

8888
await fs.put(key, Uint8Array.from([0, 1, 2, 3]))
@@ -98,7 +98,7 @@ describe('DatastoreFs', () => {
9898

9999
it('deleting non-existent files', async () => {
100100
const dir = tempdir()
101-
const fs = new DatastoreFs(dir)
101+
const fs = new FsDatastore(dir)
102102
const key = new Key('5678')
103103

104104
await fs.delete(key)
@@ -113,7 +113,7 @@ describe('DatastoreFs', () => {
113113

114114
it('sharding files', async () => {
115115
const dir = tempdir()
116-
const fstore = new DatastoreFs(dir)
116+
const fstore = new FsDatastore(dir)
117117
await ShardingDatastore.create(fstore, new shard.NextToLast(2))
118118

119119
const file = await fs.promises.readFile(path.join(dir, shard.SHARDING_FN))
@@ -125,7 +125,7 @@ describe('DatastoreFs', () => {
125125
})
126126

127127
it('query', async () => {
128-
const fs = new DatastoreFs(path.join(process.cwd(), '/test/test-repo/blocks'))
128+
const fs = new FsDatastore(path.join(process.cwd(), '/test/test-repo/blocks'))
129129
const res = []
130130
for await (const q of fs.query({})) {
131131
res.push(q)
@@ -135,7 +135,7 @@ describe('DatastoreFs', () => {
135135

136136
it('interop with go', async () => {
137137
const repodir = path.join(process.cwd(), '/test/test-repo/blocks')
138-
const fstore = new DatastoreFs(repodir)
138+
const fstore = new FsDatastore(repodir)
139139
const key = new Key('CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY')
140140
const expected = fs.readFileSync(path.join(repodir, 'VO', key.toString() + '.data'))
141141
const flatfs = await ShardingDatastore.open(fstore)
@@ -152,7 +152,7 @@ describe('DatastoreFs', () => {
152152

153153
interfaceDatastoreTests({
154154
setup: () => {
155-
return new DatastoreFs(dir)
155+
return new FsDatastore(dir)
156156
},
157157
teardown: () => {
158158
return rimraf(dir)
@@ -165,7 +165,7 @@ describe('DatastoreFs', () => {
165165

166166
interfaceDatastoreTests({
167167
setup: () => {
168-
return new ShardingDatastore(new DatastoreFs(dir), new shard.NextToLast(2))
168+
return new ShardingDatastore(new FsDatastore(dir), new shard.NextToLast(2))
169169
},
170170
teardown: () => {
171171
return rimraf(dir)
@@ -175,7 +175,7 @@ describe('DatastoreFs', () => {
175175

176176
it('can survive concurrent writes', async () => {
177177
const dir = tempdir()
178-
const fstore = new DatastoreFs(dir)
178+
const fstore = new FsDatastore(dir)
179179
const key = new Key('CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY')
180180
const value = utf8Encoder.encode('Hello world')
181181

@@ -190,7 +190,7 @@ describe('DatastoreFs', () => {
190190

191191
it('can survive putRaw and getRaw with an empty extension', async () => {
192192
const dir = tempdir()
193-
const fstore = new DatastoreFs(dir, {
193+
const fstore = new FsDatastore(dir, {
194194
extension: ''
195195
})
196196
const key = new Key('CIQGFTQ7FSI2COUXWWLOQ45VUM2GUZCGAXLWCTOKKPGTUWPXHBNIVOY')

0 commit comments

Comments
 (0)