ipfs-unixfs-exporter
Advanced tools
Comparing version
import { CID } from 'multiformats/cid'; | ||
import type { UnixFS } from 'ipfs-unixfs'; | ||
import type { PBNode } from '@ipld/dag-pb'; | ||
import type { Blockstore as InterfaceBlockstore } from 'interface-blockstore'; | ||
import type { Blockstore } from 'interface-blockstore'; | ||
import type { Bucket } from 'hamt-sharding'; | ||
@@ -55,6 +55,6 @@ import type { ProgressOptions } from 'progress-events'; | ||
export interface Resolve { | ||
(cid: CID, name: string, path: string, toResolve: string[], depth: number, blockstore: Blockstore, options: ExporterOptions): Promise<ResolveResult>; | ||
(cid: CID, name: string, path: string, toResolve: string[], depth: number, blockstore: ReadableStorage, options: ExporterOptions): Promise<ResolveResult>; | ||
} | ||
export interface Resolver { | ||
(cid: CID, name: string, path: string, toResolve: string[], resolve: Resolve, depth: number, blockstore: Blockstore, options: ExporterOptions): Promise<ResolveResult>; | ||
(cid: CID, name: string, path: string, toResolve: string[], resolve: Resolve, depth: number, blockstore: ReadableStorage, options: ExporterOptions): Promise<ResolveResult>; | ||
} | ||
@@ -65,3 +65,3 @@ export type UnixfsV1FileContent = AsyncIterable<Uint8Array> | Iterable<Uint8Array>; | ||
export interface UnixfsV1Resolver { | ||
(cid: CID, node: PBNode, unixfs: UnixFS, path: string, resolve: Resolve, depth: number, blockstore: Blockstore): (options: ExporterOptions) => UnixfsV1Content; | ||
(cid: CID, node: PBNode, unixfs: UnixFS, path: string, resolve: Resolve, depth: number, blockstore: ReadableStorage): (options: ExporterOptions) => UnixfsV1Content; | ||
} | ||
@@ -73,6 +73,6 @@ export interface ShardTraversalContext { | ||
} | ||
export type Blockstore = Pick<InterfaceBlockstore, 'get'>; | ||
export declare function walkPath(path: string | CID, blockstore: Blockstore, options?: ExporterOptions): AsyncGenerator<UnixFSEntry, void, any>; | ||
export declare function exporter(path: string | CID, blockstore: Blockstore, options?: ExporterOptions): Promise<UnixFSEntry>; | ||
export declare function recursive(path: string | CID, blockstore: Blockstore, options?: ExporterOptions): AsyncGenerator<UnixFSEntry, void, any>; | ||
export type ReadableStorage = Pick<Blockstore, 'get'>; | ||
export declare function walkPath(path: string | CID, blockstore: ReadableStorage, options?: ExporterOptions): AsyncGenerator<UnixFSEntry, void, any>; | ||
export declare function exporter(path: string | CID, blockstore: ReadableStorage, options?: ExporterOptions): Promise<UnixFSEntry>; | ||
export declare function recursive(path: string | CID, blockstore: ReadableStorage, options?: ExporterOptions): AsyncGenerator<UnixFSEntry, void, any>; | ||
//# sourceMappingURL=index.d.ts.map |
import { PBNode } from '@ipld/dag-pb'; | ||
import type { ExporterOptions, ShardTraversalContext, Blockstore } from '../index.js'; | ||
import type { ExporterOptions, ShardTraversalContext, ReadableStorage } from '../index.js'; | ||
import type { CID } from 'multiformats/cid'; | ||
declare const findShardCid: (node: PBNode, name: string, blockstore: Blockstore, context?: ShardTraversalContext, options?: ExporterOptions) => Promise<CID | undefined>; | ||
declare const findShardCid: (node: PBNode, name: string, blockstore: ReadableStorage, context?: ShardTraversalContext, options?: ExporterOptions) => Promise<CID | undefined>; | ||
export default findShardCid; | ||
//# sourceMappingURL=find-cid-in-shard.d.ts.map |
@@ -15,3 +15,3 @@ { | ||
"UnixfsV1Resolver": "https://ipfs.github.io/js-ipfs-unixfs/interfaces/ipfs_unixfs_exporter.UnixfsV1Resolver.html", | ||
"Blockstore": "https://ipfs.github.io/js-ipfs-unixfs/types/ipfs_unixfs_exporter.Blockstore.html", | ||
"ReadableStorage": "https://ipfs.github.io/js-ipfs-unixfs/types/ipfs_unixfs_exporter.ReadableStorage.html", | ||
"UnixFSEntry": "https://ipfs.github.io/js-ipfs-unixfs/types/ipfs_unixfs_exporter.UnixFSEntry.html", | ||
@@ -18,0 +18,0 @@ "UnixfsV1Content": "https://ipfs.github.io/js-ipfs-unixfs/types/ipfs_unixfs_exporter.UnixfsV1Content.html", |
{ | ||
"name": "ipfs-unixfs-exporter", | ||
"version": "13.0.5", | ||
"version": "13.0.6", | ||
"description": "JavaScript implementation of the UnixFs exporter used by IPFS", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0 OR MIT", |
@@ -7,3 +7,3 @@ import errCode from 'err-code' | ||
import type { PBNode } from '@ipld/dag-pb' | ||
import type { Blockstore as InterfaceBlockstore } from 'interface-blockstore' | ||
import type { Blockstore } from 'interface-blockstore' | ||
import type { Bucket } from 'hamt-sharding' | ||
@@ -69,4 +69,4 @@ import type { ProgressOptions } from 'progress-events' | ||
export interface Resolve { (cid: CID, name: string, path: string, toResolve: string[], depth: number, blockstore: Blockstore, options: ExporterOptions): Promise<ResolveResult> } | ||
export interface Resolver { (cid: CID, name: string, path: string, toResolve: string[], resolve: Resolve, depth: number, blockstore: Blockstore, options: ExporterOptions): Promise<ResolveResult> } | ||
export interface Resolve { (cid: CID, name: string, path: string, toResolve: string[], depth: number, blockstore: ReadableStorage, options: ExporterOptions): Promise<ResolveResult> } | ||
export interface Resolver { (cid: CID, name: string, path: string, toResolve: string[], resolve: Resolve, depth: number, blockstore: ReadableStorage, options: ExporterOptions): Promise<ResolveResult> } | ||
@@ -76,3 +76,3 @@ export type UnixfsV1FileContent = AsyncIterable<Uint8Array> | Iterable<Uint8Array> | ||
export type UnixfsV1Content = UnixfsV1FileContent | UnixfsV1DirectoryContent | ||
export interface UnixfsV1Resolver { (cid: CID, node: PBNode, unixfs: UnixFS, path: string, resolve: Resolve, depth: number, blockstore: Blockstore): (options: ExporterOptions) => UnixfsV1Content } | ||
export interface UnixfsV1Resolver { (cid: CID, node: PBNode, unixfs: UnixFS, path: string, resolve: Resolve, depth: number, blockstore: ReadableStorage): (options: ExporterOptions) => UnixfsV1Content } | ||
@@ -85,3 +85,3 @@ export interface ShardTraversalContext { | ||
export type Blockstore = Pick<InterfaceBlockstore, 'get'> | ||
export type ReadableStorage = Pick<Blockstore, 'get'> | ||
@@ -128,3 +128,3 @@ const toPathComponents = (path: string = ''): string[] => { | ||
export async function * walkPath (path: string | CID, blockstore: Blockstore, options: ExporterOptions = {}): AsyncGenerator<UnixFSEntry, void, any> { | ||
export async function * walkPath (path: string | CID, blockstore: ReadableStorage, options: ExporterOptions = {}): AsyncGenerator<UnixFSEntry, void, any> { | ||
let { | ||
@@ -161,3 +161,3 @@ cid, | ||
export async function exporter (path: string | CID, blockstore: Blockstore, options: ExporterOptions = {}): Promise<UnixFSEntry> { | ||
export async function exporter (path: string | CID, blockstore: ReadableStorage, options: ExporterOptions = {}): Promise<UnixFSEntry> { | ||
const result = await last(walkPath(path, blockstore, options)) | ||
@@ -172,3 +172,3 @@ | ||
export async function * recursive (path: string | CID, blockstore: Blockstore, options: ExporterOptions = {}): AsyncGenerator<UnixFSEntry, void, any> { | ||
export async function * recursive (path: string | CID, blockstore: ReadableStorage, options: ExporterOptions = {}): AsyncGenerator<UnixFSEntry, void, any> { | ||
const node = await exporter(path, blockstore, options) | ||
@@ -175,0 +175,0 @@ |
@@ -12,5 +12,5 @@ import extractDataFromBlock from '../../../utils/extract-data-from-block.js' | ||
import PQueue from 'p-queue' | ||
import type { ExporterOptions, UnixfsV1FileContent, UnixfsV1Resolver, Blockstore } from '../../../index.js' | ||
import type { ExporterOptions, UnixfsV1FileContent, UnixfsV1Resolver, ReadableStorage } from '../../../index.js' | ||
async function walkDAG (blockstore: Blockstore, node: dagPb.PBNode | Uint8Array, queue: Pushable<Uint8Array>, streamPosition: bigint, start: bigint, end: bigint, options: ExporterOptions): Promise<void> { | ||
async function walkDAG (blockstore: ReadableStorage, node: dagPb.PBNode | Uint8Array, queue: Pushable<Uint8Array>, streamPosition: bigint, start: bigint, end: bigint, options: ExporterOptions): Promise<void> { | ||
// a `raw` node | ||
@@ -17,0 +17,0 @@ if (node instanceof Uint8Array) { |
@@ -5,3 +5,3 @@ import parallel from 'it-parallel' | ||
import { decode, PBNode } from '@ipld/dag-pb' | ||
import type { ExporterOptions, Resolve, UnixfsV1DirectoryContent, UnixfsV1Resolver, Blockstore } from '../../../index.js' | ||
import type { ExporterOptions, Resolve, UnixfsV1DirectoryContent, UnixfsV1Resolver, ReadableStorage } from '../../../index.js' | ||
@@ -16,3 +16,3 @@ const hamtShardedDirectoryContent: UnixfsV1Resolver = (cid, node, unixfs, path, resolve, depth, blockstore) => { | ||
async function * listDirectory (node: PBNode, path: string, resolve: Resolve, depth: number, blockstore: Blockstore, options: ExporterOptions): UnixfsV1DirectoryContent { | ||
async function * listDirectory (node: PBNode, path: string, resolve: Resolve, depth: number, blockstore: ReadableStorage, options: ExporterOptions): UnixfsV1DirectoryContent { | ||
const links = node.Links | ||
@@ -19,0 +19,0 @@ |
@@ -5,3 +5,3 @@ | ||
import { murmur3128 } from '@multiformats/murmur3' | ||
import type { ExporterOptions, ShardTraversalContext, Blockstore } from '../index.js' | ||
import type { ExporterOptions, ShardTraversalContext, ReadableStorage } from '../index.js' | ||
import type { CID } from 'multiformats/cid' | ||
@@ -65,3 +65,3 @@ | ||
const findShardCid = async (node: PBNode, name: string, blockstore: Blockstore, context?: ShardTraversalContext, options?: ExporterOptions): Promise<CID | undefined> => { | ||
const findShardCid = async (node: PBNode, name: string, blockstore: ReadableStorage, context?: ShardTraversalContext, options?: ExporterOptions): Promise<CID | undefined> => { | ||
if (context == null) { | ||
@@ -68,0 +68,0 @@ const rootBucket = createHAMT<boolean>({ |
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
206204
0.02%