Skip to content

Commit

Permalink
Merge branch 'master' of github.com:MaiaVictor/swarm-js into Jonahss-…
Browse files Browse the repository at this point in the history
…master
  • Loading branch information
evertonfraga committed Aug 30, 2018
2 parents d5904f1 + 21bc9ed commit 56da3d3
Show file tree
Hide file tree
Showing 15 changed files with 1,636 additions and 34 deletions.
Empty file.
File renamed without changes
File renamed without changes.
File renamed without changes.
628 changes: 628 additions & 0 deletions examples/uploader_dapp/swarm.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions lib/api-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ var unavailable = function unavailable() {
throw "This swarm.js function isn't available on the browser.";
};

var fsp = { readFile: unavailable };
var fs = { readFile: unavailable };
var files = { download: unavailable, safeDownloadArchived: unavailable, directoryTree: unavailable };
var os = { platform: unavailable, arch: unavailable };
var path = { join: unavailable, slice: unavailable };
Expand All @@ -17,7 +17,7 @@ var pick = require("./pick.js");
var swarm = require("./swarm");

module.exports = swarm({
fsp: fsp,
fs: fs,
files: files,
os: os,
path: path,
Expand Down
4 changes: 2 additions & 2 deletions lib/api-node.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var fsp = require("fs-promise");
var fs = require("fs-extra");
var files = require("./files.js");
var os = require("os");
var path = require("path");
Expand All @@ -25,7 +25,7 @@ var request = function request(url, params) {
};

module.exports = swarm({
fsp: fsp,
fs: fs,
files: files,
os: os,
path: path,
Expand Down
2 changes: 1 addition & 1 deletion lib/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,4 +247,4 @@ module.exports = {
downloadArchived: downloadArchived,
search: search,
test: test
};
};
10 changes: 5 additions & 5 deletions lib/swarm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// separating the functions that are used on Node.js from the functions that
// are used only on the browser.
module.exports = function (_ref) {
var fsp = _ref.fsp,
var fs = _ref.fs,
files = _ref.files,
os = _ref.os,
path = _ref.path,
Expand Down Expand Up @@ -253,7 +253,7 @@ module.exports = function (_ref) {
// String -> String -> Promise String
var uploadFileFromDisk = function uploadFileFromDisk(swarmUrl) {
return function (filePath) {
return fsp.readFile(filePath).then(function (data) {
return fs.readFile(filePath).then(function (data) {
return uploadFile(swarmUrl)({ type: mimetype.lookup(filePath), data: data });
});
};
Expand Down Expand Up @@ -282,7 +282,7 @@ module.exports = function (_ref) {
// String -> Promise String
var uploadDataFromDisk = function uploadDataFromDisk(swarmUrl) {
return function (filePath) {
return fsp.readFile(filePath).then(uploadData(swarmUrl));
return fs.readFile(filePath).then(uploadData(swarmUrl));
};
};

Expand All @@ -292,7 +292,7 @@ module.exports = function (_ref) {
return function (dirPath) {
return files.directoryTree(dirPath).then(function (fullPaths) {
return Promise.all(fullPaths.map(function (path) {
return fsp.readFile(path);
return fs.readFile(path);
})).then(function (datas) {
var paths = fullPaths.map(function (path) {
return path.slice(dirPath.length);
Expand Down Expand Up @@ -622,4 +622,4 @@ module.exports = function (_ref) {
fromString: fromString,
toString: toString
};
};
};
Loading

0 comments on commit 56da3d3

Please sign in to comment.