Skip to content

Commit

Permalink
Optimise default types
Browse files Browse the repository at this point in the history
  • Loading branch information
timursevimli committed Aug 26, 2023
1 parent 093873b commit 1fe6562
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/throttle.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const throttle = (timeout, fn, ...args) => {
: (...pars) => (pars ? fn(...pars) : fn());

const delayed = (...pars) => {
timer = undefined;
timer = null;
if (wait) execute(...pars);
};

Expand All @@ -38,12 +38,15 @@ const throttle = (timeout, fn, ...args) => {
// fn - <Function>, to be debounced
// args - <Array>, arguments for fn, optional
const debounce = (timeout, fn, ...args) => {
let timer;
let timer = null

Check failure on line 41 in lib/throttle.js

View workflow job for this annotation

GitHub Actions / build (14, ubuntu-latest)

Insert `;`

Check failure on line 41 in lib/throttle.js

View workflow job for this annotation

GitHub Actions / build (16, ubuntu-latest)

Insert `;`

Check failure on line 41 in lib/throttle.js

View workflow job for this annotation

GitHub Actions / build (18, ubuntu-latest)

Insert `;`

Check failure on line 41 in lib/throttle.js

View workflow job for this annotation

GitHub Actions / build (18, macos-latest)

Insert `;`

Check failure on line 41 in lib/throttle.js

View workflow job for this annotation

GitHub Actions / build (19, ubuntu-latest)

Insert `;`

Check failure on line 41 in lib/throttle.js

View workflow job for this annotation

GitHub Actions / build (20, ubuntu-latest)

Insert `;`

const debounced = () => (args ? fn(...args) : fn());

const wrapped = () => {
if (timer) clearTimeout(timer);
if (timer) {
clearTimeout(timer);
timer = null;
}
timer = setTimeout(debounced, timeout);
};

Expand Down

0 comments on commit 1fe6562

Please sign in to comment.