computes-ipfs
v1.0.4
Published
computes.io distributed supercomputer
Downloads
25
Maintainers
Readme
computes-ipfs NPM Module
NPM module for connecting Computes.io kernels to the Computes cores via IPFS.
Simple demonstration of submitting 3 javascript requests to IPFS cores.
const computes = require('computes-ipfs')
var operation = "(function(data) { var result = data; return result; })";
// Set options
var options = {
domain: "0381de45-609c-682e-7258-4e79ed738f00"
};
// Connect kernel to computes
var job = computes.connect(options.domain);
job.on("ready", function (){
console.log("connected to ipfs...");
// Submit operations
for(var data = 0; data < 3; data++) {
job.compute(operation, data, options);
}
});
var jobCount = 0
// Fired as cores return results
job.on("result", function (result){
console.log(result);
jobCount++;
if (jobCount == 3){
job.disconnect();
}
});
Notes:
- Options are optional
- Operation can also be a URL such as a raw gist i.e. https://gist.githubusercontent.com/computes/df86808c4a9d0a0d489a/raw/11c92b86662a4df5b5db585a1442796333bd1934/test.js
API commands include:
- connect
- disconnect
- compute
- execute
- cancel
- message
- memory