Giter Site home page Giter Site logo

js-ipld-resolver's Introduction

IPLD Resolver

Coverage Status Travis CI Circle CI Dependency Status js-standard-style standard-readme compliant

Sauce Test Status

JavaScript implementation of the IPLD Resolver (internal DAG API module)

Table of Contents

Install

> npm install --save ipld-resolver

Usage

const Resolver = require('ipld-resolver')

// pass an optional blockService, if no blockService is passed,
// one is created in memory.
const Resolver = new Resolver(blockService)

API

.put(node, options, callback)

Store the given node of a recognized IPLD Format.

options is an object that must contain one of the following combinations:

  • cid - the CID of the node
  • hashAlg and format - the hashAlg and the format that should be used to create the CID of the node

callback is a function that should have the signature as following: function (err, cid) {}, where err is an Error object in case of error and cid is the cid of the stored object.

.get(cid [, path] [, options], callback)

Retrieve a node by the given cid or cid + path

options is an optional object containing:

  • localResolve: bool - if true, get will only attempt to resolve the path locally

callback should be a function with the signature function (err, result), the result being an object with:

  • value - the value that resulted from the get
  • remainderPath - If it didn't manage to successfully resolve the whole path through or if simply the localResolve option was passed.

.getStream(cid [, path] [, options])

Same as get, but returns a source pull-stream that is used to pass the fetched node.

.treeStream(cid [, path] [, options])

Returns all the paths under a cid + path through a pull-stream. Accepts the following options:

  • recursive - bool - traverse through links to complete the graph.

.remove(cid, callback)

Remove a node by the given cid

.support.add(multicodec, formatResolver, formatUtil)

Add support to another IPLD Format

.support.rm(multicodec)

Removes support of an IPLD Format

Contribute

Feel free to join in. All welcome. Open an issue!

This repository falls under the IPFS Code of Conduct.

License

MIT

js-ipld-resolver's People

Contributors

daviddias avatar dignifiedquire avatar greenkeeperio-bot avatar kumavis avatar nicola avatar richardlitt avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.