File tree 6 files changed +96
-7
lines changed
6 files changed +96
-7
lines changed Original file line number Diff line number Diff line change 15
15
- [ Usage] ( #usage )
16
16
- [ BaseBlockstore] ( #baseblockstore )
17
17
- [ MemoryBlockstore] ( #memoryblockstore )
18
+ - [ BlackHoleBlockstore] ( #blackholeblockstore )
18
19
- [ API Docs] ( #api-docs )
19
20
- [ License] ( #license )
20
21
- [ Contribute] ( #contribute )
@@ -35,8 +36,9 @@ Loading this module through a script tag will make it's exports available as `Bl
35
36
36
37
## Implementations
37
38
38
- - Base: [ ` src/base ` ] ( src/base.js )
39
- - Memory: [ ` src/memory ` ] ( src/memory.js )
39
+ - Base: [ ` src/base ` ] ( src/base.ts )
40
+ - Memory: [ ` src/memory ` ] ( src/memory.ts )
41
+ - BlackHole: [ 'src/blackhole] ( src/blackhole.ts )
40
42
41
43
## Usage
42
44
@@ -70,6 +72,16 @@ import { MemoryBlockstore } from 'blockstore-core/memory'
70
72
const store = new MemoryBlockstore ()
71
73
```
72
74
75
+ ### BlackHoleBlockstore
76
+
77
+ A Blockstore that does not store any blocks.
78
+
79
+ ``` js
80
+ import { BlackHoleBlockstore } from ' blockstore-core/black-hole'
81
+
82
+ const store = new BlackHoleBlockstore ()
83
+ ```
84
+
73
85
## API Docs
74
86
75
87
- < https://ipfs.github.io/js-stores/modules/blockstore_core.html >
Original file line number Diff line number Diff line change 55
55
"types" : " ./dist/src/base.d.ts" ,
56
56
"import" : " ./dist/src/base.js"
57
57
},
58
+ "./black-hole" : {
59
+ "types" : " ./dist/src/black-hole.d.ts" ,
60
+ "import" : " ./dist/src/black-hole.js"
61
+ },
58
62
"./errors" : {
59
63
"types" : " ./dist/src/errors.d.ts" ,
60
64
"import" : " ./dist/src/errors.js"
Original file line number Diff line number Diff line change
1
+ import { BaseBlockstore } from './base.js'
2
+ import * as Errors from './errors.js'
3
+ import type { Pair } from 'interface-blockstore'
4
+ import type { Await , AwaitIterable } from 'interface-store'
5
+ import type { CID } from 'multiformats/cid'
6
+
7
+ export class BlackHoleBlockstore extends BaseBlockstore {
8
+ put ( key : CID ) : Await < CID > {
9
+ return key
10
+ }
11
+
12
+ get ( ) : Await < Uint8Array > {
13
+ throw Errors . notFoundError ( )
14
+ }
15
+
16
+ has ( ) : Await < boolean > {
17
+ return false
18
+ }
19
+
20
+ async delete ( ) : Promise < void > {
21
+
22
+ }
23
+
24
+ async * getAll ( ) : AwaitIterable < Pair > {
25
+
26
+ }
27
+ }
Original file line number Diff line number Diff line change @@ -37,11 +37,12 @@ Loading this module through a script tag will make it's exports available as `Da
37
37
## Implementations
38
38
39
39
- Wrapper Implementations
40
- - Mount: [ ` src/mount ` ] ( src/mount.js )
41
- - Keytransform: [ ` src/keytransform ` ] ( src/keytransform.js )
42
- - Sharding: [ ` src/sharding ` ] ( src/sharding.js )
43
- - Tiered: [ ` src/tiered ` ] ( src/tirered.js )
44
- - Namespace: [ ` src/namespace ` ] ( src/namespace.js )
40
+ - Mount: [ ` src/mount ` ] ( src/mount.ts )
41
+ - Keytransform: [ ` src/keytransform ` ] ( src/keytransform.ts )
42
+ - Sharding: [ ` src/sharding ` ] ( src/sharding.ts )
43
+ - Tiered: [ ` src/tiered ` ] ( src/tirered.ts )
44
+ - Namespace: [ ` src/namespace ` ] ( src/namespace.ts )
45
+ - BlackHole: [ ` src/black-hole ` ] ( src/black-hole.ts )
45
46
46
47
## Usage
47
48
@@ -83,6 +84,16 @@ import {
83
84
const store = new MountStore ({prefix: new Key (' /a' ), datastore: new MemoryStore ()})
84
85
```
85
86
87
+ ### BlackHoleDatastore
88
+
89
+ A datastore that does not store any data.
90
+
91
+ ``` js
92
+ import { BlackHoleDatastore } from ' datastore-core/black-hole'
93
+
94
+ const store = new BlackHoleDatastore ()
95
+ ```
96
+
86
97
## Contribute
87
98
88
99
Feel free to join in. All welcome. Open an [ issue] ( https://github.com/ipfs/js-ipfs-unixfs-importer/issues ) !
Original file line number Diff line number Diff line change 55
55
"types" : " ./dist/src/base.d.ts" ,
56
56
"import" : " ./dist/src/base.js"
57
57
},
58
+ "./black-hole" : {
59
+ "types" : " ./dist/src/black-hole.d.ts" ,
60
+ "import" : " ./dist/src/black-hole.js"
61
+ },
58
62
"./errors" : {
59
63
"types" : " ./dist/src/errors.d.ts" ,
60
64
"import" : " ./dist/src/errors.js"
Original file line number Diff line number Diff line change
1
+ import { BaseDatastore } from './base.js'
2
+ import * as Errors from './errors.js'
3
+ import type { Pair } from 'interface-datastore'
4
+ import type { Key } from 'interface-datastore/key'
5
+ import type { Await , AwaitIterable } from 'interface-store'
6
+
7
+ export class BlackHoleDatastore extends BaseDatastore {
8
+ put ( key : Key ) : Await < Key > {
9
+ return key
10
+ }
11
+
12
+ get ( ) : Await < Uint8Array > {
13
+ throw Errors . notFoundError ( )
14
+ }
15
+
16
+ has ( key : Key ) : Await < boolean > {
17
+ return false
18
+ }
19
+
20
+ delete ( key : Key ) : Await < void > {
21
+
22
+ }
23
+
24
+ * _all ( ) : AwaitIterable < Pair > {
25
+
26
+ }
27
+
28
+ * _allKeys ( ) : AwaitIterable < Key > {
29
+
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments