Skip to content

Commit

Permalink
fix(esl-utils): delayed-task now accept numeric string delay represen…
Browse files Browse the repository at this point in the history
…tation
  • Loading branch information
ala-n committed Aug 30, 2021
1 parent 5404156 commit d1122f4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/modules/esl-utils/async/delayed-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ export class DelayedTask {
* - pass 0 to plan task to the macrotask
* - pass positive number x to delay task on x ms.
* */
public put(task: AnyToVoidFnSignature, delay: number | boolean = false) {
public put(task: AnyToVoidFnSignature, delay: number | string | boolean = false) {
const prev = this.cancel();
if (typeof task === 'function') {
if (delay && typeof delay === 'string') delay = +delay;
if (typeof delay === 'number' && delay >= 0) {
this._fn = task;
this._timeout = window.setTimeout(this.run, delay);
Expand Down

0 comments on commit d1122f4

Please sign in to comment.