Skip to content

Commit

Permalink
Merge pull request #1021 from wincent/lint/n+13
Browse files Browse the repository at this point in the history
Fix 2 lints in core/debounce.js
  • Loading branch information
julien authored Jan 29, 2019
2 parents 5eee1d4 + c423495 commit 387ec57
Showing 1 changed file with 5 additions and 15 deletions.
20 changes: 5 additions & 15 deletions src/core/debounce.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,18 @@
*/
CKEDITOR.tools.debounce =
CKEDITOR.tools.debounce ||
function(callback, timeout, context, args) {
function(callback, timeout, context, args = []) {
let debounceHandle;

let callFn = function() {
let callFn = function(...callArgs) {
/* eslint-disable babel/no-invalid-this */
let callContext = context || this;
/* eslint-enable babel/no-invalid-this */

clearTimeout(debounceHandle);

let result = [];

for (
let len = arguments.length, startIndex = 0;
startIndex < len;
++startIndex
) {
result.push(arguments[startIndex]);
}

let callArgs = result.concat(args || []);

debounceHandle = setTimeout(function() {
callback.apply(callContext, callArgs);
callback.apply(callContext, [...callArgs, ...args]);
}, timeout);
};

Expand Down

0 comments on commit 387ec57

Please sign in to comment.