From 9c6de1eeec0eb5b0fe28b47224d5f0f2cd0ae8f6 Mon Sep 17 00:00:00 2001 From: Gamaliel Garcia <46827955+EGAMAGZ@users.noreply.github.com> Date: Sun, 5 May 2024 19:25:05 -0600 Subject: [PATCH 1/2] doc: Updated documentation --- README.md | 70 ++++++++++++++++++++++++++++-------------------- src/paska-ovo.ts | 49 ++++++++++++++++++++++++++++++++- src/types.ts | 2 +- 3 files changed, 90 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 0e15d76..a84a59c 100644 --- a/README.md +++ b/README.md @@ -38,33 +38,46 @@ Check the [JSR page for more details](https://jsr.io/@egamagz/paska-ovo). import { HistoricalCodes, PaskaOvo } from "@egamagz/paska-ovo"; const paskaOvo = new PaskaOvo() - .addCallback((easterEgg) => { - console.log("Actual easter egg:", easterEgg.tag); - console.log("Easter egg's code:", easterEgg.code); + .addCode({ + code: HistoricalCodes.BarrelRoll, + onFound: () => { + //... + }, + onFinish() { + // ... + }, + duration: 1000, + tag: "Barrel Roll" }) - .addCode( - HistoricalCodes.Iddqd, - () => { - alert("God Mode"); + .addCode({ + code: HistoricalCodes.Konami, + onFound: () => { + // ... }, - "Doom", - ) - .addCode("left,up,right,down", () => { - alert("Do a Barrel Roll"); - }, "Barrel Roll"); + tag: "Konami" + }) + .addCode({ + code: ["a", "w", "e", "s", "o", "m", "e"], + onFound: () => { + // ... + }, + tag: "Awesome" + }) + .addCallback((easterEgg) => { + alert(`You found the easter egg: ${easterEgg.tag}`) + }); // Listen to keyboard events -document.getElementById("add-easter-egg") - .addEventListener("click", () => { - paskaOvo.listen(); - }); +document.getElementById("add-easter-egg").addEventListener("click", () => { + paskaOvo.listen(); +}); // Stop listening to keyboard events -document.getElementById("remove-easter-egg") +document + .getElementById("remove-easter-egg") .addEventListener("click", () => { paskaOvo.stop(); }); - ``` Alternatively, it's possible to define the easter egg using the constructor: @@ -72,19 +85,18 @@ Alternatively, it's possible to define the easter egg using the constructor: ```typescript import { HistoricalCodes, PaskaOvo } from "@egamagz/paska-ovo"; -const paskaOvo = new PaskaOvo( - HistoricalCodes.Konami, - () => { - alert("Gradius"); + const paskaOvo = new PaskaOvo({ + code: HistoricalCodes.Konami, + onFound: () => { + alert("Gradius"); }, - "konami-code", -) - .addCallback((easterEgg) => { - console.log("Actual easter egg:", easterEgg.tag); - console.log("Easter egg's code:", easterEgg.code); - }); + tag: "konami-code", + }).addCallback((easterEgg) => { + console.log("Actual easter egg:", easterEgg.tag); + console.log("Easter egg's code:", easterEgg.code); + }); -paskaOvo.listen(); + paskaOvo.listen(); ``` Check the [example](https://egamagz.github.io/paska-ovo/) with [source code](https://github.com/EGAMAGZ/paska-ovo/tree/master/example). diff --git a/src/paska-ovo.ts b/src/paska-ovo.ts index 8182d01..9cde53e 100644 --- a/src/paska-ovo.ts +++ b/src/paska-ovo.ts @@ -10,7 +10,54 @@ import { codeToChars } from "./util/code.ts"; /** * Class that is used to manage easter eggs. - */ + * + * @example + * ```typescript + * import { HistoricalCodes, PaskaOvo } from "@egamagz/paska-ovo"; + * + * const paskaOvo = new PaskaOvo() + * .addCode({ + * code: HistoricalCodes.BarrelRoll, + * onFound: () => { + * //... + * }, + * onFinish() { + * // ... + * }, + * duration: 1000, + * tag: "Barrel Roll" + * }) + * .addCode({ + * code: HistoricalCodes.Konami, + * onFound: () => { + * // ... + * }, + * tag: "Konami" + * }) + * .addCode({ + * code: ["a", "w", "e", "s", "o", "m", "e"], + * onFound: () => { + * // ... + * }, + * tag: "Awesome" + * }) + * .addCallback((easterEgg) => { + * alert(`You found the easter egg: ${easterEgg.tag}`) + * }); + * + * // Listen to keyboard events + * document.getElementById("add-easter-egg").addEventListener("click", () => { + * paskaOvo.listen(); + * }); + * + * // Stop listening to keyboard events + * document + * .getElementById("remove-easter-egg") + * .addEventListener("click", () => { + * paskaOvo.stop(); + * }); + *``` + * */ export class PaskaOvo { /** * List of easter eggs registered. diff --git a/src/types.ts b/src/types.ts index 1f82104..5e6ef4e 100644 --- a/src/types.ts +++ b/src/types.ts @@ -27,7 +27,7 @@ export type EasterEgg = { * */ onFinish?: () => void, /** - * Duration of the easter egg. Once it is finished, onFinish will be called. + * Duration in milliseconds of the easter egg. Once it is finished, onFinish will be called. * */ duration?: number, }; From 7d9eacc277bb95bdd96b3083c1f11a1f296e7987 Mon Sep 17 00:00:00 2001 From: Gamaliel Garcia <46827955+EGAMAGZ@users.noreply.github.com> Date: Sun, 5 May 2024 19:26:13 -0600 Subject: [PATCH 2/2] feat: updated version --- deno.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deno.json b/deno.json index d56d166..f4c533d 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@egamagz/paska-ovo", - "version": "1.0.0", + "version": "1.0.1", "exports": "./mod.ts", "lock": false, "compilerOptions": {