@@ -3,7 +3,7 @@ import { DAGBuilder, defaultDagBuilder } from './dag-builder/index.js'
3
3
import { defaultTreeBuilder } from './tree-builder.js'
4
4
import type { UnixFS , Mtime } from 'ipfs-unixfs'
5
5
import type { CID , Version as CIDVersion } from 'multiformats/cid'
6
- import type { Blockstore as InterfaceBlockstore } from 'interface-blockstore'
6
+ import type { Blockstore } from 'interface-blockstore'
7
7
import { ChunkValidator , defaultChunkValidator } from './dag-builder/validate-chunks.js'
8
8
import { fixedSize } from './chunker/fixed-size.js'
9
9
import type { Chunker } from './chunker/index.js'
@@ -17,7 +17,7 @@ import type { ProgressOptions } from 'progress-events'
17
17
export type ByteStream = AwaitIterable < Uint8Array >
18
18
export type ImportContent = ByteStream | Uint8Array
19
19
20
- export type Blockstore = Pick < InterfaceBlockstore , 'put' >
20
+ export type WritableStorage = Pick < Blockstore , 'put' >
21
21
22
22
export interface FileCandidate {
23
23
path ?: string
@@ -73,8 +73,8 @@ export interface BufferImporterResult extends ImportResult {
73
73
}
74
74
75
75
export interface HamtHashFn { ( value : Uint8Array ) : Promise < Uint8Array > }
76
- export interface TreeBuilder { ( source : AsyncIterable < InProgressImportResult > , blockstore : Blockstore ) : AsyncIterable < ImportResult > }
77
- export interface BufferImporter { ( file : File , blockstore : Blockstore ) : AsyncIterable < ( ) => Promise < BufferImporterResult > > }
76
+ export interface TreeBuilder { ( source : AsyncIterable < InProgressImportResult > , blockstore : WritableStorage ) : AsyncIterable < ImportResult > }
77
+ export interface BufferImporter { ( file : File , blockstore : WritableStorage ) : AsyncIterable < ( ) => Promise < BufferImporterResult > > }
78
78
79
79
export type ImportProgressEvents =
80
80
BufferImportProgressEvents
@@ -227,7 +227,7 @@ export type ImportCandidateStream = AsyncIterable<FileCandidate | DirectoryCandi
227
227
* }
228
228
* ```
229
229
*/
230
- export async function * importer ( source : ImportCandidateStream , blockstore : Blockstore , options : ImporterOptions = { } ) : AsyncGenerator < ImportResult , void , unknown > {
230
+ export async function * importer ( source : ImportCandidateStream , blockstore : WritableStorage , options : ImporterOptions = { } ) : AsyncGenerator < ImportResult , void , unknown > {
231
231
let candidates : AsyncIterable < FileCandidate | DirectoryCandidate > | Iterable < FileCandidate | DirectoryCandidate >
232
232
233
233
if ( Symbol . asyncIterator in source || Symbol . iterator in source ) {
@@ -302,7 +302,7 @@ export async function * importer (source: ImportCandidateStream, blockstore: Blo
302
302
* const entry = await importFile(input, blockstore)
303
303
* ```
304
304
*/
305
- export async function importFile ( content : FileCandidate , blockstore : Blockstore , options : ImporterOptions = { } ) : Promise < ImportResult > {
305
+ export async function importFile ( content : FileCandidate , blockstore : WritableStorage , options : ImporterOptions = { } ) : Promise < ImportResult > {
306
306
const result = await first ( importer ( [ content ] , blockstore , options ) )
307
307
308
308
if ( result == null ) {
@@ -333,7 +333,7 @@ export async function importFile (content: FileCandidate, blockstore: Blockstore
333
333
* const entry = await importDirectory(input, blockstore)
334
334
* ```
335
335
*/
336
- export async function importDirectory ( content : DirectoryCandidate , blockstore : Blockstore , options : ImporterOptions = { } ) : Promise < ImportResult > {
336
+ export async function importDirectory ( content : DirectoryCandidate , blockstore : WritableStorage , options : ImporterOptions = { } ) : Promise < ImportResult > {
337
337
const result = await first ( importer ( [ content ] , blockstore , options ) )
338
338
339
339
if ( result == null ) {
@@ -361,7 +361,7 @@ export async function importDirectory (content: DirectoryCandidate, blockstore:
361
361
* const entry = await importBytes(input, blockstore)
362
362
* ```
363
363
*/
364
- export async function importBytes ( buf : ImportContent , blockstore : Blockstore , options : ImporterOptions = { } ) : Promise < ImportResult > {
364
+ export async function importBytes ( buf : ImportContent , blockstore : WritableStorage , options : ImporterOptions = { } ) : Promise < ImportResult > {
365
365
return await importFile ( {
366
366
content : buf
367
367
} , blockstore , options )
@@ -388,7 +388,7 @@ export async function importBytes (buf: ImportContent, blockstore: Blockstore, o
388
388
* const entry = await importByteStream(input, blockstore)
389
389
* ```
390
390
*/
391
- export async function importByteStream ( bufs : ByteStream , blockstore : Blockstore , options : ImporterOptions = { } ) : Promise < ImportResult > {
391
+ export async function importByteStream ( bufs : ByteStream , blockstore : WritableStorage , options : ImporterOptions = { } ) : Promise < ImportResult > {
392
392
return await importFile ( {
393
393
content : bufs
394
394
} , blockstore , options )
0 commit comments