96
97
return function (this: any, ...args: any[]) {
99
>
this[resultKey] = initialValueProvider ? initialValueProvider() : undefined;
100
>
}
101
>
if (this[lastRunKey] === null || this[lastRunKey] === undefined) {
102
>
this[lastRunKey] = -Number.MAX_VALUE;
103
>
}
104
>
105
>
if (reducer) {
106
this[resultKey] = reducer(this[resultKey], ...args);
107
}
109
>
if (this[pendingKey]) {
110
return;
111
}
113
>
const nextTime = this[lastRunKey] + delay;
114
>
if (nextTime <= Date.now()) {
115
>
this[lastRunKey] = Date.now();
116
>
fn.apply(this, [this[resultKey]]);
117
>
this[resultKey] = initialValueProvider ? initialValueProvider() : undefined;
118
>
} else {
119
this[pendingKey] = true;
120
this[timerKey] = setTimeout(() => {