Skip to content

Assign event listeners through a `on<event>` methods. Great for stubbing DOM API's

License

Notifications You must be signed in to change notification settings

unshiftio/eventstub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

eventstub

Made by unshiftVersion npmBuild StatusDependenciesCoverage StatusIRC channel

Install

This module is published in the public npm registry and can be installed using:

npm install --save eventstub

Usage

The exported function by the module accepts one argument, an array or comma/space separated list of methods that should add event listeners for the given method name. The methods that are added are automatically prefixed with on.

'use strict';

var eventstub = require('eventstub')
  , stub = eventstub('message, error, timeout');

stub.onmessage = function message(one, two, four, five, six) {
  // this will acutally be transformed as `stub.on('message', function ..)`
};

stub.emit('message', 1, 2, 4, 5, 6);

If you add another onmessage handler we will automatically kill all previously assigned handlers so your onmessage handler is the only event listener.

License

MIT

About

Assign event listeners through a `on<event>` methods. Great for stubbing DOM API's

Resources

License

Stars

Watchers

Forks

Packages

No packages published