mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-21 16:12:40 +08:00
no need to copy arguments for apply, see petkaantonov/bluebird#1389
This commit is contained in:
@@ -134,18 +134,14 @@ function debounce (func, wait, immediate) {
|
||||
if (callNow) func.apply(context, args);
|
||||
} : function () {
|
||||
var context = this;
|
||||
var args = new Array(arguments.length);
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
var later = function() {
|
||||
timeout = null;
|
||||
if (!immediate) func.apply(context, args);
|
||||
if (!immediate) func.apply(context, arguments);
|
||||
};
|
||||
var callNow = immediate && !timeout;
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(later, wait);
|
||||
if (callNow) func.apply(context, args);
|
||||
if (callNow) func.apply(context, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -47,18 +47,14 @@ function debounce (func, wait, immediate) {
|
||||
if (callNow) func.apply(context, args);
|
||||
} : function () {
|
||||
var context = this;
|
||||
var args = new Array(arguments.length);
|
||||
for (var i = 0; i < arguments.length; i++) {
|
||||
args[i] = arguments[i];
|
||||
}
|
||||
var later = function() {
|
||||
timeout = null;
|
||||
if (!immediate) func.apply(context, args);
|
||||
if (!immediate) func.apply(context, arguments);
|
||||
};
|
||||
var callNow = immediate && !timeout;
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(later, wait);
|
||||
if (callNow) func.apply(context, args);
|
||||
if (callNow) func.apply(context, arguments);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user