Skip to content

Commit

Permalink
Merge pull request #12 from EGAMAGZ/development
Browse files Browse the repository at this point in the history
Fixed unexpected behaviour when no duration is passed for an easter egg
  • Loading branch information
EGAMAGZ authored Aug 15, 2024
2 parents f2e1f57 + 2fa83de commit 096fb9f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@egamagz/paska-ovo",
"version": "1.0.6",
"version": "1.0.7",
"exports": "./mod.ts",
"lock": false,
"compilerOptions": {
Expand Down
13 changes: 5 additions & 8 deletions src/paska-ovo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import type { Callback, EasterEgg, EasterEggState } from "./types.ts";
import { codeToChars } from "./util/code.ts";
import { DEFAULT_DURATION } from "./util/constants.ts";
import { isInputElement } from "./util/dom.ts";

/**
Expand Down Expand Up @@ -162,14 +163,10 @@ export class PaskaOvo {
this.callbacks.forEach((callback) => callback(easterEgg));

if (easterEgg.onFinish) {
if (easterEgg.duration) {
setTimeout(
easterEgg.onFinish,
easterEgg.duration,
);
} else {
easterEgg.onFinish();
}
setTimeout(
easterEgg.onFinish,
easterEgg.duration || DEFAULT_DURATION,
);
}
} catch (error) {
console.error(`Error executing easter egg ${easterEgg.tag}:`, error);
Expand Down
2 changes: 2 additions & 0 deletions src/util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,5 @@ export const INPUT_ELEMENTS = [
"input",
"select",
];

export const DEFAULT_DURATION = 1_000;

0 comments on commit 096fb9f

Please sign in to comment.