Skip to content

Commit

Permalink
Avoid Array.fill
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpschaaf committed Feb 27, 2019
1 parent f4df466 commit 7485a60
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions test/unit/debounce.html
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,22 @@
const timeoutCallback = sinon.spy(() => actualCallbacks.push(timeoutCallback));
Polymer.enqueueDebouncer(Polymer.Debouncer.debounce(null, Polymer.Async.timeOut, timeoutCallback));
// Set of short-running debouncers enqueued in the middle of first set
const nestedCallbacks = new Array(150).fill().map((_, i) => sinon.spy(() =>
actualCallbacks.push(nestedCallbacks[i])));
const nestedCallbacks = [];
for (let i=0; i<150; i++) {
nestedCallbacks.push(sinon.spy(() =>
actualCallbacks.push(nestedCallbacks[i])));
}
// First set of short-running debouncers
const microtaskCallbacks = new Array(150).fill().map((_, i) => sinon.spy(() => {
actualCallbacks.push(microtaskCallbacks[i]);
if (i === 125) {
nestedCallbacks.forEach(cb =>
Polymer.enqueueDebouncer(Polymer.Debouncer.debounce(null, Polymer.Async.microTask, cb)));
}
}));
const microtaskCallbacks = [];
for (let i=0; i<150; i++) {
microtaskCallbacks.push(sinon.spy(() => {
actualCallbacks.push(microtaskCallbacks[i]);
if (i === 125) {
nestedCallbacks.forEach(cb =>
Polymer.enqueueDebouncer(Polymer.Debouncer.debounce(null, Polymer.Async.microTask, cb)));
}
}));
}
microtaskCallbacks.forEach(cb =>
Polymer.enqueueDebouncer(Polymer.Debouncer.debounce(null, Polymer.Async.microTask, cb)));
// Expect short before long
Expand Down

0 comments on commit 7485a60

Please sign in to comment.