frpjs
Version:
Functional Reactive Programming JavaScript Library
30 lines (26 loc) • 676 B
JavaScript
// Nodejs functions
const https = require('https'),
fs = require('fs'),
Node = {}
Node.https.get = function(url) {
return function(next) {
let data = ''
https.get(url, function(res) {
res.on('data', function(d) {
data += d.toString()
}).on('end', function() {
next(data)
})
}).on('error', function(e) {
console.log("Got error: " + e.message);
})
}
}
Node.fs.readFile = function(filename) {
return function(next) {
fs.readFile(filename, function(err, data) {
next(data, err)
})
}
}
export default Node