@helia/utils 2.5.1 → 2.5.2-6f8165b5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +4 -4
- package/dist/src/index.d.ts +3 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/storage.d.ts +6 -5
- package/dist/src/storage.d.ts.map +1 -1
- package/dist/src/storage.js +7 -1
- package/dist/src/storage.js.map +1 -1
- package/dist/src/utils/get-codec.d.ts +1 -2
- package/dist/src/utils/get-codec.d.ts.map +1 -1
- package/dist/src/utils/get-codec.js.map +1 -1
- package/dist/src/utils/get-hasher.d.ts +1 -2
- package/dist/src/utils/get-hasher.d.ts.map +1 -1
- package/dist/src/utils/get-hasher.js.map +1 -1
- package/dist/src/utils/session-storage.d.ts +3 -4
- package/dist/src/utils/session-storage.d.ts.map +1 -1
- package/dist/src/utils/session-storage.js.map +1 -1
- package/dist/src/utils/storage.d.ts +3 -4
- package/dist/src/utils/storage.d.ts.map +1 -1
- package/dist/src/utils/storage.js.map +1 -1
- package/package.json +13 -14
- package/src/index.ts +4 -4
- package/src/storage.ts +13 -5
- package/src/utils/get-codec.ts +1 -2
- package/src/utils/get-hasher.ts +1 -2
- package/src/utils/session-storage.ts +3 -4
- package/src/utils/storage.ts +3 -4
- package/dist/typedoc-urls.json +0 -19
package/src/utils/get-hasher.ts
CHANGED
|
@@ -2,10 +2,9 @@ import { UnknownHashAlgorithmError } from '@helia/interface'
|
|
|
2
2
|
import { identity } from 'multiformats/hashes/identity'
|
|
3
3
|
import { sha256, sha512 } from 'multiformats/hashes/sha2'
|
|
4
4
|
import { isPromise } from './is-promise.ts'
|
|
5
|
-
import type { Await } from '@helia/interface'
|
|
6
5
|
import type { MultihashHasher } from 'multiformats/hashes/interface'
|
|
7
6
|
|
|
8
|
-
export function getHasher (initialHashers: MultihashHasher[] = [], loadHasher?: (code: number) =>
|
|
7
|
+
export function getHasher (initialHashers: MultihashHasher[] = [], loadHasher?: (code: number) => MultihashHasher | Promise<MultihashHasher>): (code: number) => MultihashHasher | Promise<MultihashHasher> {
|
|
9
8
|
const hashers: Record<number, MultihashHasher> = {
|
|
10
9
|
[sha256.code]: sha256,
|
|
11
10
|
[sha512.code]: sha512,
|
|
@@ -6,7 +6,6 @@ import type { Pair, DeleteManyBlocksProgressEvents, DeleteBlockProgressEvents, G
|
|
|
6
6
|
import type { AbortOptions, PeerId } from '@libp2p/interface'
|
|
7
7
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
8
8
|
import type { InputPair } from 'interface-blockstore'
|
|
9
|
-
import type { AwaitIterable } from 'interface-store'
|
|
10
9
|
import type { CID } from 'multiformats/cid'
|
|
11
10
|
import type { ProgressOptions } from 'progress-events'
|
|
12
11
|
|
|
@@ -63,7 +62,7 @@ export class SessionStorage extends Storage<SessionBlockBroker> implements Sessi
|
|
|
63
62
|
/**
|
|
64
63
|
* Put a multiple blocks to the underlying datastore
|
|
65
64
|
*/
|
|
66
|
-
async * putMany (blocks:
|
|
65
|
+
async * putMany (blocks: Iterable<InputPair> | AsyncIterable<InputPair>, options: AbortOptions & ProgressOptions<PutManyBlocksProgressEvents> = {}): AsyncGenerator<CID> {
|
|
67
66
|
const signal = anySignal([this.closeController.signal, options.signal])
|
|
68
67
|
setMaxListeners(Infinity, signal)
|
|
69
68
|
|
|
@@ -97,7 +96,7 @@ export class SessionStorage extends Storage<SessionBlockBroker> implements Sessi
|
|
|
97
96
|
/**
|
|
98
97
|
* Get multiple blocks back from an (async) iterable of cids
|
|
99
98
|
*/
|
|
100
|
-
async * getMany (cids:
|
|
99
|
+
async * getMany (cids: Iterable<CID> | AsyncIterable<CID>, options: GetOfflineOptions & AbortOptions & ProgressOptions<GetManyBlocksProgressEvents> = {}): AsyncGenerator<Pair> {
|
|
101
100
|
const signal = anySignal([this.closeController.signal, options.signal])
|
|
102
101
|
setMaxListeners(Infinity, signal)
|
|
103
102
|
|
|
@@ -131,7 +130,7 @@ export class SessionStorage extends Storage<SessionBlockBroker> implements Sessi
|
|
|
131
130
|
/**
|
|
132
131
|
* Delete multiple blocks from the blockstore
|
|
133
132
|
*/
|
|
134
|
-
async * deleteMany (cids:
|
|
133
|
+
async * deleteMany (cids: Iterable<CID> | AsyncIterable<CID>, options: AbortOptions & ProgressOptions<DeleteManyBlocksProgressEvents> = {}): AsyncGenerator<CID> {
|
|
135
134
|
const signal = anySignal([this.closeController.signal, options.signal])
|
|
136
135
|
setMaxListeners(Infinity, signal)
|
|
137
136
|
|
package/src/utils/storage.ts
CHANGED
|
@@ -11,7 +11,6 @@ import type { HasherLoader } from '@helia/interface'
|
|
|
11
11
|
import type { BlockBroker, Pair, DeleteManyBlocksProgressEvents, DeleteBlockProgressEvents, GetBlockProgressEvents, GetManyBlocksProgressEvents, PutManyBlocksProgressEvents, PutBlockProgressEvents, GetAllBlocksProgressEvents, GetOfflineOptions, BlockRetrievalOptions } from '@helia/interface/blocks'
|
|
12
12
|
import type { AbortOptions, ComponentLogger, Logger, LoggerOptions } from '@libp2p/interface'
|
|
13
13
|
import type { Blockstore, InputPair } from 'interface-blockstore'
|
|
14
|
-
import type { AwaitIterable } from 'interface-store'
|
|
15
14
|
import type { CID } from 'multiformats/cid'
|
|
16
15
|
import type { MultihashDigest, MultihashHasher } from 'multiformats/hashes/interface'
|
|
17
16
|
import type { ProgressEvent, ProgressOptions } from 'progress-events'
|
|
@@ -72,7 +71,7 @@ export class Storage <Broker extends BlockBroker<ProgressEvent<any, any>, Progre
|
|
|
72
71
|
/**
|
|
73
72
|
* Put a multiple blocks to the underlying datastore
|
|
74
73
|
*/
|
|
75
|
-
async * putMany (blocks:
|
|
74
|
+
async * putMany (blocks: Iterable<InputPair> | AsyncIterable<InputPair>, options: AbortOptions & ProgressOptions<PutManyBlocksProgressEvents> = {}): AsyncGenerator<CID> {
|
|
76
75
|
const missingBlocks = filter(blocks, async ({ cid }): Promise<boolean> => {
|
|
77
76
|
const has = await this.child.has(cid, options)
|
|
78
77
|
|
|
@@ -137,7 +136,7 @@ export class Storage <Broker extends BlockBroker<ProgressEvent<any, any>, Progre
|
|
|
137
136
|
/**
|
|
138
137
|
* Get multiple blocks back from an (async) iterable of cids
|
|
139
138
|
*/
|
|
140
|
-
async * getMany (cids:
|
|
139
|
+
async * getMany (cids: Iterable<CID> | AsyncIterable<CID>, options: GetOfflineOptions & AbortOptions & ProgressOptions<GetManyBlocksProgressEvents> = {}): AsyncGenerator<Pair> {
|
|
141
140
|
options.onProgress?.(new CustomProgressEvent('blocks:get-many:blockstore:get-many'))
|
|
142
141
|
|
|
143
142
|
yield * this.child.getMany(forEach(cids, async (cid): Promise<void> => {
|
|
@@ -182,7 +181,7 @@ export class Storage <Broker extends BlockBroker<ProgressEvent<any, any>, Progre
|
|
|
182
181
|
/**
|
|
183
182
|
* Delete multiple blocks from the blockstore
|
|
184
183
|
*/
|
|
185
|
-
async * deleteMany (cids:
|
|
184
|
+
async * deleteMany (cids: Iterable<CID> | AsyncIterable<CID>, options: AbortOptions & ProgressOptions<DeleteManyBlocksProgressEvents> = {}): AsyncGenerator<CID> {
|
|
186
185
|
options.onProgress?.(new CustomProgressEvent('blocks:delete-many:blockstore:delete-many'))
|
|
187
186
|
yield * this.child.deleteMany((async function * (): AsyncGenerator<CID> {
|
|
188
187
|
for await (const cid of cids) {
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"GraphWalker": "https://ipfs.github.io/helia/interfaces/_helia_car.GraphWalker.html",
|
|
3
|
-
"breadthFirstWalker": "https://ipfs.github.io/helia/functions/_helia_car.breadthFirstWalker.html",
|
|
4
|
-
"depthFirstWalker": "https://ipfs.github.io/helia/functions/_helia_car.depthFirstWalker.html",
|
|
5
|
-
"naturalOrderWalker": "https://ipfs.github.io/helia/functions/_helia_car.naturalOrderWalker.html",
|
|
6
|
-
"AbstractSession": "https://ipfs.github.io/helia/classes/_helia_utils.AbstractSession.html",
|
|
7
|
-
"Helia": "https://ipfs.github.io/helia/classes/_helia_utils.Helia.html",
|
|
8
|
-
".:Helia": "https://ipfs.github.io/helia/classes/_helia_utils.Helia.html",
|
|
9
|
-
"AbstractCreateSessionOptions": "https://ipfs.github.io/helia/interfaces/_helia_utils.AbstractCreateSessionOptions.html",
|
|
10
|
-
"AbstractSessionComponents": "https://ipfs.github.io/helia/interfaces/_helia_utils.AbstractSessionComponents.html",
|
|
11
|
-
"BlockStorage": "https://ipfs.github.io/helia/interfaces/_helia_utils.BlockStorage.html",
|
|
12
|
-
"BlockStorageInit": "https://ipfs.github.io/helia/interfaces/_helia_utils.BlockStorageInit.html",
|
|
13
|
-
"BlockstoreSessionEvents": "https://ipfs.github.io/helia/interfaces/_helia_utils.BlockstoreSessionEvents.html",
|
|
14
|
-
"GraphNode": "https://ipfs.github.io/helia/interfaces/_helia_utils.GraphNode.html",
|
|
15
|
-
"GraphWalkerComponents": "https://ipfs.github.io/helia/interfaces/_helia_utils.GraphWalkerComponents.html",
|
|
16
|
-
"GraphWalkerInit": "https://ipfs.github.io/helia/interfaces/_helia_utils.GraphWalkerInit.html",
|
|
17
|
-
"HeliaInit": "https://ipfs.github.io/helia/interfaces/_helia_utils.HeliaInit.html",
|
|
18
|
-
".:HeliaInit": "https://ipfs.github.io/helia/interfaces/helia.HeliaInit.html"
|
|
19
|
-
}
|