From 183adc1ceb497c1ee1b5afbff85c16b5fe44fddb Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Mon, 8 Oct 2012 17:02:54 -0700 Subject: [PATCH] docs --- Readme.md | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/Readme.md b/Readme.md index 8f5ffd6..134d6c0 100644 --- a/Readme.md +++ b/Readme.md @@ -14,11 +14,30 @@ $ component install component/emitter The `Emitter` may also be used as a mixin. For example a "plain" object may become an emitter, or you may - extend an existing prototype: + extend an existing prototype. + + As an `Emitter` instance: + +```js +var Emitter = require('emitter'); +var emitter = new Emitter; +emitter.emit('something'); +``` + + As a mixin: + +```js +var Emitter = require('emitter'); +var user = { name: 'tobi' }; +Emitter(user); + +user.emit('im a user'); +``` + + As a prototype mixin: ```js -var obj = {}; -Emitter(obj); +var Emitter = require('emitter'); Emitter(User.prototype); ```