The CID of the entry
How far down the DAG the entry is
The name of the entry
The path of the entry within the DAG in which it was encountered
The size of the entry
A disambiguator to allow TypeScript to work out the type of the entry.
if (entry.type === 'file') {
// access UnixFSFile properties safely
}
if (entry.type === 'directory') {
// access UnixFSDirectory properties safely
}
Optional
options: ExporterOptionsWhen entry
is a file or a raw
node, offset
and/or length
arguments can be passed to entry.content()
to return slices of data:
const length = 5
const data = new Uint8Array(length)
let offset = 0
for await (const chunk of entry.content({
offset: 0,
length
})) {
data.set(chunk, offset)
offset += chunk.length
}
// `data` contains the first 5 bytes of the file
return data
If entry
is a directory, passing offset
and/or length
to entry.content()
will limit the number of files returned from the directory.
const entries = []
for await (const entry of dir.content({
offset: 0,
length: 5
})) {
entries.push(entry)
}
// `entries` contains the first 5 files/directories in the directory
Entries with a
dag-cbor
ordag-json
codec CID return JavaScript object entries