Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eeaas

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eeaas

Easter eggs as a service

  • 1.0.19
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

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.

URLExposes
https://eeaas.herokuapp.com/eeaas.jswindow.Eeaas
https://eeaas.herokuapp.com/eeaas-snake.jswindow.EeaasSnake
https://eeaas.herokuapp.com/eeaas-nyancat.jswindow.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.

MethodDescription
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();

Keywords

FAQs

Package last updated on 29 Mar 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc