ipfs-unixfs-importer
Advanced tools
Comparing version 15.1.4 to 15.1.5
@@ -0,5 +1,5 @@ | ||
import errcode from 'err-code'; | ||
// @ts-expect-error no types | ||
import { create } from 'rabin-wasm'; | ||
import { Uint8ArrayList } from 'uint8arraylist'; | ||
// @ts-expect-error | ||
import { create } from 'rabin-wasm'; | ||
import errcode from 'err-code'; | ||
const DEFAULT_MIN_CHUNK_SIZE = 262144; | ||
@@ -6,0 +6,0 @@ const DEFAULT_MAX_CHUNK_SIZE = 262144; |
@@ -0,6 +1,6 @@ | ||
import * as dagPb from '@ipld/dag-pb'; | ||
import { UnixFS } from 'ipfs-unixfs'; | ||
import { persist } from '../utils/persist.js'; | ||
import * as dagPb from '@ipld/dag-pb'; | ||
import * as raw from 'multiformats/codecs/raw'; | ||
import { CustomProgressEvent } from 'progress-events'; | ||
import { persist } from '../utils/persist.js'; | ||
export function defaultBufferImporter(options) { | ||
@@ -7,0 +7,0 @@ return async function* bufferImporter(file, blockstore) { |
@@ -0,4 +1,4 @@ | ||
import { encode, prepare } from '@ipld/dag-pb'; | ||
import { UnixFS } from 'ipfs-unixfs'; | ||
import { persist } from '../utils/persist.js'; | ||
import { encode, prepare } from '@ipld/dag-pb'; | ||
export const dirBuilder = async (dir, blockstore, options) => { | ||
@@ -5,0 +5,0 @@ const unixfs = new UnixFS({ |
@@ -0,7 +1,7 @@ | ||
import { encode, prepare } from '@ipld/dag-pb'; | ||
import { UnixFS } from 'ipfs-unixfs'; | ||
import { persist } from '../utils/persist.js'; | ||
import { encode, prepare } from '@ipld/dag-pb'; | ||
import parallelBatch from 'it-parallel-batch'; | ||
import * as rawCodec from 'multiformats/codecs/raw'; | ||
import { CustomProgressEvent } from 'progress-events'; | ||
import { persist } from '../utils/persist.js'; | ||
async function* buildFileBatch(file, blockstore, options) { | ||
@@ -138,4 +138,4 @@ let count = -1; | ||
export const fileBuilder = async (file, block, options) => { | ||
return await options.layout(buildFileBatch(file, block, options), reduce(file, block, options)); | ||
return options.layout(buildFileBatch(file, block, options), reduce(file, block, options)); | ||
}; | ||
//# sourceMappingURL=file.js.map |
@@ -1,6 +0,6 @@ | ||
import { DirBuilderOptions } from './dir.js'; | ||
import { FileBuilderOptions } from './file.js'; | ||
import type { ImportCandidate, ImporterProgressEvents, InProgressImportResult, WritableStorage } from '../index.js'; | ||
import { type DirBuilderOptions } from './dir.js'; | ||
import { type FileBuilderOptions } from './file.js'; | ||
import type { ChunkValidator } from './validate-chunks.js'; | ||
import type { Chunker } from '../chunker/index.js'; | ||
import type { ImportCandidate, ImporterProgressEvents, InProgressImportResult, WritableStorage } from '../index.js'; | ||
import type { ProgressEvent, ProgressOptions } from 'progress-events'; | ||
@@ -7,0 +7,0 @@ /** |
@@ -0,5 +1,5 @@ | ||
import errCode from 'err-code'; | ||
import { CustomProgressEvent } from 'progress-events'; | ||
import { dirBuilder } from './dir.js'; | ||
import { fileBuilder } from './file.js'; | ||
import errCode from 'err-code'; | ||
import { CustomProgressEvent } from 'progress-events'; | ||
function isIterable(thing) { | ||
@@ -63,3 +63,3 @@ return Symbol.iterator in thing; | ||
}; | ||
yield async () => await fileBuilder(file, blockstore, options); | ||
yield async () => fileBuilder(file, blockstore, options); | ||
} | ||
@@ -73,3 +73,3 @@ else if (entry.path != null) { | ||
}; | ||
yield async () => await dirBuilder(dir, blockstore, options); | ||
yield async () => dirBuilder(dir, blockstore, options); | ||
} | ||
@@ -76,0 +76,0 @@ else { |
@@ -0,5 +1,5 @@ | ||
import { Dir, type DirProps } from './dir.js'; | ||
import { type PersistOptions } from './utils/persist.js'; | ||
import type { ImportResult, InProgressImportResult } from './index.js'; | ||
import type { Blockstore } from 'interface-blockstore'; | ||
import { Dir, DirProps } from './dir.js'; | ||
import type { ImportResult, InProgressImportResult } from './index.js'; | ||
import { PersistOptions } from './utils/persist.js'; | ||
export declare class DirFlat extends Dir { | ||
@@ -6,0 +6,0 @@ private readonly _children; |
@@ -6,2 +6,3 @@ import { encode, prepare } from '@ipld/dag-pb'; | ||
export class DirFlat extends Dir { | ||
_children; | ||
constructor(props, options) { | ||
@@ -18,3 +19,3 @@ super(props, options); | ||
async get(name) { | ||
return await Promise.resolve(this._children.get(name)); | ||
return Promise.resolve(this._children.get(name)); | ||
} | ||
@@ -21,0 +22,0 @@ childCount() { |
@@ -1,4 +0,4 @@ | ||
import { Dir, DirProps } from './dir.js'; | ||
import { PersistOptions } from './utils/persist.js'; | ||
import { Bucket, BucketChild } from 'hamt-sharding'; | ||
import { Bucket, type BucketChild } from 'hamt-sharding'; | ||
import { Dir, type DirProps } from './dir.js'; | ||
import { type PersistOptions } from './utils/persist.js'; | ||
import type { ImportResult, InProgressImportResult } from './index.js'; | ||
@@ -5,0 +5,0 @@ import type { Blockstore } from 'interface-blockstore'; |
import { encode, prepare } from '@ipld/dag-pb'; | ||
import { murmur3128 } from '@multiformats/murmur3'; | ||
import { createHAMT, Bucket } from 'hamt-sharding'; | ||
import { UnixFS } from 'ipfs-unixfs'; | ||
import { Dir, CID_V0, CID_V1 } from './dir.js'; | ||
import { persist } from './utils/persist.js'; | ||
import { createHAMT, Bucket } from 'hamt-sharding'; | ||
import { murmur3128 } from '@multiformats/murmur3'; | ||
async function hamtHashFn(buf) { | ||
@@ -18,2 +18,3 @@ return (await murmur3128.encode(buf)) | ||
class DirSharded extends Dir { | ||
_bucket; | ||
constructor(props, options) { | ||
@@ -33,3 +34,3 @@ super(props, options); | ||
async get(name) { | ||
return await this._bucket.get(name); | ||
return this._bucket.get(name); | ||
} | ||
@@ -36,0 +37,0 @@ childCount() { |
@@ -0,5 +1,5 @@ | ||
import { CID } from 'multiformats/cid'; | ||
import type { WritableStorage, ImportResult, InProgressImportResult } from './index.js'; | ||
import type { PersistOptions } from './utils/persist.js'; | ||
import type { Mtime, UnixFS } from 'ipfs-unixfs'; | ||
import { CID } from 'multiformats/cid'; | ||
import type { PersistOptions } from './utils/persist.js'; | ||
export interface DirProps { | ||
@@ -6,0 +6,0 @@ root: boolean; |
import { CID } from 'multiformats/cid'; | ||
export class Dir { | ||
options; | ||
root; | ||
dir; | ||
path; | ||
dirty; | ||
flat; | ||
parent; | ||
parentKey; | ||
unixfs; | ||
mode; | ||
mtime; | ||
cid; | ||
size; | ||
nodeSize; | ||
constructor(props, options) { | ||
@@ -4,0 +18,0 @@ this.options = options ?? {}; |
@@ -0,3 +1,3 @@ | ||
import { DirFlat } from './dir-flat.js'; | ||
import DirSharded from './dir-sharded.js'; | ||
import { DirFlat } from './dir-flat.js'; | ||
export async function flatToShard(child, dir, threshold, options) { | ||
@@ -19,5 +19,4 @@ let newDir = dir; | ||
} | ||
return await flatToShard(newDir, parent, threshold, options); | ||
return flatToShard(newDir, parent, threshold, options); | ||
} | ||
// @ts-expect-error | ||
return newDir; | ||
@@ -24,0 +23,0 @@ } |
@@ -1,12 +0,12 @@ | ||
import { DAGBuilder, DagBuilderProgressEvents } from './dag-builder/index.js'; | ||
import { type BufferImportProgressEvents } from './dag-builder/buffer-importer.js'; | ||
import { type DAGBuilder, type DagBuilderProgressEvents } from './dag-builder/index.js'; | ||
import { type ChunkValidator } from './dag-builder/validate-chunks.js'; | ||
import { type FileLayout } from './layout/index.js'; | ||
import type { Chunker } from './chunker/index.js'; | ||
import type { ReducerProgressEvents } from './dag-builder/file.js'; | ||
import type { Blockstore } from 'interface-blockstore'; | ||
import type { AwaitIterable } from 'interface-store'; | ||
import type { UnixFS, Mtime } from 'ipfs-unixfs'; | ||
import type { CID, Version as CIDVersion } from 'multiformats/cid'; | ||
import type { Blockstore } from 'interface-blockstore'; | ||
import { ChunkValidator } from './dag-builder/validate-chunks.js'; | ||
import type { Chunker } from './chunker/index.js'; | ||
import { FileLayout } from './layout/index.js'; | ||
import { BufferImportProgressEvents } from './dag-builder/buffer-importer.js'; | ||
import type { AwaitIterable } from 'interface-store'; | ||
import type { ProgressOptions } from 'progress-events'; | ||
import type { ReducerProgressEvents } from './dag-builder/file.js'; | ||
export type ByteStream = AwaitIterable<Uint8Array>; | ||
@@ -13,0 +13,0 @@ export type ImportContent = ByteStream | Uint8Array; |
@@ -0,10 +1,10 @@ | ||
import errcode from 'err-code'; | ||
import first from 'it-first'; | ||
import parallelBatch from 'it-parallel-batch'; | ||
import { fixedSize } from './chunker/fixed-size.js'; | ||
import { defaultBufferImporter } from './dag-builder/buffer-importer.js'; | ||
import { defaultDagBuilder } from './dag-builder/index.js'; | ||
import { defaultTreeBuilder } from './tree-builder.js'; | ||
import { defaultChunkValidator } from './dag-builder/validate-chunks.js'; | ||
import { fixedSize } from './chunker/fixed-size.js'; | ||
import { balanced } from './layout/index.js'; | ||
import { defaultBufferImporter } from './dag-builder/buffer-importer.js'; | ||
import first from 'it-first'; | ||
import errcode from 'err-code'; | ||
import { defaultTreeBuilder } from './tree-builder.js'; | ||
/** | ||
@@ -162,3 +162,3 @@ * The importer creates UnixFS DAGs and stores the blocks that make | ||
export async function importBytes(buf, blockstore, options = {}) { | ||
return await importFile({ | ||
return importFile({ | ||
content: buf | ||
@@ -189,3 +189,3 @@ }, blockstore, options); | ||
export async function importByteStream(bufs, blockstore, options = {}) { | ||
return await importFile({ | ||
return importFile({ | ||
content: bufs | ||
@@ -192,0 +192,0 @@ }, blockstore, options); |
@@ -11,3 +11,3 @@ import batch from 'it-batch'; | ||
if (roots.length > 1) { | ||
return await balancedLayout(roots, reduce); | ||
return balancedLayout(roots, reduce); | ||
} | ||
@@ -14,0 +14,0 @@ return roots[0]; |
import all from 'it-all'; | ||
export function flat() { | ||
return async function flatLayout(source, reduce) { | ||
return await reduce(await all(source)); | ||
return reduce(await all(source)); | ||
}; | ||
} | ||
//# sourceMappingURL=flat.js.map |
@@ -31,6 +31,13 @@ import batch from 'it-batch'; | ||
} | ||
return await root.reduce(reduce); | ||
return root.reduce(reduce); | ||
}; | ||
} | ||
class SubTree { | ||
root; | ||
node; | ||
parent; | ||
maxDepth; | ||
layerRepeat; | ||
currentDepth; | ||
iteration; | ||
constructor(maxDepth, layerRepeat, iteration = 0) { | ||
@@ -75,3 +82,3 @@ this.maxDepth = maxDepth; | ||
}; | ||
// @ts-expect-error | ||
// @ts-expect-error nextNode is different type | ||
parent.children.push(nextNode); | ||
@@ -85,3 +92,3 @@ this.currentDepth = nextNode.depth; | ||
async reduce(reduce) { | ||
return await this._reduce(this.root, reduce); | ||
return this._reduce(this.root, reduce); | ||
} | ||
@@ -92,8 +99,8 @@ async _reduce(node, reduce) { | ||
children = await Promise.all(node.children | ||
// @ts-expect-error | ||
// @ts-expect-error data is not present on type | ||
.filter(child => child.data) | ||
// @ts-expect-error | ||
.map(async (child) => await this._reduce(child, reduce))); | ||
// @ts-expect-error child is wrong type | ||
.map(async (child) => this._reduce(child, reduce))); | ||
} | ||
return await reduce((node.data ?? []).concat(children)); | ||
return reduce((node.data ?? []).concat(children)); | ||
} | ||
@@ -122,5 +129,5 @@ _findParent(node, depth) { | ||
async reduce(reduce) { | ||
return await reduce((this.root.data ?? []).concat(this.root.children)); | ||
return reduce((this.root.data ?? []).concat(this.root.children)); | ||
} | ||
} | ||
//# sourceMappingURL=trickle.js.map |
import { DirFlat } from './dir-flat.js'; | ||
import { Dir } from './dir.js'; | ||
import { flatToShard } from './flat-to-shard.js'; | ||
import { Dir } from './dir.js'; | ||
import { toPathComponents } from './utils/to-path-components.js'; | ||
@@ -5,0 +5,0 @@ async function addToTree(elem, tree, options) { |
import { CID } from 'multiformats/cid'; | ||
import type { WritableStorage } from '../index.js'; | ||
import type { Version as CIDVersion } from 'multiformats/cid'; | ||
import type { BlockCodec } from 'multiformats/codecs/interface'; | ||
import type { Version as CIDVersion } from 'multiformats/cid'; | ||
import type { ProgressOptions } from 'progress-events'; | ||
@@ -6,0 +6,0 @@ export interface PersistOptions extends ProgressOptions { |
@@ -0,3 +1,3 @@ | ||
import * as dagPb from '@ipld/dag-pb'; | ||
import { CID } from 'multiformats/cid'; | ||
import * as dagPb from '@ipld/dag-pb'; | ||
import { sha256 } from 'multiformats/hashes/sha2'; | ||
@@ -4,0 +4,0 @@ export const persist = async (buffer, blockstore, options) => { |
{ | ||
"name": "ipfs-unixfs-importer", | ||
"version": "15.1.4", | ||
"version": "15.1.5", | ||
"description": "JavaScript implementation of the UnixFs importer used by IPFS", | ||
@@ -180,6 +180,4 @@ "license": "Apache-2.0 OR MIT", | ||
"devDependencies": { | ||
"aegir": "^38.1.2", | ||
"aegir": "^39.0.6", | ||
"blockstore-core": "^4.0.1", | ||
"it-buffer-stream": "^3.0.0", | ||
"it-drain": "^3.0.2", | ||
"it-last": "^3.0.2", | ||
@@ -186,0 +184,0 @@ "wherearewe": "^2.0.1" |
@@ -0,5 +1,5 @@ | ||
import errcode from 'err-code' | ||
// @ts-expect-error no types | ||
import { create } from 'rabin-wasm' | ||
import { Uint8ArrayList } from 'uint8arraylist' | ||
// @ts-expect-error | ||
import { create } from 'rabin-wasm' | ||
import errcode from 'err-code' | ||
import type { Chunker } from './index.js' | ||
@@ -6,0 +6,0 @@ |
@@ -0,8 +1,8 @@ | ||
import * as dagPb from '@ipld/dag-pb' | ||
import { UnixFS } from 'ipfs-unixfs' | ||
import { persist, PersistOptions } from '../utils/persist.js' | ||
import * as dagPb from '@ipld/dag-pb' | ||
import * as raw from 'multiformats/codecs/raw' | ||
import { CustomProgressEvent } from 'progress-events' | ||
import { persist, type PersistOptions } from '../utils/persist.js' | ||
import type { BufferImporter } from '../index.js' | ||
import type { CID, Version } from 'multiformats/cid' | ||
import { CustomProgressEvent } from 'progress-events' | ||
import type { ProgressOptions, ProgressEvent } from 'progress-events' | ||
@@ -9,0 +9,0 @@ |
@@ -0,4 +1,4 @@ | ||
import { encode, prepare } from '@ipld/dag-pb' | ||
import { UnixFS } from 'ipfs-unixfs' | ||
import { persist } from '../utils/persist.js' | ||
import { encode, prepare } from '@ipld/dag-pb' | ||
import type { Directory, InProgressImportResult, WritableStorage } from '../index.js' | ||
@@ -5,0 +5,0 @@ import type { Version } from 'multiformats/cid' |
@@ -0,10 +1,10 @@ | ||
import { encode, type PBLink, type PBNode, prepare } from '@ipld/dag-pb' | ||
import { UnixFS } from 'ipfs-unixfs' | ||
import { persist } from '../utils/persist.js' | ||
import { encode, PBLink, PBNode, prepare } from '@ipld/dag-pb' | ||
import parallelBatch from 'it-parallel-batch' | ||
import * as rawCodec from 'multiformats/codecs/raw' | ||
import { CustomProgressEvent } from 'progress-events' | ||
import { persist } from '../utils/persist.js' | ||
import type { BufferImporter, File, InProgressImportResult, WritableStorage, SingleBlockImportResult, ImporterProgressEvents } from '../index.js' | ||
import type { FileLayout, Reducer } from '../layout/index.js' | ||
import type { CID, Version } from 'multiformats/cid' | ||
import { CustomProgressEvent } from 'progress-events' | ||
import type { ProgressOptions, ProgressEvent } from 'progress-events' | ||
@@ -196,3 +196,3 @@ | ||
export const fileBuilder = async (file: File, block: WritableStorage, options: FileBuilderOptions): Promise<InProgressImportResult> => { | ||
return await options.layout(buildFileBatch(file, block, options), reduce(file, block, options)) | ||
return options.layout(buildFileBatch(file, block, options), reduce(file, block, options)) | ||
} |
@@ -1,9 +0,9 @@ | ||
import { dirBuilder, DirBuilderOptions } from './dir.js' | ||
import { fileBuilder, FileBuilderOptions } from './file.js' | ||
import errCode from 'err-code' | ||
import type { Directory, File, FileCandidate, ImportCandidate, ImporterProgressEvents, InProgressImportResult, WritableStorage } from '../index.js' | ||
import { CustomProgressEvent } from 'progress-events' | ||
import { dirBuilder, type DirBuilderOptions } from './dir.js' | ||
import { fileBuilder, type FileBuilderOptions } from './file.js' | ||
import type { ChunkValidator } from './validate-chunks.js' | ||
import type { Chunker } from '../chunker/index.js' | ||
import type { Directory, File, FileCandidate, ImportCandidate, ImporterProgressEvents, InProgressImportResult, WritableStorage } from '../index.js' | ||
import type { ProgressEvent, ProgressOptions } from 'progress-events' | ||
import { CustomProgressEvent } from 'progress-events' | ||
@@ -110,3 +110,3 @@ /** | ||
yield async () => await fileBuilder(file, blockstore, options) | ||
yield async () => fileBuilder(file, blockstore, options) | ||
} else if (entry.path != null) { | ||
@@ -120,3 +120,3 @@ const dir: Directory = { | ||
yield async () => await dirBuilder(dir, blockstore, options) | ||
yield async () => dirBuilder(dir, blockstore, options) | ||
} else { | ||
@@ -123,0 +123,0 @@ throw new Error('Import candidate must have content or path or both') |
@@ -1,8 +0,8 @@ | ||
import { encode, PBNode, prepare } from '@ipld/dag-pb' | ||
import { encode, type PBNode, prepare } from '@ipld/dag-pb' | ||
import { UnixFS } from 'ipfs-unixfs' | ||
import { Dir, CID_V0, CID_V1, type DirProps } from './dir.js' | ||
import { persist, type PersistOptions } from './utils/persist.js' | ||
import type { ImportResult, InProgressImportResult } from './index.js' | ||
import type { Blockstore } from 'interface-blockstore' | ||
import { UnixFS } from 'ipfs-unixfs' | ||
import type { CID } from 'multiformats/cid' | ||
import { Dir, CID_V0, CID_V1, DirProps } from './dir.js' | ||
import type { ImportResult, InProgressImportResult } from './index.js' | ||
import { persist, PersistOptions } from './utils/persist.js' | ||
@@ -27,3 +27,3 @@ export class DirFlat extends Dir { | ||
async get (name: string): Promise<InProgressImportResult | Dir | undefined> { | ||
return await Promise.resolve(this._children.get(name)) | ||
return Promise.resolve(this._children.get(name)) | ||
} | ||
@@ -30,0 +30,0 @@ |
@@ -1,7 +0,7 @@ | ||
import { encode, PBLink, prepare } from '@ipld/dag-pb' | ||
import { encode, type PBLink, prepare } from '@ipld/dag-pb' | ||
import { murmur3128 } from '@multiformats/murmur3' | ||
import { createHAMT, Bucket, type BucketChild } from 'hamt-sharding' | ||
import { UnixFS } from 'ipfs-unixfs' | ||
import { Dir, CID_V0, CID_V1, DirProps } from './dir.js' | ||
import { persist, PersistOptions } from './utils/persist.js' | ||
import { createHAMT, Bucket, BucketChild } from 'hamt-sharding' | ||
import { murmur3128 } from '@multiformats/murmur3' | ||
import { Dir, CID_V0, CID_V1, type DirProps } from './dir.js' | ||
import { persist, type PersistOptions } from './utils/persist.js' | ||
import type { ImportResult, InProgressImportResult } from './index.js' | ||
@@ -43,3 +43,3 @@ import type { Blockstore } from 'interface-blockstore' | ||
async get (name: string): Promise<InProgressImportResult | Dir | undefined> { | ||
return await this._bucket.get(name) | ||
return this._bucket.get(name) | ||
} | ||
@@ -46,0 +46,0 @@ |
@@ -0,5 +1,5 @@ | ||
import { CID } from 'multiformats/cid' | ||
import type { WritableStorage, ImportResult, InProgressImportResult } from './index.js' | ||
import type { PersistOptions } from './utils/persist.js' | ||
import type { Mtime, UnixFS } from 'ipfs-unixfs' | ||
import { CID } from 'multiformats/cid' | ||
import type { PersistOptions } from './utils/persist.js' | ||
@@ -6,0 +6,0 @@ export interface DirProps { |
@@ -0,3 +1,3 @@ | ||
import { DirFlat } from './dir-flat.js' | ||
import DirSharded from './dir-sharded.js' | ||
import { DirFlat } from './dir-flat.js' | ||
import type { Dir } from './dir.js' | ||
@@ -7,3 +7,3 @@ import type { PersistOptions } from './utils/persist.js' | ||
export async function flatToShard (child: Dir | null, dir: Dir, threshold: number, options: PersistOptions): Promise<DirSharded> { | ||
let newDir = dir | ||
let newDir = dir as DirSharded | ||
@@ -29,6 +29,5 @@ if (dir instanceof DirFlat && dir.estimateNodeSize() > threshold) { | ||
return await flatToShard(newDir, parent, threshold, options) | ||
return flatToShard(newDir, parent, threshold, options) | ||
} | ||
// @ts-expect-error | ||
return newDir | ||
@@ -35,0 +34,0 @@ } |
@@ -0,17 +1,17 @@ | ||
import errcode from 'err-code' | ||
import first from 'it-first' | ||
import parallelBatch from 'it-parallel-batch' | ||
import { DAGBuilder, DagBuilderProgressEvents, defaultDagBuilder } from './dag-builder/index.js' | ||
import { fixedSize } from './chunker/fixed-size.js' | ||
import { type BufferImportProgressEvents, defaultBufferImporter } from './dag-builder/buffer-importer.js' | ||
import { type DAGBuilder, type DagBuilderProgressEvents, defaultDagBuilder } from './dag-builder/index.js' | ||
import { type ChunkValidator, defaultChunkValidator } from './dag-builder/validate-chunks.js' | ||
import { balanced, type FileLayout } from './layout/index.js' | ||
import { defaultTreeBuilder } from './tree-builder.js' | ||
import type { Chunker } from './chunker/index.js' | ||
import type { ReducerProgressEvents } from './dag-builder/file.js' | ||
import type { Blockstore } from 'interface-blockstore' | ||
import type { AwaitIterable } from 'interface-store' | ||
import type { UnixFS, Mtime } from 'ipfs-unixfs' | ||
import type { CID, Version as CIDVersion } from 'multiformats/cid' | ||
import type { Blockstore } from 'interface-blockstore' | ||
import { ChunkValidator, defaultChunkValidator } from './dag-builder/validate-chunks.js' | ||
import { fixedSize } from './chunker/fixed-size.js' | ||
import type { Chunker } from './chunker/index.js' | ||
import { balanced, FileLayout } from './layout/index.js' | ||
import { BufferImportProgressEvents, defaultBufferImporter } from './dag-builder/buffer-importer.js' | ||
import first from 'it-first' | ||
import errcode from 'err-code' | ||
import type { AwaitIterable } from 'interface-store' | ||
import type { ProgressOptions } from 'progress-events' | ||
import type { ReducerProgressEvents } from './dag-builder/file.js' | ||
@@ -368,3 +368,3 @@ export type ByteStream = AwaitIterable<Uint8Array> | ||
export async function importBytes (buf: ImportContent, blockstore: WritableStorage, options: ImporterOptions = {}): Promise<ImportResult> { | ||
return await importFile({ | ||
return importFile({ | ||
content: buf | ||
@@ -396,5 +396,5 @@ }, blockstore, options) | ||
export async function importByteStream (bufs: ByteStream, blockstore: WritableStorage, options: ImporterOptions = {}): Promise<ImportResult> { | ||
return await importFile({ | ||
return importFile({ | ||
content: bufs | ||
}, blockstore, options) | ||
} |
import batch from 'it-batch' | ||
import type { FileLayout } from './index.js' | ||
import type { InProgressImportResult } from '../index.js' | ||
import type { FileLayout } from './index.js' | ||
@@ -22,3 +22,3 @@ const DEFAULT_MAX_CHILDREN_PER_NODE = 174 | ||
if (roots.length > 1) { | ||
return await balancedLayout(roots, reduce) | ||
return balancedLayout(roots, reduce) | ||
} | ||
@@ -25,0 +25,0 @@ |
@@ -7,4 +7,4 @@ import all from 'it-all' | ||
return async function flatLayout (source, reduce): Promise<InProgressImportResult> { | ||
return await reduce(await all(source)) | ||
return reduce(await all(source)) | ||
} | ||
} |
@@ -1,6 +0,6 @@ | ||
import type { UnixFS } from 'ipfs-unixfs' | ||
import batch from 'it-batch' | ||
import type { CID } from 'multiformats/cid' | ||
import type { InProgressImportResult } from '../index.js' | ||
import type { FileLayout, Reducer } from '../layout/index.js' | ||
import type { UnixFS } from 'ipfs-unixfs' | ||
import type { CID } from 'multiformats/cid' | ||
@@ -62,3 +62,3 @@ const DEFAULT_LAYER_REPEAT = 4 | ||
return await root.reduce(reduce) | ||
return root.reduce(reduce) | ||
} | ||
@@ -126,3 +126,3 @@ } | ||
// @ts-expect-error | ||
// @ts-expect-error nextNode is different type | ||
parent.children.push(nextNode) | ||
@@ -139,3 +139,3 @@ | ||
async reduce (reduce: Reducer): Promise<InProgressImportResult> { | ||
return await this._reduce(this.root, reduce) | ||
return this._reduce(this.root, reduce) | ||
} | ||
@@ -149,10 +149,10 @@ | ||
node.children | ||
// @ts-expect-error | ||
// @ts-expect-error data is not present on type | ||
.filter(child => child.data) | ||
// @ts-expect-error | ||
.map(async child => await this._reduce(child, reduce)) | ||
// @ts-expect-error child is wrong type | ||
.map(async child => this._reduce(child, reduce)) | ||
) | ||
} | ||
return await reduce((node.data ?? []).concat(children)) | ||
return reduce((node.data ?? []).concat(children)) | ||
} | ||
@@ -189,4 +189,4 @@ | ||
async reduce (reduce: Reducer): Promise<InProgressImportResult> { | ||
return await reduce((this.root.data ?? []).concat(this.root.children)) | ||
return reduce((this.root.data ?? []).concat(this.root.children)) | ||
} | ||
} |
import { DirFlat } from './dir-flat.js' | ||
import { Dir } from './dir.js' | ||
import { flatToShard } from './flat-to-shard.js' | ||
import { Dir } from './dir.js' | ||
import { toPathComponents } from './utils/to-path-components.js' | ||
@@ -5,0 +5,0 @@ import type { ImportResult, InProgressImportResult, TreeBuilder, WritableStorage } from './index.js' |
@@ -0,7 +1,7 @@ | ||
import * as dagPb from '@ipld/dag-pb' | ||
import { CID } from 'multiformats/cid' | ||
import * as dagPb from '@ipld/dag-pb' | ||
import { sha256 } from 'multiformats/hashes/sha2' | ||
import type { WritableStorage } from '../index.js' | ||
import type { Version as CIDVersion } from 'multiformats/cid' | ||
import type { BlockCodec } from 'multiformats/codecs/interface' | ||
import type { Version as CIDVersion } from 'multiformats/cid' | ||
import type { ProgressOptions } from 'progress-events' | ||
@@ -8,0 +8,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
270478
4
3701