Get links (references) from an object.
ipfsPath
can be of type:
cid
of type:- String, including the ipfs handler, a cid and a path to traverse to, ie:
- '/ipfs/QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66'
- '/ipfs/QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66/a.txt'
- 'QmXEmhrMpbVvTh61FNAxP9nU7ygVtyvZA8HZDUaqQCAb66/a.txt'
options
is an optional object that may contain the following keys:
recursive (false)
: recursively list references of child nodesunique (false)
: omit duplicate references from outputformat ("<dst>")
: output edges with given format. Available tokens:<src>
,<dst>
,<linkname>
edges (false)
: output references in edge format:"<src> -> <dst>"
maxDepth (1)
: only for recursive refs, limits fetch and listing to the given depthtimeout (number|string)
: Throw an error if the request does not complete within the specified milliseconds timeout. Iftimeout
is a string, the value is parsed as a human readable duration. There is no timeout by default.
Returns
Type | Description |
---|---|
AsyncIterable<Object> |
An async iterable that yields objects representing the links (references) |
Each yielded object is of the form:
{
ref: string,
err: Error | null
}
Example:
for await (const ref of ipfs.refs(ipfsPath, { recursive: true })) {
if (ref.err) {
console.error(ref.err)
} else {
console.log(ref.ref)
// output: "QmHash"
}
}
Output all local references (CIDs of all blocks in the blockstore)
Returns
Type | Description |
---|---|
AsyncIterable<Object> |
An async iterable that yields objects representing the links (references) |
Each yielded object is of the form:
{
ref: string,
err: Error | null
}
Example:
for await (const ref of ipfs.refs.local()) {
if (ref.err) {
console.error(ref.err)
} else {
console.log(ref.ref)
// output: "QmHash"
}
}