Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
feat(object): add template option to object.new
Browse files Browse the repository at this point in the history
  • Loading branch information
dignifiedquire committed Dec 10, 2016
1 parent a43b71b commit 2f23617
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 3 additions & 3 deletions API/object/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ object API
##### `Go` **WIP**

##### `JavaScript` - ipfs.object.new([callback])
##### `JavaScript` - ipfs.object.new([template][, callback])

`template` if defined, must be a string `unixfs-dir` and if that is passed, the created node will be an empty unixfs style directory.

`callback` must follow `function (err, node) {}` signature, where `err` is an error if the operation was not successful and `node` is a MerkleDAG node of the type [DAGNode][]

Expand Down Expand Up @@ -256,5 +258,3 @@ If no `callback` is passed, a [promise][] is returned.
[DAGNode]: https://github.com/vijayee/js-ipfs-merkle-dag
[multihash]: http://github.com/jbenet/multihash
[promise]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise


13 changes: 13 additions & 0 deletions src/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ module.exports = (common) => {
done()
})
})

it('template unixfs-dir', (done) => {
ipfs.object.new('unixfs-dir', (err, node) => {
expect(err).to.not.exist
const nodeJSON = node.toJSON()
expect(
nodeJSON.multihash
).to.equal(
'QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn'
)
done()
})
})
})

describe('.put', () => {
Expand Down

0 comments on commit 2f23617

Please sign in to comment.