This file contains hidden or 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() { | |
var restante = 0; | |
'use strict'; | |
function wait() { | |
return new Promise(function(done, reject) { | |
setTimeout(function() { | |
if (restante > 0) { | |
done(); | |
} else { |
This file contains hidden or 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 revoke = (function(func) { | |
var tmp = func; | |
return { | |
invoke: function(p) { | |
tmp(p); | |
}, | |
revoke: function() { | |
tmp = null; | |
} | |
} |
This file contains hidden or 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 counterf = (function(n){ | |
var inc = function() { | |
return n += 1; | |
}; | |
var dec = function() { | |
return n -= 1; | |
}; | |
return { | |
dec: dec, | |
inc: inc |
This file contains hidden or 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 counterf(n) { | |
var n = n; | |
var inc = function() { | |
return n += 1; | |
}; | |
var dec = function() { | |
return n -= 1; | |
}; | |
return { | |
dec: dec, |
This file contains hidden or 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 multiMax(multi){ | |
// Make an array of all but the first argument | |
var allButFirst = Array().slice.call(arguments); | |
// Find the largest number in that array of arguments | |
var largestAllButFirst = Math.max.apply(Math,allButFirst); | |
// Return the multiplied result | |
return multi * largestAllButFirst; | |
} |
This file contains hidden or 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 add = (function(a) { | |
return function(b) { | |
return a + b; | |
} | |
}); | |
var mul = (function(a) { | |
return function(b) { | |
var total = a * b; | |
return total; | |
} |
This file contains hidden or 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 demethodize(func){ | |
return function(that,y){ | |
return func.call(that,y); | |
} | |
} | |
var add = (function(a) { | |
return function(b) { | |
return a + b; | |
} | |
}); |
This file contains hidden or 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 add(a,b) { | |
return (a + b); | |
} | |
function methodize(func) { | |
return function(y){ | |
return func(this,y); | |
} | |
} | |
Number.prototype.add = methodize(add); | |
(2).add(3) // 5 |
This file contains hidden or 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 add = (function(a) { | |
return function(b) { | |
return a + b; | |
} | |
}); | |
var mul = (function(a) { | |
return function(b) { | |
var total = a * b; |
This file contains hidden or 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 add = (function(a) { | |
return function(b) { | |
return a + b; | |
} | |
}); | |
var mul = (function(a) { | |
return function(b) { | |
var total = a * b; |