Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

swarm-js

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swarm-js - npm Package Compare versions

Comparing version 0.1.16 to 0.1.17

61

lib/swarm.js

@@ -1,15 +0,5 @@

var Q = require("bluebird");
var archives = require("./../archives/archives.json");
var assert = require("assert");
var files = require("./files.js");
var fsp = require("fs-promise");
var got = require("got");
var mimetype = require('mimetype');
var os = require("os");
var path = require("path");
var pick = require("./pick.js");
var got = require("got");
var _require = require("child_process"),
spawn = _require.spawn;
var downloadUrl = "http://ethereum-mist.s3.amazonaws.com/swarm/";

@@ -79,3 +69,2 @@

return function (routes) {
// Formats an entry to the Swarm.js type.

@@ -92,3 +81,3 @@ var format = function format(entry) {

var downloadEntry = function downloadEntry(entry) {
return entry.contentType === "application/bzz-manifest+json" ? search(entry.hash)(path + entry.path)(routes) : Q.resolve(impureInsert(path + entry.path)(format(entry))(routes));
return entry.contentType === "application/bzz-manifest+json" ? search(entry.hash)(path + entry.path)(routes) : Promise.resolve(impureInsert(path + entry.path)(format(entry))(routes));
};

@@ -100,5 +89,5 @@

}).then(function (entries) {
return Q.reduce(entries.map(downloadEntry), function (a, b) {
return b;
});
return entries.map(downloadEntry).reduce(function (a, b) {
return b.then(a);
}, Promise.resolve());
});

@@ -108,2 +97,3 @@ };

};
return search(hash)("")({});

@@ -144,3 +134,3 @@ };

};
return Q.all(datas).then(function (datas) {
return Promise.all(datas).then(function (datas) {
return toMap(paths)(files(datas));

@@ -158,3 +148,3 @@ });

return function (filePath) {
return files.download(rawUrl(swarmUrl)(hash))(filePath);
return require("." + "/files.js").download(rawUrl(swarmUrl)(hash))(filePath);
};

@@ -174,7 +164,7 @@ };

if (route.length > 0) {
var filePath = path.join(dirPath, route);
var filePath = require("p" + "ath").join(dirPath, route);
downloads.push(downloadDataToDisk(swarmUrl)(routingTable[route])(filePath));
};
};
return Q.all(downloads).then(function () {
return Promise.all(downloads).then(function () {
return dirPath;

@@ -235,3 +225,3 @@ });

return function (filePath) {
return fsp.readFile(filePath).then(function (data) {
return require("f" + "s-promise").readFile(filePath).then(function (data) {
return uploadFile(swarmUrl)({ type: mimetype.lookup(filePath), data: data });

@@ -257,3 +247,3 @@ });

};
return Object.keys(directory).reduce(uploadToHash, Q.resolve(hash));
return Object.keys(directory).reduce(uploadToHash, Promise.resolve(hash));
});

@@ -266,3 +256,3 @@ };

return function (filePath) {
return fsp.readFile(filePath).then(uploadData(swarmUrl));
return require("f" + "s-promise").readFile(filePath).then(uploadData(swarmUrl));
};

@@ -275,5 +265,5 @@ };

return function (dirPath) {
return files.directoryTree(dirPath).then(function (fullPaths) {
return Q.all(fullPaths.map(function (path) {
return fsp.readFile(path);
return require("." + "/files.js").directoryTree(dirPath).then(function (fullPaths) {
return Promise.all(fullPaths.map(function (path) {
return require("f" + "s-promise").readFile(path);
})).then(function (datas) {

@@ -334,3 +324,3 @@ var paths = fullPaths.map(function (path) {

return Q.reject(new Error("Bad arguments"));
return Promise.reject(new Error("Bad arguments"));
};

@@ -362,3 +352,3 @@ };

var downloadBinary = function downloadBinary(path) {
var system = os.platform().replace("win32", "windows") + "-" + (os.arch() === "x64" ? "amd64" : "386");
var system = require("o" + "s").platform().replace("win32", "windows") + "-" + (os.arch() === "x64" ? "amd64" : "386");
var archive = archives[system];

@@ -368,3 +358,3 @@ var archiveUrl = downloadUrl + archive.archive + ".tar.gz";

var binaryMD5 = archive.binaryMD5;
return files.safeDownloadArchived(archiveUrl)(archiveMD5)(binaryMD5)(path);
return require("./" + "files.js").safeDownloadArchived(archiveUrl)(archiveMD5)(binaryMD5)(path);
};

@@ -384,3 +374,6 @@

var startProcess = function startProcess(swarmSetup) {
return new Q(function (resolve, reject) {
return new Promise(function (resolve, reject) {
var _require = require("c" + "hild_process"),
spawn = _require.spawn;
var hasString = function hasString(str) {

@@ -439,3 +432,3 @@ return function (buffer) {

var stopProcess = function stopProcess(process) {
return new Q(function (resolve, reject) {
return new Promise(function (resolve, reject) {
process.stderr.removeAllListeners('data');

@@ -529,3 +522,3 @@ process.stdout.removeAllListeners('data');

var test = function test() {
return Q.resolve(true);
return Promise.resolve(true);
};

@@ -591,4 +584,4 @@

Swarm = module.exports;
require("setimmediate");
window.Buffer = require("buffer/").Buffer;
require("s" + "etimmediate");
window.Buffer = require("b" + "uffer/").Buffer;
window.pick = pick;

@@ -595,0 +588,0 @@ };

{
"name": "swarm-js",
"version": "0.1.16",
"version": "0.1.17",
"description": "Swarm tools for JavaScript.",

@@ -10,3 +10,3 @@ "main": "lib/swarm.js",

"build": "npm run bundle; npm run minify",
"babel": " babel src --out-dir=lib",
"babel": "babel src --out-dir=lib",
"test": "echo \"Error: no test specified\" && exit 1"

@@ -17,3 +17,2 @@ },

"dependencies": {
"bluebird": "^3.4.7",
"buffer": "^5.0.5",

@@ -20,0 +19,0 @@ "decompress": "^4.0.0",

@@ -426,4 +426,4 @@ const mimetype = require('mimetype');

Swarm = module.exports;
require("setimmediate");
window.Buffer = require("buffer/").Buffer
require("s"+"etimmediate");
window.Buffer = require("b"+"uffer/").Buffer
window.pick = pick;

@@ -430,0 +430,0 @@ };

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc