Skip to content

Instantly share code, notes, and snippets.

View alvieirajr's full-sized avatar

Antônio Vieira alvieirajr

  • Brazil, Recife
View GitHub Profile
// 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();};
// Another Simple example
// Simplest compose
var compose = function(f, g) {
return function(x) {
return f(g(x));
};
};
var add1 = function(x) {return x + 1;};
var compose = function(f, g) {
return function() {
return f.call(this, g.apply(this, arguments));
};
};
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];
};
};
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];
};
};
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) {
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;
};
var sendMessage = function(a,b) {
console.log('Message sent to: ' + a + ', content: ' + b);
};
var phone = function(spec) {
var that = {};
that.getPhoneNumber = function() {
"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);
//
// (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) {