This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Simple compose example (extract from Scott Sauyet) | |
// Simplest compose | |
var compose = function(f, g) { | |
return function(x) { | |
return f(g(x)); | |
}; | |
}; | |
var trim = function(str) {return str.replace(/^\s*|\s*$/g, '');}; | |
var capitalize = function(str) {return str.toUpperCase();}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Another Simple example | |
// Simplest compose | |
var compose = function(f, g) { | |
return function(x) { | |
return f(g(x)); | |
}; | |
}; | |
var add1 = function(x) {return x + 1;}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var compose = function(f, g) { | |
return function() { | |
return f.call(this, g.apply(this, arguments)); | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var compose = function() { | |
var funcs = arguments; | |
return function() { | |
var args = arguments; | |
for (var i = funcs.length; i --> 0;) { | |
args = [funcs[i].apply(this, args)]; | |
} | |
return args[0]; | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var compose = function() { | |
var funcs = arguments; | |
return function() { | |
var args = arguments; | |
for (var i = funcs.length; i --> 0;) { | |
args = [funcs[i].apply(this, args)]; | |
} | |
return args[0]; | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var compose = function compose(f) { | |
var queue = f ? [f] : []; | |
var fn = function fn(g) { | |
if (arguments.length) { | |
queue.push(g); | |
return fn; | |
} | |
return function() { | |
var args = Array.prototype.slice.call(arguments); | |
queue.forEach(function(func) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var first = (function() { | |
var chainNames = ["then", "andThen", "next"]; | |
var endChainNames = ["finally", "andFinally", "last"]; | |
var chain = function(fn) { | |
var f1 = function(g) { | |
var func = function() {return g.call(this, | |
fn.apply(this, arguments));}; | |
chain(func); | |
return func; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sendMessage = function(a,b) { | |
console.log('Message sent to: ' + a + ', content: ' + b); | |
}; | |
var phone = function(spec) { | |
var that = {}; | |
that.getPhoneNumber = function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
var property = { baseValue: 5 }; // Parts of model domain (domain properties). | |
var someBehavior = function (params) { // implementation domain. | |
return this.baseValue + params; | |
}; | |
var result = someBehavior.call(property, 4); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// (BACKEND) | |
// | |
//var sourceRandom = Rx.Observable.from([1, 2, 3, 6, 8, 7, 5, 4, 9]); | |
//+ Create a stream of random numbers. (BACKEND) | |
var sourceRandom = Rx.Observable | |
.interval(100) | |
.timeInterval() | |
.map(function(value) { |
OlderNewer