Skip to content

Commit

Permalink
Delay as optional arg
Browse files Browse the repository at this point in the history
  • Loading branch information
craigbeck committed Oct 17, 2023
1 parent c7a9902 commit ec4f389
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export abstract class Component<T = object> extends Controller<T> {
//
// Like component.bind(), will no longer call back once the component is
// destroyed, which avoids possible bugs and memory leaks.
debounce<F extends AnyVoidFunction>(callback: (...args: Parameters<F>) => void, delay: number): (...args: Parameters<F>) => void {
debounce<F extends AnyVoidFunction>(callback: (...args: Parameters<F>) => void, delay?: number): (...args: Parameters<F>) => void {
delay = delay || 0;
if (typeof delay !== 'number') {
throw new Error('Second argument must be a number');
Expand Down Expand Up @@ -267,7 +267,7 @@ export abstract class Component<T = object> extends Controller<T> {
//
// Like component.bind(), will no longer call back once the component is
// destroyed, which avoids possible bugs and memory leaks.
debounceAsync<F extends AnyVoidFunction>(callback: (...args: Parameters<F>) => void, delay: number = 0): (...args: Parameters<F>) => void {
debounceAsync<F extends AnyVoidFunction>(callback: (...args: Parameters<F>) => void, delay?: number): (...args: Parameters<F>) => void {
const applyArguments = callback.length !== 1;
delay = delay || 0;
if (typeof delay !== 'number') {
Expand Down

0 comments on commit ec4f389

Please sign in to comment.