@helia/utils 2.5.2-ae98a4f4 → 2.5.2-ed6c3b79
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 +22 -1
- package/dist/index.min.js.map +4 -4
- package/dist/src/abstract-session.d.ts +3 -3
- package/dist/src/abstract-session.d.ts.map +1 -1
- package/dist/src/abstract-session.js.map +1 -1
- package/dist/src/errors.d.ts +4 -0
- package/dist/src/errors.d.ts.map +1 -1
- package/dist/src/errors.js +4 -0
- package/dist/src/errors.js.map +1 -1
- package/dist/src/index.d.ts +41 -38
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +62 -30
- package/dist/src/index.js.map +1 -1
- package/dist/src/routing.d.ts +7 -5
- package/dist/src/routing.d.ts.map +1 -1
- package/dist/src/routing.js +10 -4
- package/dist/src/routing.js.map +1 -1
- package/dist/src/storage.d.ts +3 -4
- package/dist/src/storage.d.ts.map +1 -1
- package/dist/src/storage.js.map +1 -1
- package/dist/src/utils/constants.d.ts +4 -0
- package/dist/src/utils/constants.d.ts.map +1 -0
- package/dist/src/utils/constants.js +4 -0
- package/dist/src/utils/constants.js.map +1 -0
- package/dist/src/utils/get-codec.d.ts +2 -2
- package/dist/src/utils/get-codec.d.ts.map +1 -1
- package/dist/src/utils/get-codec.js +0 -1
- package/dist/src/utils/get-codec.js.map +1 -1
- package/dist/src/utils/get-crypto.d.ts +4 -0
- package/dist/src/utils/get-crypto.d.ts.map +1 -0
- package/dist/src/utils/get-crypto.js +35 -0
- package/dist/src/utils/get-crypto.js.map +1 -0
- package/dist/src/utils/get-hasher.d.ts +2 -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/is-cid.d.ts +3 -0
- package/dist/src/utils/is-cid.d.ts.map +1 -0
- package/dist/src/utils/is-cid.js +8 -0
- package/dist/src/utils/is-cid.js.map +1 -0
- package/dist/src/utils/networked-storage.d.ts +2 -1
- package/dist/src/utils/networked-storage.d.ts.map +1 -1
- package/dist/src/utils/networked-storage.js.map +1 -1
- package/dist/src/utils/session-storage.d.ts +5 -6
- 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 +29 -31
- package/src/abstract-session.ts +4 -4
- package/src/errors.ts +5 -0
- package/src/index.ts +110 -75
- package/src/routing.ts +23 -10
- package/src/storage.ts +3 -4
- package/src/utils/constants.ts +3 -0
- package/src/utils/get-codec.ts +2 -4
- package/src/utils/get-crypto.ts +44 -0
- package/src/utils/get-hasher.ts +2 -2
- package/src/utils/is-cid.ts +9 -0
- package/src/utils/networked-storage.ts +2 -1
- package/src/utils/session-storage.ts +5 -6
- package/src/utils/storage.ts +3 -4
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) {
|