Skip to content

Commit 096fb9f

Browse files
authored
Merge pull request #12 from EGAMAGZ/development
Fixed unexpected behaviour when no duration is passed for an easter egg
2 parents f2e1f57 + 2fa83de commit 096fb9f

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

deno.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@egamagz/paska-ovo",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"exports": "./mod.ts",
55
"lock": false,
66
"compilerOptions": {

src/paska-ovo.ts

+5-8
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import type { Callback, EasterEgg, EasterEggState } from "./types.ts";
99
import { codeToChars } from "./util/code.ts";
10+
import { DEFAULT_DURATION } from "./util/constants.ts";
1011
import { isInputElement } from "./util/dom.ts";
1112

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

164165
if (easterEgg.onFinish) {
165-
if (easterEgg.duration) {
166-
setTimeout(
167-
easterEgg.onFinish,
168-
easterEgg.duration,
169-
);
170-
} else {
171-
easterEgg.onFinish();
172-
}
166+
setTimeout(
167+
easterEgg.onFinish,
168+
easterEgg.duration || DEFAULT_DURATION,
169+
);
173170
}
174171
} catch (error) {
175172
console.error(`Error executing easter egg ${easterEgg.tag}:`, error);

src/util/constants.ts

+2
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,5 @@ export const INPUT_ELEMENTS = [
3030
"input",
3131
"select",
3232
];
33+
34+
export const DEFAULT_DURATION = 1_000;

0 commit comments

Comments
 (0)