|
1 |
| -# IPFS IPLD |
| 1 | +# IPLD Resolver |
2 | 2 |
|
3 | 3 | [](http://ipn.io)
|
4 | 4 | [](http://ipfs.io/)
|
5 | 5 | [](http://webchat.freenode.net/?channels=%23ipfs)
|
| 6 | +[](https://coveralls.io/github/ipld/js-ipld-resolver?branch=master) |
| 7 | +[](https://travis-ci.org/ipld/js-ipld-resolver) |
| 8 | +[](https://circleci.com/gh/ipld/js-ipld-resolver) |
| 9 | +[](https://david-dm.org/ipld/js-ipld-resolver) |
| 10 | +[](https://github.com/feross/standard) |
6 | 11 | [](https://github.com/RichardLitt/standard-readme)
|
7 |
| -[](https://coveralls.io/github/ipfs/js-ipfs-ipld?branch=master) |
8 |
| -[](https://travis-ci.org/ipfs/js-ipfs-ipld) |
9 |
| -[](https://circleci.com/gh/ipfs/js-ipfs-ipld) |
10 |
| -[](https://david-dm.org/ipfs/js-ipfs-ipld) [](https://github.com/feross/standard) |
11 | 12 |
|
12 |
| -> JavaScript implementation of the IPLDService |
| 13 | +> JavaScript implementation of the IPLD Resolver |
13 | 14 |
|
14 | 15 | ## Table of Contents
|
15 | 16 |
|
16 |
| -* [Install](#install) |
17 |
| -* [Usage](#usage) |
18 |
| -* [API](#api) |
19 |
| - + [`resolve`](#resolve) |
20 |
| - + [IPLDService](#ipldservice) |
| 17 | +- [Install](#install) |
| 18 | +- [Usage](#usage) |
| 19 | +- [API](#api) |
| 20 | + - [IPLD Resolver](#ipldresolver) |
21 | 21 | - [`.put(node, cb)`](#putnode-cb)
|
22 | 22 | - [`.putStream([cb])`](#putstreamcb)
|
23 |
| - - [`.get(multihash, cb)`](#getmultihash-cb) |
24 |
| - - [`.getStream(multihash)`](#getstreammultihash) |
25 |
| - - [`.getRecursive(multihash, cb)`](#getrecursivemultihash-cb) |
26 |
| - - [`.getRecursiveStream(multihash)`](#getrecursivestreammultihash) |
27 |
| - - [`.remove(multihash, cb)`](#removemultihash-cb) |
28 |
| -* [Contribute](#contribute) |
29 |
| -* [License](#license) |
| 23 | + - [`.get(cid, cb)`](#getcid-cb) |
| 24 | + - [`.getStream(cid)`](#getstreamcid) |
| 25 | + - [`.remove(cid, cb)`](#removecid-cb) |
| 26 | +- [Contribute](#contribute) |
| 27 | +- [License](#license) |
30 | 28 |
|
31 | 29 | ## Install
|
32 | 30 |
|
33 | 31 | ```bash
|
34 |
| -npm install --save ipfs-ipld |
| 32 | +> npm install --save ipfs-ipld |
35 | 33 | ```
|
36 | 34 |
|
37 | 35 | ## Usage
|
38 | 36 |
|
39 | 37 | ```js
|
40 |
| -const ipfsIPLD = require('ipfs-ipld') |
| 38 | +const IPLDResolver = require('ipld-resolver') |
41 | 39 |
|
42 |
| -// available components |
43 |
| -ipfsIPLD.IPLDService |
44 |
| -ipfsIPLD.resolve |
| 40 | +// pass an optional blockService, if no blockService is passed, |
| 41 | +// one is created in memory. |
| 42 | +const ipldResolver = new IPLDResolver(blockService) |
45 | 43 | ```
|
46 | 44 |
|
47 | 45 | ## API
|
48 | 46 |
|
49 |
| -### `resolve` |
| 47 | +### IPLD Resolver |
50 | 48 |
|
51 |
| -> Resolve IPLD paths against a given IPLDService |
52 |
| -
|
53 |
| -```js |
54 |
| -const node = { |
55 |
| - hello: { |
56 |
| - world: 11, |
57 |
| - some: 12 |
58 |
| - } |
59 |
| -} |
60 |
| -const mh = ipld.multihash(ipld.marshal(node)) |
61 |
| -ipldService.put(node, (err) => { |
62 |
| - resolve(ipldService, `${mh}/hello/world`, (err, res) => { |
63 |
| - console.log(res) |
64 |
| - // => 11 |
65 |
| -}) |
66 |
| -``` |
67 |
| -
|
68 |
| -### IPLDService |
69 |
| -
|
70 |
| -#### `.put(node, cb)` |
| 49 | +#### `.put(node, callback)` |
71 | 50 |
|
72 | 51 | > Store the given node (any JavaScript object).
|
73 | 52 |
|
74 |
| -#### `.putStream([cb])` |
| 53 | +#### `.putStream([callback])` |
75 | 54 |
|
76 | 55 | Returns a sink pull-stream, to write IPLD objects to.
|
77 | 56 |
|
78 |
| -#### `.get(multihash, cb)` |
| 57 | +#### `.get(cid, callback)` |
79 | 58 |
|
80 | 59 | > Retrieve a node by the given `multihash`.
|
81 | 60 |
|
82 |
| -#### `.getStream(multihash)` |
| 61 | +#### `.getStream(cid)` |
83 | 62 |
|
84 | 63 | Returns a source pull-stream of the requested IPLD object.
|
85 | 64 |
|
86 |
| -#### `.getRecursive(multihash, cb)` |
| 65 | +#### `.remove(cid, callback)` |
87 | 66 |
|
88 |
| -> Retrieve a node by the given `multihash` and all linked nodes. |
| 67 | +> Remove a node by the given `multihash` |
89 | 68 |
|
90 |
| -#### `.getRecursiveStream(multihash)` |
| 69 | +#### `.resolve(cid, path, callback)` |
91 | 70 |
|
92 |
| -Returns a source pull-stream, which emits the requested node, and |
93 |
| -all linked nodes. |
| 71 | +> Resolves an IPLD path |
94 | 72 |
|
95 |
| -#### `.remove(multihash, cb)` |
| 73 | +#### `.support.add(multicodec, formatResolver, formatUtil)` |
96 | 74 |
|
97 |
| -> Remove a node by the given `multihash` |
| 75 | +> Add support to another IPLD Format |
| 76 | +
|
| 77 | +#### `.support.rm(multicodec)` |
| 78 | + |
| 79 | +> Removes support of an IPLD Format |
98 | 80 |
|
99 | 81 | ## Contribute
|
100 | 82 |
|
|
0 commit comments