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

feat(object): add template option to object.new #103

Merged
merged 1 commit into from
Dec 10, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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