Skip to content

Instantly share code, notes, and snippets.

@frankandrobot
Last active November 7, 2015 18:11
Show Gist options
  • Save frankandrobot/9015b87140e2e6cf55c3 to your computer and use it in GitHub Desktop.
Save frankandrobot/9015b87140e2e6cf55c3 to your computer and use it in GitHub Desktop.
BaconJS combineTemplate vs HighlandJS zip vs Bluebird join vs BaconJS zip vs Kefir zip
const restify = require('restify');
const server = restify.createServer();
const Bacon = require('baconjs');
server.get('/', function(req, res, next) {
const a = Bacon.once('a');
const b = Bacon.once('b');
a.flatMap(a => Bacon.combineTemplate({a, b}))
.onValue(template => {
res.send(template);
next();
return Bacon.noMore; //unsubscribe onValue
});
});
server.listen(3000, function() {
console.log('Listening on port 3000');
});
const restify = require('restify');
const server = restify.createServer();
const Bacon = require('baconjs');
server.get('/', function(req, res, next) {
const a = Bacon.once('a');
const b = Bacon.once('b');
a.zip(b, (a,b) => { return [a, b]; })
.onValue(template => {
res.send(template);
next();
return Bacon.noMore; //unsubscribe onValue
});
});
server.listen(3000, function() {
console.log('Listening on port 3000');
});
const restify = require('restify');
const server = restify.createServer();
const Promise = require('bluebird');
server.get('/', function(req, res, next) {
const a = new Promise((res,err) => res('a'));
const b = new Promise((res,err) => res('b'));
a.then(a => Promise.join(a, b))
.then(template => {
res.send(template);
next();
});
});
server.listen(3000, function() {
console.log('Listening on port 3000');
});
const restify = require('restify');
const server = restify.createServer();
const h = require('highland');
server.get('/', function(req, res, next) {
const a = h(['a']);
const b = h(['b']);
a.zip(b)
.pull((err, template) => {
res.send(template);
next();
});
});
server.listen(3000, function() {
console.log('Listening on port 3000');
});
const Kefir = require('kefir');
const restify = require('restify');
const server = restify.createServer();
server.get('/', function(req, res, next) {
const a = Kefir.fromCallback(callback => callback('a'));
const b = Kefir.fromCallback(callback => callback('b'));
a.zip(b).onValue(template => {
res.send(template);
next();
});
});
server.listen(3000, function() {
console.log('Listening on port 3000');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment