view on requirebin
Created
October 17, 2013 19:45
-
-
Save kumavis/7031031 to your computer and use it in GitHub Desktop.
requirebin sketch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var WTChannel = require('walkietalkie') | |
var team = WTChannel() | |
var shaggy = team.WalkieTalkie() | |
var scooby = team.WalkieTalkie() | |
var daphne = team.WalkieTalkie() | |
var fred = team.WalkieTalkie() | |
var velma = team.WalkieTalkie() | |
shaggy.on('ruh-oh',function() { | |
alert('zoinks!') | |
}) | |
scooby.emit('ruh-oh') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require=function(e,t,n){function r(n,s){if(!t[n]){if(!e[n]){var o="function"==typeof require&&require;if(!s&&o)return o(n,!0);if(i)return i(n,!0);throw Error("Cannot find module '"+n+"'")}var a=t[n]={exports:{}};e[n][0].call(a.exports,function(t){var i=e[n][1][t];return r(i?i:t)},a,a.exports)}return t[n].exports}for(var i="function"==typeof require&&require,s=0;n.length>s;s++)r(n[s]);return r}({walkietalkie:[function(e,t){t.exports=e("uEXKnY")},{}],uEXKnY:[function(e,t){var n=e("./lib/channel.js");t.exports=function(){return new n}},{"./lib/channel.js":1}],1:[function(e,t){function n(e){return this instanceof n?(this._initialize(e),void 0):new n(e)}function r(e,t){var n=t.indexOf(e);-1!==n&&t.splice(n,1)}var i=e("./walkietalkie.js");t.exports=n,n.prototype.WalkieTalkie=function(){var e=this,t=new i(e);return e.subscribers.push(t),t},n.prototype._initialize=function(){var e=this;e.subscribers=[]},n.prototype._emit=function(e,t){var n=this;n.subscribers.map(function(n){if(n!==e){var r=n.emitter;r.emit.apply(r,t)}})},n.prototype._unsubscribe=function(e){var t=this;-1===t.subscribers.indexOf(e)&&(r(e,t.subscribers),e.destroy())}},{"./walkietalkie.js":2}],3:[function(e,t){var n=t.exports={};n.nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};if(t){var n=[];return window.addEventListener("message",function(e){if(e.source===window&&"process-tick"===e.data&&(e.stopPropagation(),n.length>0)){var t=n.shift();t()}},!0),function(e){n.push(e),window.postMessage("process-tick","*")}}return function(e){setTimeout(e,0)}}(),n.title="browser",n.browser=!0,n.env={},n.argv=[],n.binding=function(){throw Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(){throw Error("process.chdir is not supported")}},{}],4:[function(e,t,n){(function(e){function t(e,t){if(e.indexOf)return e.indexOf(t);for(var n=0;e.length>n;n++)if(t===e[n])return n;return-1}e.EventEmitter||(e.EventEmitter=function(){});var r=n.EventEmitter=e.EventEmitter,i="function"==typeof Array.isArray?Array.isArray:function(e){return"[object Array]"===Object.prototype.toString.call(e)},s=10;r.prototype.setMaxListeners=function(e){this._events||(this._events={}),this._events.maxListeners=e},r.prototype.emit=function(e){if("error"===e&&(!this._events||!this._events.error||i(this._events.error)&&!this._events.error.length))throw arguments[1]instanceof Error?arguments[1]:Error("Uncaught, unspecified 'error' event.");if(!this._events)return!1;var t=this._events[e];if(!t)return!1;if("function"==typeof t){switch(arguments.length){case 1:t.call(this);break;case 2:t.call(this,arguments[1]);break;case 3:t.call(this,arguments[1],arguments[2]);break;default:var n=Array.prototype.slice.call(arguments,1);t.apply(this,n)}return!0}if(i(t)){for(var n=Array.prototype.slice.call(arguments,1),r=t.slice(),s=0,o=r.length;o>s;s++)r[s].apply(this,n);return!0}return!1},r.prototype.addListener=function(e,t){if("function"!=typeof t)throw Error("addListener only takes instances of Function");if(this._events||(this._events={}),this.emit("newListener",e,t),this._events[e])if(i(this._events[e])){if(!this._events[e].warned){var n;n=void 0!==this._events.maxListeners?this._events.maxListeners:s,n&&n>0&&this._events[e].length>n&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),console.trace())}this._events[e].push(t)}else this._events[e]=[this._events[e],t];else this._events[e]=t;return this},r.prototype.on=r.prototype.addListener,r.prototype.once=function(e,t){var n=this;return n.on(e,function r(){n.removeListener(e,r),t.apply(this,arguments)}),this},r.prototype.removeListener=function(e,n){if("function"!=typeof n)throw Error("removeListener only takes instances of Function");if(!this._events||!this._events[e])return this;var r=this._events[e];if(i(r)){var s=t(r,n);if(0>s)return this;r.splice(s,1),0==r.length&&delete this._events[e]}else this._events[e]===n&&delete this._events[e];return this},r.prototype.removeAllListeners=function(e){return 0===arguments.length?(this._events={},this):(e&&this._events&&this._events[e]&&(this._events[e]=null),this)},r.prototype.listeners=function(e){return this._events||(this._events={}),this._events[e]||(this._events[e]=[]),i(this._events[e])||(this._events[e]=[this._events[e]]),this._events[e]}})(e("__browserify_process"))},{__browserify_process:3}],2:[function(e,t){function n(e){return this instanceof n?(this._initialize(e),void 0):new n(e)}e("extend");var r=e("events").EventEmitter;t.exports=n,n.prototype.emit=function(){var e=this;e.channel._emit(e,arguments)},n.prototype.on=function(){var e=this,t=e.emitter;t.on.apply(t,arguments)},n.prototype.destroy=function(){var e=this;e.emitter&&delete e.emitter,e.channel._unsubscribe(e)},n.prototype._initialize=function(e){var t=this;t.channel=e,t.emitter=new r}},{events:4,extend:5}],5:[function(e,t){function n(e){if(!e||"[object Object]"!==i.call(e)||e.nodeType||e.setInterval)return!1;var t=r.call(e,"constructor"),n=r.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!t&&!n)return!1;var s;for(s in e);return void 0===s||r.call(e,s)}var r=Object.prototype.hasOwnProperty,i=Object.prototype.toString;t.exports=function s(){var e,t,r,i,o,a,u=arguments[0]||{},c=1,f=arguments.length,h=!1;for("boolean"==typeof u&&(h=u,u=arguments[1]||{},c=2),"object"!=typeof u&&"function"!=typeof u&&(u={});f>c;c++)if(null!=(e=arguments[c]))for(t in e)r=u[t],i=e[t],u!==i&&(h&&i&&(n(i)||(o=Array.isArray(i)))?(o?(o=!1,a=r&&Array.isArray(r)?r:[]):a=r&&n(r)?r:{},u[t]=s(h,a,i)):void 0!==i&&(u[t]=i));return u}},{}]},{},[]);var WTChannel=require("walkietalkie"),team=WTChannel(),shaggy=team.WalkieTalkie(),scooby=team.WalkieTalkie(),daphne=team.WalkieTalkie(),fred=team.WalkieTalkie(),velma=team.WalkieTalkie();shaggy.on("ruh-oh",function(){alert("zoinks!")}),scooby.emit("ruh-oh"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<style type='text/css'>html, body { margin: 0; padding: 0; border: 0; } | |
body, html { height: 100%; width: 100%; }</style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment