How to use the ipfs.Buffer.isBuffer function in ipfs

To help you get started, we’ve selected a few ipfs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ipfs-shipyard / ipfs-dag-builder-vis / src / Dag.js View on Github external
isLeaf: Boolean(source.Links.length),
          length: (await ipfs.block.get(cid)).data.length,
          unixfsData
        }
      } catch (err) {
        // dag-pb but not a unixfs.
        console.log(err)
      }

      for (let i = 0; i < source.Links.length; i++) {
        await this._getGraphNodes(source.Links[i].Hash.toString(), nodeMap)
      }

      if (!source.Links.length) classes.push('leaf')
      if (nodeData) classes.push('unixfs', nodeData.unixfsData.type)
    } else if (Buffer.isBuffer(source)) {
      classes.push('raw')
      nodeData = { type: 'raw', isLeaf: true, length: source.length }
    } else {
      // TODO: What IPLD node is this? How to extract the links?
      classes.push('leaf')
      nodeData = { type: 'unknown', isLeaf: true }
    }

    nodeMap.set(cid, {
      group: 'nodes',
      data: { id: cid, ...nodeData },
      classes
    })

    ;(source.Links || []).forEach(link => {
      nodeMap.set(cid + '->' + link.Hash, {

ipfs

JavaScript implementation of the IPFS specification

Apache-2.0 OR MIT
Latest version published 1 year ago

Package Health Score

56 / 100
Full package analysis