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

Commit ab1d02e

Browse files
committed
fix files.add promises
1 parent db2315f commit ab1d02e

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"aegir": "^3.2.0",
3434
"chai": "^3.5.0",
3535
"gulp": "^3.9.1",
36-
"interface-ipfs-core": "^0.3.0",
36+
"interface-ipfs-core": "^0.3.1",
3737
"ipfsd-ctl": "^0.14.0",
3838
"pre-commit": "^1.1.2",
3939
"stream-equal": "^0.1.8",
@@ -94,4 +94,4 @@
9494
"url": "https://github.com/ipfs/js-ipfs-api/issues"
9595
},
9696
"homepage": "https://github.com/ipfs/js-ipfs-api"
97-
}
97+
}

src/api/add.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,20 @@
22

33
const isStream = require('isstream')
44
const addToDagNodesTransform = require('../add-to-dagnode-transform')
5+
const promisify = require('promisify-es6')
56

67
module.exports = (send) => {
7-
return function add (files, opts, cb) {
8-
if (typeof (opts) === 'function' && cb === undefined) {
9-
cb = opts
10-
opts = {}
11-
}
12-
8+
return promisify((files, callback) => {
139
const good = Buffer.isBuffer(files) ||
1410
isStream.isReadable(files) ||
1511
Array.isArray(files)
1612

1713
if (!good) {
18-
return cb(new Error('"files" must be a buffer, readable stream, or array of objects'))
14+
callback(new Error('"files" must be a buffer, readable stream, or array of objects'))
1915
}
2016

21-
var sendWithTransform = send.withTransform(addToDagNodesTransform)
17+
const sendWithTransform = send.withTransform(addToDagNodesTransform)
2218

23-
return sendWithTransform('add', null, opts, files, cb)
24-
}
19+
sendWithTransform('add', null, {}, files, callback)
20+
})
2521
}

0 commit comments

Comments
 (0)