diff --git a/package.json b/package.json index 039c28b1b..60e350e64 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "aegir": "^3.2.0", "chai": "^3.5.0", "gulp": "^3.9.1", - "interface-ipfs-core": "^0.3.0", + "interface-ipfs-core": "^0.4.3", "ipfsd-ctl": "^0.14.0", "pre-commit": "^1.1.2", "stream-equal": "^0.1.8", @@ -94,4 +94,4 @@ "url": "https://github.com/ipfs/js-ipfs-api/issues" }, "homepage": "https://github.com/ipfs/js-ipfs-api" -} \ No newline at end of file +} diff --git a/src/api/add.js b/src/api/add.js index d4a99b96f..2dfea23b9 100644 --- a/src/api/add.js +++ b/src/api/add.js @@ -2,24 +2,20 @@ const isStream = require('isstream') const addToDagNodesTransform = require('../add-to-dagnode-transform') +const promisify = require('promisify-es6') module.exports = (send) => { - return function add (files, opts, cb) { - if (typeof (opts) === 'function' && cb === undefined) { - cb = opts - opts = {} - } - + return promisify((files, callback) => { const good = Buffer.isBuffer(files) || isStream.isReadable(files) || Array.isArray(files) if (!good) { - return cb(new Error('"files" must be a buffer, readable stream, or array of objects')) + callback(new Error('"files" must be a buffer, readable stream, or array of objects')) } - var sendWithTransform = send.withTransform(addToDagNodesTransform) + const sendWithTransform = send.withTransform(addToDagNodesTransform) - return sendWithTransform('add', null, opts, files, cb) - } + sendWithTransform('add', null, {}, files, callback) + }) }