Make _.defer use setImmediate if available.

Former-commit-id: b3898d78725a4b203856916b1b071ab9c6f40b83
This commit is contained in:
John-David Dalton
2013-02-17 14:29:40 -08:00
parent cb3b4e446e
commit 5133e39d45
8 changed files with 99 additions and 86 deletions

View File

@@ -3463,10 +3463,10 @@
* _.defer(function() { alert('deferred'); });
* // returns from the function before `alert` is called
*/
function defer(func) {
var defer = reNative.test(window.setImmediate) && bind(setImmediate, window) || function(func) {
var args = slice(arguments, 1);
return setTimeout(function() { func.apply(undefined, args); }, 1);
}
};
/**
* Creates a function that memoizes the result of `func`. If `resolver` is