New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

evie

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

evie

Extends EventEmitter-like classes

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-42.86%
Maintainers
1
Weekly downloads
 
Created
Source

Evie

Install

npm install evie

Using the provided class

{Evie} = require "evie"

events = new Evie()

Creating your own class with Evie as a mixin

{evie} = require "evie"

class MyEvents extends EventEmitter
  evie(@)

events = new MyEvents()

What Evie can do

Evie (and any class that has been evied) provides several useful methods, many of which rely on following a convention for the names of emitted events. For error conditions, emit an event named "error". For successes, emit "success".

events = new Evie()
if everything_wrong?
  events.emit "error", new Error "It is all wrong"
else
  events.emit "success", {everything: "ok"}

Other event names are certainly legal, but they are not used by the serially, concurrently, and wrap methods.

forward and source

The forward method relays all events from one instance to another. source creates a new instance and forwards all events from it to the caller. This allows events to bubble up through a tree, which can be useful in observing and handling errors at a single place in your system.

base = new Evie()
base.on "error", (error) -> console.error "We have a problem:", error

stuff = ->
  base.source (events) ->
    number = Date.now()
    if number % 7 == 0
      events.emit "error", new Error "Oh no, the time is divisible by seven!"
    else
      events.emit "success", number

e1 = stuff()
e1.on "success", (result) ->
  console.log "The time is #{result} and it is NOT divisible by 7"

e2 = stuff()
e2.on "success", (result) ->
  console.log "The time is STILL not divisible by 7."

wrap

serially

concurrently

FAQs

Package last updated on 18 Feb 2014

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