Skip to content

Latest commit

 

History

History
115 lines (87 loc) · 3 KB

REFS.md

File metadata and controls

115 lines (87 loc) · 3 KB

Refs API

ipfs.refs(ipfsPath, [options])

Get links (references) from an object.

Parameters

Name Type Description
ipfsPath CID or String The object to search for references

Options

An optional object which may have the following keys:

Name Type Default Description
recursive boolean false Recursively list references of child nodes
unique boolean false Omit duplicate references from output
format String '<dst>' output edges with given format. Available tokens: <src>, <dst>, <linkname>
edges boolean false output references in edge format: "<src> -> <dst>"
maxDepth Number 1 only for recursive refs, limits fetch and listing to the given depth
timeout Number undefined A timeout in ms
signal AbortSignal undefined Can be used to cancel any long running requests started as a result of this call

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"
  }
}

ipfs.refs.local([options])

Output all local references (CIDs of all blocks in the blockstore)

Parameters

None

Options

An optional object which may have the following keys:

Name Type Default Description
timeout Number undefined A timeout in ms
signal AbortSignal undefined Can be used to cancel any long running requests started as a result of this call

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"
  }
}