[1,2,3].filter(function(v){return v>2;});
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
Array.prototype.every = function (fn) { | |
return this.reduce(function (a, b){ return a && fn(b); }, true); | |
} |
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
(function () { | |
Array.prototype.select = Array.prototype.map; | |
Array.prototype.where = Array.prototype.filter; | |
Array.prototype.all = Array.prototype.every; | |
Array.prototype.any = Array.prototype.some; | |
Array.prototype.agregate = Array.prototype.reduce; | |
Array.prototype.fold = Array.prototype.reduce; | |
} ()); |
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
<ul> | |
<% for(var i = 0; i<items.length; i++){ %> | |
<li><%= items[i].name %></li> | |
<% } %> | |
</ul> |
[gist https://gist.github.com/2760000 file="reduce.js" /]
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
Array.prototype.contains = function(value, comparison){ | |
comparison = comparison || function(A,B){ | |
return (A === B); | |
}; | |
return this.some(function(item){ | |
return comparison(item, value); | |
}); | |
}; |
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
function getAllUserDetails(id, cb){ | |
database.findUserByID(id, function(err,user){ | |
if(err) return cb(err); | |
var roles,friends; | |
user.getRoles(function(err,res){ | |
if(err) return cb(err); | |
roles = res; | |
next(); | |
}); | |
user.getFriends(function(err,res){ |
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
function longCompare(actual, expected) { | |
function format(str) { | |
if (typeof str === 'string') { | |
return JSON.stringify(str).replace(/^\"/g, '\'').replace(/\"$/g, '\''); | |
} else { | |
return str; | |
} | |
} | |
for (var i = 0; i < actual.length || i < expected.length; i++) { | |
if (actual.charAt(i) !== expected.charAt(i)) { |
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
module.exports.not = not_qjs; | |
function not_qjs(promise) { | |
return promise.then(function (value) { | |
return !value; | |
}); | |
} | |
function continue_qjs(result) { | |
return once_qjs(function continue_qjs() { | |
return result; |
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
git checkout master | |
git pull upstream master | |
git rebase master |
OlderNewer