Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit e7a4566

Browse files
committed
feat: dag.resolve API
1 parent 01b4e32 commit e7a4566

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

API/dag/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,17 @@ If no `callback` is passed, a [promise][] is returned.
3030

3131
`callback` must follow `function (err, dagNode) {}` signature, where `err` is an error if the operation was not successful and `dagNode` is the IPLD format DAG node retrieved.
3232

33+
#### `dag.resolve`
34+
35+
> Resolves an IPLD path
36+
37+
##### `Go` **WIP**
38+
39+
##### `JavaScript` - ipfs.dag.resolve(cid, path, callback)
40+
41+
- `cid` is a [CID][https://github.com/ipfs/js-cid] instance.
42+
- `path` is a String that represents a valid path to be resolved
43+
44+
`callback` must follow `function (err, value) {}` signature, where `err` is an error if the operation was not successful and `value` is the value it was retrieved.
45+
3346
If no `callback` is passed, a [promise][] is returned.

src/dag-resolve.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* eslint-env mocha */
2+
/* eslint max-nested-callbacks: ["error", 8] */
3+
4+
'use strict'
5+
6+
const expect = require('chai').expect
7+
const dagPB = require('ipld-dag-pb')
8+
const DAGNode = dagPB.DAGNode
9+
const dagCBOR = require('ipld-dag-pb')
10+
11+
module.exports = (common) => {
12+
describe('.dag.resolve', () => {
13+
let ipfs
14+
15+
before((done) => {
16+
common.setup((err, factory) => {
17+
expect(err).to.not.exist
18+
factory.spawnNode((err, node) => {
19+
expect(err).to.not.exist
20+
ipfs = node
21+
done()
22+
})
23+
})
24+
})
25+
26+
after((done) => {
27+
common.teardown(done)
28+
})
29+
30+
describe('callback API', () => {
31+
describe('.resolve', () => {
32+
it.skip('dag-pb local scope', (done) => {})
33+
it.skip('dag-pb one level', (done) => {})
34+
it.skip('dag-pb two levels', (done) => {})
35+
it.skip('dag-cbor local scope', (done) => {})
36+
it.skip('dag-cbor one level', (done) => {})
37+
it.skip('dag-cbor two levels', (done) => {})
38+
it.skip('from dag-pb to dag-cbor', (done) => {})
39+
it.skip('from dag-cbor to dag-pb', (done) => {})
40+
})
41+
})
42+
43+
describe('promise API', () => {
44+
describe('.resolve', () => {})
45+
})
46+
})
47+
}

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ exports.swarm = require('./swarm')
99
exports.block = require('./block')
1010
exports.dht = require('./dht')
1111
exports.dag = require('./dag')
12+
exports.dagResolve = require('./dag-resolve')
1213
exports.pubsub = require('./pubsub')

0 commit comments

Comments
 (0)