Created
December 8, 2016 22:23
-
-
Save jgermade/c1eb7f9ee116b81f46f6929a653beda9 to your computer and use it in GitHub Desktop.
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 delayed (fn, args) { | |
var _this = this, _args = args || arguments; | |
setTimeout(function () { | |
fn.apply(_this, _args); | |
}, 0); | |
} | |
function once (fn, nextValue) { | |
var result, hasNextValue = arguments.length > 1; | |
return function () { | |
if( fn ) { | |
result = fn.apply(this, arguments); | |
fn = null; | |
return result; | |
} | |
return hasNextValue ? nextValue : result; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment