forked from ipfs-inactive/js-ipfs-http-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: modularize files api(ipfs-inactive#544)
- Loading branch information
Showing
16 changed files
with
214 additions
and
131 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict' | ||
|
||
const promisify = require('promisify-es6') | ||
|
||
module.exports = (send) => { | ||
return promisify((args, opts, callback) => { | ||
if (typeof (opts) === 'function') { | ||
callback = opts | ||
opts = {} | ||
} | ||
send({ | ||
path: 'files/cp', | ||
args: args, | ||
qs: opts | ||
}, callback) | ||
}) | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict' | ||
|
||
const moduleConfig = require('../../module-config') | ||
|
||
module.exports = (arg) => { | ||
const send = moduleConfig(arg) | ||
|
||
return { | ||
add: require('./add')(send), | ||
createAddStream: require('./create-add-stream')(send), | ||
get: require('./get')(send), | ||
cat: require('./cat')(send), | ||
cp: require('./cp')(send), | ||
ls: require('./ls')(send), | ||
mkdir: require('./mkdir')(send), | ||
stat: require('./stat')(send), | ||
rm: require('./rm')(send), | ||
read: require('./read')(send), | ||
write: require('./write')(send), | ||
mv: require('./mv')(send) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict' | ||
|
||
const promisify = require('promisify-es6') | ||
|
||
module.exports = (send) => { | ||
return promisify((args, opts, callback) => { | ||
if (typeof (opts) === 'function') { | ||
callback = opts | ||
opts = {} | ||
} | ||
return send({ | ||
path: 'files/ls', | ||
args: args, | ||
qs: opts | ||
}, callback) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
|
||
'use strict' | ||
|
||
const promisify = require('promisify-es6') | ||
|
||
module.exports = (send) => { | ||
return promisify((args, opts, callback) => { | ||
if (typeof (opts) === 'function') { | ||
callback = opts | ||
opts = {} | ||
} | ||
send({ | ||
path: 'files/mkdir', | ||
args: args, | ||
qs: opts | ||
}, callback) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict' | ||
|
||
const promisify = require('promisify-es6') | ||
|
||
module.exports = (send) => { | ||
return promisify((args, opts, callback) => { | ||
if (typeof opts === 'function' && | ||
callback === undefined) { | ||
callback = opts | ||
opts = {} | ||
} | ||
send({ | ||
path: 'files/mv', | ||
args: args, | ||
qs: opts | ||
}, callback) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict' | ||
|
||
const promisify = require('promisify-es6') | ||
|
||
module.exports = (send) => { | ||
return promisify((args, opts, callback) => { | ||
if (typeof (opts) === 'function') { | ||
callback = opts | ||
opts = {} | ||
} | ||
send({ | ||
path: 'files/read', | ||
args: args, | ||
qs: opts | ||
}, callback) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict' | ||
|
||
const promisify = require('promisify-es6') | ||
|
||
module.exports = (send) => { | ||
return promisify((path, opts, callback) => { | ||
if (typeof opts === 'function' && | ||
!callback) { | ||
callback = opts | ||
opts = {} | ||
} | ||
|
||
// opts is the real callback -- | ||
// 'callback' is being injected by promisify | ||
if (typeof opts === 'function' && | ||
typeof callback === 'function') { | ||
callback = opts | ||
opts = {} | ||
} | ||
|
||
send({ | ||
path: 'files/rm', | ||
args: path, | ||
qs: opts | ||
}, callback) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict' | ||
|
||
const promisify = require('promisify-es6') | ||
|
||
module.exports = (send) => { | ||
return promisify((args, opts, callback) => { | ||
if (typeof (opts) === 'function') { | ||
callback = opts | ||
opts = {} | ||
} | ||
send({ | ||
path: 'files/stat', | ||
args: args, | ||
qs: opts | ||
}, callback) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict' | ||
|
||
const promisify = require('promisify-es6') | ||
|
||
module.exports = (send) => { | ||
return promisify((pathDst, files, opts, callback) => { | ||
if (typeof opts === 'function' && | ||
!callback) { | ||
callback = opts | ||
opts = {} | ||
} | ||
|
||
// opts is the real callback -- | ||
// 'callback' is being injected by promisify | ||
if (typeof opts === 'function' && | ||
typeof callback === 'function') { | ||
callback = opts | ||
opts = {} | ||
} | ||
|
||
send({ | ||
path: 'files/write', | ||
args: pathDst, | ||
qs: opts, | ||
files: files | ||
}, callback) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.