npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

eeaas

v1.0.19

Published

Easter eggs as a service

Downloads

11

Readme

Easter eggs as a service

This utility creates a very basic skeleton with which easter eggs can be injected into apps or websites running JavaScript.

Use at own risk.

Demo

Basic installation

yarn add eeaas

Once installed you can import the utility and start creating your own easter eggs.

Installing default eggs

yarn add eeaas-snake
yarn add eeaas-nyancat

Using eeaas

import Eeaas from 'eeaas';
import Snake from 'eeaas-snake';
import Nyancat from 'eeaas-nyancat';

// Register the eggs, only registered eggs can be activated
Eeaas.register(Snake);
Eeaas.register(Nyancat);

// Enable all keylisteners (start triggers) for all eggs
Eeaas.enable();

That's about it. Once enabled, all eggs will listen until triggered. In this example, if you included snake and nyancat, you can test out the easter eggs by typing "snake" and "nyan" respectively to trigger them (use "esc" to cancel the easter eggs).

As a service

Alternatively you can do quick and dirty calls to the following endpoints to achieve the same result as above.

URL | Exposes -------------------------------------------- | ------------------- https://eeaas.herokuapp.com/eeaas.js | window.Eeaas https://eeaas.herokuapp.com/eeaas-snake.js | window.EeaasSnake https://eeaas.herokuapp.com/eeaas-nyancat.js | window.EeaasNyancat

<script src="https://eeaas.herokuapp.com/eeaas.js"></script>
<script src="https://eeaas.herokuapp.com/eeaas-snake.js"></script>
<script src="https://eeaas.herokuapp.com/eeaas-nyancat.js"></script>
<script>
  window.Eeaas.register(window.EeaasSnake);
  window.Eeaas.register(window.EeaasNyancat);
  window.Eeaas.enable();
</script>

How does eeaas work?

At its core eeaas provides a key listener and a basic event handler for adding and removing key listeners (or start triggers). Eeaas is not limited to key listeners. Any logic to trigger an easter egg can be used.

Importing eeaas won't add any easter eggs to your app/website. You'll have to write your own or import the default eggs to get started.

To make an egg available it has to be registered with eeaas. You can do so by running Eeaas.register(MyEgg), where MyEgg refers to an object. Once the egg is registered you can enable the egg by running Eeaas.enable(). You can also individually enable or disable eggs by calling the enable() or disable methods explicitly on the egg itself, e.g. Eeaas.Eggs.MyEgg.enable() or Eeaas.Eggs.MyEgg.disable().

If you provided a startTrigger which is a string then typing the keys in the provided startTrigger will call the egg's start method. The enable() and disable() methods are safety wrappers which ensure that the eggs are only ever triggerable when the eggs themselves are "enabled".

If an egg is disabled it will be available but won't be triggereable via the startTrigger. You can always manually trigger eggs via the code. So even if an egg is disabled, calling Eeaas.Eggs.MyEgg.start() will run the egg.

Building your own egg

export default {
  name: 'MyEgg', // Required, this name is used as the namespace for the easter egg

  startTrigger: 'secretstring', // Required, must be as string, an array of strings or a function

  stopTrigger: 'esc', // Optional, must be a string, an array of strings or a function

  start() { ... }, // Required, contains all logic for the easter egg and attaches necessary elements to the DOM

  stop() { ... } // Optional, contains logic to remove the easter egg functionality and the attached DOM elements
};

Eeaas methods

Eeaas comes with 3 built-in methods. These methods are mainly used to add, enable and disable easter eggs.

Method | Description ------------ | ------------------------------------------------------------------------------------------------------------ register() | Used to add easter eggs to the eeaas container. enable() | Used to add the keylisteners (start triggers) for all easter eggs. Can also be used on eggs individually. disable() | Used to remove the keylisteners (start triggers) for all easter eggs. Can also be used on eggs individually.

Example:

import Eeaas from 'eeaas';
import Snake from 'eeaas-snake';
import Nyancat from 'eeaas-nyancat';

Eeaas.register(Snake);
Eeaas.register(Nyancat);

// Only enable "Snake"
Eeaas.Eggs.Snake.enable();

// Enable all eggs
Eeaas.enable();

// Disable "Snake"
Eeaas.Eggs.Snake.disable();

// Disable all eggs
Eeaas.disable();