view on requirebin
Created
October 5, 2013 17:55
-
-
Save davidguttman/6844091 to your computer and use it in GitHub Desktop.
requirebin sketch
This file contains 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 through = require('through') | |
var streamVis = require('stream-vis') | |
// This is the readable stream | |
// "through" is a easy way of creating a readable (and writable) stream | |
var stream = through() | |
setInterval(function(){ | |
stream.emit('data', new Date) | |
}, 500) | |
// Create our transform stream | |
var transform = through(function(date) { | |
var r = date.valueOf()*10 % 255 | |
var g = date.valueOf()*20 % 255 | |
var b = date.valueOf()*30 % 255 | |
var colorString = [r,g,b].join(',') | |
this.emit('data', colorString) | |
}) | |
// Create our Writable Stream | |
var writeStream = createWriteDiv() | |
document.body.appendChild(writeStream.el) | |
// Pipe them together | |
stream.pipe(transform).pipe(writeStream) | |
// Modify our Writable Stream to handle date objects | |
function createWriteDiv () { | |
var el = document.createElement('div') | |
el.style.width = '200px' | |
el.style.height = '200px' | |
el.style.margin = '0 auto' | |
var stream = through(function(colorString) { | |
el.style.background = 'rgb('+ colorString +')' | |
}) | |
stream.el = el | |
return stream | |
} | |
// This just lets us visualize the stream | |
var w = window.innerWidth/8, | |
h = window.innerHeight/4, | |
x = window.innerWidth/4, | |
y = window.innerHeight/2 | |
var vis = streamVis(stream, {x:x,y:y,w:w,h:h}) | |
document.body.appendChild(vis.el) | |
document.body.style.textAlign = 'right' |
This file contains 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
function createWriteDiv(){var e=document.createElement("div");e.style.width="200px",e.style.height="200px",e.style.margin="0 auto";var t=through(function(t){e.style.background="rgb("+t+")"});return t.el=e,t}require=function(e,t,n){function r(n,o){if(!t[n]){if(!e[n]){var s="function"==typeof require&&require;if(!o&&s)return s(n,!0);if(i)return i(n,!0);throw Error("Cannot find module '"+n+"'")}var u=t[n]={exports:{}};e[n][0].call(u.exports,function(t){var i=e[n][1][t];return r(i?i:t)},u,u.exports)}return t[n].exports}for(var i="function"==typeof require&&require,o=0;n.length>o;o++)r(n[o]);return r}({through:[function(e,t){t.exports=e("kraIbE")},{}],1:[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")}},{}],kraIbE:[function(e,t,n){(function(r){function i(e,t,n){function i(){for(;c.length&&!p.paused;){var e=c.shift();if(null===e)return p.emit("end");p.emit("data",e)}}function s(){p.writable=!1,t.call(p),!p.readable&&p.autoDestroy&&p.destroy()}e=e||function(e){this.queue(e)},t=t||function(){this.queue(null)};var u=!1,a=!1,c=[],f=!1,p=new o;return p.readable=p.writable=!0,p.paused=!1,p.autoDestroy=!(n&&n.autoDestroy===!1),p.write=function(t){return e.call(this,t),!p.paused},p.queue=p.push=function(e){return f?p:(null==e&&(f=!0),c.push(e),i(),p)},p.on("end",function(){p.readable=!1,!p.writable&&p.autoDestroy&&r.nextTick(function(){p.destroy()})}),p.end=function(e){return u?void 0:(u=!0,arguments.length&&p.write(e),s(),p)},p.destroy=function(){return a?void 0:(a=!0,u=!0,c.length=0,p.writable=p.readable=!1,p.emit("close"),p)},p.pause=function(){return p.paused?void 0:(p.paused=!0,p)},p.resume=function(){return p.paused&&(p.paused=!1,p.emit("resume")),i(),p.paused||p.emit("drain"),p},p}var o=e("stream");n=t.exports=i,i.through=i})(e("__browserify_process"))},{stream:2,__browserify_process:1}],2:[function(e,t){function n(){r.EventEmitter.call(this)}var r=e("events"),i=e("util");i.inherits(n,r.EventEmitter),t.exports=n,n.Stream=n,n.prototype.pipe=function(e,t){function n(t){e.writable&&!1===e.write(t)&&a.pause&&a.pause()}function r(){a.readable&&a.resume&&a.resume()}function i(){c||(c=!0,e._pipeCount--,u(),e._pipeCount>0||e.end())}function o(){c||(c=!0,e._pipeCount--,u(),e._pipeCount>0||e.destroy())}function s(e){if(u(),0===this.listeners("error").length)throw e}function u(){a.removeListener("data",n),e.removeListener("drain",r),a.removeListener("end",i),a.removeListener("close",o),a.removeListener("error",s),e.removeListener("error",s),a.removeListener("end",u),a.removeListener("close",u),e.removeListener("end",u),e.removeListener("close",u)}var a=this;a.on("data",n),e.on("drain",r),e._isStdio||t&&t.end===!1||(e._pipeCount=e._pipeCount||0,e._pipeCount++,a.on("end",i),a.on("close",o));var c=!1;return a.on("error",s),e.on("error",s),a.on("end",u),a.on("close",u),e.on("end",u),e.on("close",u),e.emit("pipe",a),e}},{events:3,util:4}],3:[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)},o=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(),o=0,s=r.length;s>o;o++)r[o].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:o,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 o=t(r,n);if(0>o)return this;r.splice(o,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:1}],4:[function(e,t,n){function r(e){return e instanceof Array||Array.isArray(e)||e&&e!==Object.prototype&&r(e.__proto__)}function i(e){return e instanceof RegExp||"object"==typeof e&&"[object RegExp]"===Object.prototype.toString.call(e)}function o(e){if(e instanceof Date)return!0;if("object"!=typeof e)return!1;var t=Date.prototype&&u(Date.prototype),n=e.__proto__&&u(e.__proto__);return JSON.stringify(n)===JSON.stringify(t)}e("events"),n.isArray=r,n.isDate=function(e){return"[object Date]"===Object.prototype.toString.call(e)},n.isRegExp=function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},n.print=function(){},n.puts=function(){},n.debug=function(){},n.inspect=function(e,t,a,c){function f(e,a){if(e&&"function"==typeof e.inspect&&e!==n&&(!e.constructor||e.constructor.prototype!==e))return e.inspect(a);switch(typeof e){case"undefined":return l("undefined","undefined");case"string":var c="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return l(c,"string");case"number":return l(""+e,"number");case"boolean":return l(""+e,"boolean")}if(null===e)return l("null","null");var h=s(e),d=t?u(e):h;if("function"==typeof e&&0===d.length){if(i(e))return l(""+e,"regexp");var v=e.name?": "+e.name:"";return l("[Function"+v+"]","special")}if(o(e)&&0===d.length)return l(e.toUTCString(),"date");var y,g,m;if(r(e)?(g="Array",m=["[","]"]):(g="Object",m=["{","}"]),"function"==typeof e){var _=e.name?": "+e.name:"";y=i(e)?" "+e:" [Function"+_+"]"}else y="";if(o(e)&&(y=" "+e.toUTCString()),0===d.length)return m[0]+y+m[1];if(0>a)return i(e)?l(""+e,"regexp"):l("[Object]","special");p.push(e);var b=d.map(function(t){var n,i;if(e.__lookupGetter__&&(e.__lookupGetter__(t)?i=e.__lookupSetter__(t)?l("[Getter/Setter]","special"):l("[Getter]","special"):e.__lookupSetter__(t)&&(i=l("[Setter]","special"))),0>h.indexOf(t)&&(n="["+t+"]"),i||(0>p.indexOf(e[t])?(i=null===a?f(e[t]):f(e[t],a-1),i.indexOf("\n")>-1&&(i=r(e)?i.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+i.split("\n").map(function(e){return" "+e}).join("\n"))):i=l("[Circular]","special")),n===void 0){if("Array"===g&&t.match(/^\d+$/))return i;n=JSON.stringify(""+t),n.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(n=n.substr(1,n.length-2),n=l(n,"name")):(n=n.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),n=l(n,"string"))}return n+": "+i});p.pop();var w=0,x=b.reduce(function(e,t){return w++,t.indexOf("\n")>=0&&w++,e+t.length+1},0);return b=x>50?m[0]+(""===y?"":y+"\n ")+" "+b.join(",\n ")+" "+m[1]:m[0]+y+" "+b.join(", ")+" "+m[1]}var p=[],l=function(e,t){var n={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},r={special:"cyan",number:"blue","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[t];return r?"["+n[r][0]+"m"+e+"["+n[r][1]+"m":e};return c||(l=function(e){return e}),f(e,a===void 0?2:a)},n.log=function(){},n.pump=null;var s=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t},u=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.hasOwnProperty.call(e,n)&&t.push(n);return t},a=Object.create||function(e,t){var n;if(null===e)n={__proto__:null};else{if("object"!=typeof e)throw new TypeError("typeof prototype["+typeof e+"] != 'object'");var r=function(){};r.prototype=e,n=new r,n.__proto__=e}return t!==void 0&&Object.defineProperties&&Object.defineProperties(n,t),n};n.inherits=function(e,t){e.super_=t,e.prototype=a(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})};var c=/%[sdj%]/g;n.format=function(e){if("string"!=typeof e){for(var t=[],r=0;arguments.length>r;r++)t.push(n.inspect(arguments[r]));return t.join(" ")}for(var r=1,i=arguments,o=i.length,s=(e+"").replace(c,function(e){if("%%"===e)return"%";if(r>=o)return e;switch(e){case"%s":return i[r++]+"";case"%d":return Number(i[r++]);case"%j":return JSON.stringify(i[r++]);default:return e}}),u=i[r];o>r;u=i[++r])s+=null===u||"object"!=typeof u?" "+u:" "+n.inspect(u);return s}},{events:3}]},{},[]),require=function(e,t,n){function r(n,o){if(!t[n]){if(!e[n]){var s="function"==typeof require&&require;if(!o&&s)return s(n,!0);if(i)return i(n,!0);throw Error("Cannot find module '"+n+"'")}var u=t[n]={exports:{}};e[n][0].call(u.exports,function(t){var i=e[n][1][t];return r(i?i:t)},u,u.exports)}return t[n].exports}for(var i="function"==typeof require&&require,o=0;n.length>o;o++)r(n[o]);return r}({"stream-vis":[function(e,t){t.exports=e("RSNj0j")},{}],RSNj0j:[function(e,t){function n(e){var t=this;return e=e||{},e.x=e.x||100,e.y=e.y||100,e.w=e.w||50,e.h=e.h||50,e.r=e.r||0,e.g=e.g||100,e.b=e.b||100,e.a=e.a||1,e.bufferVisible=e.bufferVisible||!1,r(this,e),this.recentData=[],this.el=this.createElement(),this.bufferEl=this.createBufferElement(),this.el.appendChild(this.bufferEl),this.el.addEventListener("click",function(){t.toggleBufferDisplay()}),this.el.addEventListener("mouseenter",function(){t.showBuffer()}),this.el.addEventListener("mouseleave",function(){t.bufferVisible||t.hideBuffer()}),this}function r(e,t){for(var n in t)e[n]=t[n];return e}e("through"),t.exports=function(e,t){var r=new n(t);return e.on("data",function(e){r.onData(e)}),r},n.prototype.createElement=function(){var e=document.createElement("div"),t="rgba("+[this.r,this.g,this.b,this.a].join(",")+")",n={position:"absolute",left:this.x-this.w/2+"px",top:this.y-this.h/2+"px",width:this.w+"px",height:3*this.h/4+"px",background:t,borderRadius:this.w/4+"px",paddingTop:this.h/4+"px",textAlign:"center",fontFamily:"helvetica"};return r(e.style,n),e},n.prototype.createBufferElement=function(){var e=document.createElement("div"),t={position:"absolute",top:this.h+10+"px",background:"white",borderRadius:"20px",fontFamily:"helvetica",textAlign:"left",fontSize:"50%",color:"rgba(0,0,0,0.5)",display:"none"};return this.bufferVisible&&(t.display="block"),r(e.style,t),e},n.prototype.flash=function(){var e=100,t=25;this.isFlashing=!0;var n=this,r=this.el,i={r:200,g:200,b:50,a:this.a},o="rgba("+[i.r,i.g,i.b,i.a].join(",")+")",s="rgba("+[this.r,this.g,this.b,this.a].join(",")+")";this.el.style.background=o,setTimeout(function(){r.style.background=s},e),setTimeout(function(){n.isFlashing=!1},e+t)},n.prototype.onData=function(e){this.addData(e);var t=this.recentData.map(function(e){return JSON.stringify(e)}).join("<br />");this.bufferEl.innerHTML=t,this.isFlashing||this.flash(e)},n.prototype.addData=function(e){var t=10;for(this.recentData.push(e);this.recentData.length>t;)this.recentData.shift()},n.prototype.showBuffer=function(){this.bufferEl.style.display="block"},n.prototype.hideBuffer=function(){this.bufferEl.style.display="none"},n.prototype.toggleBufferDisplay=function(){return this.bufferVisible?(this.bufferVisible=!1,this.hideBuffer(),!1):(this.bufferVisible=!0,this.showBuffer(),!0)}},{through:1}],2:[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")}},{}],1:[function(e,t,n){(function(r){function i(e,t,n){function i(){for(;c.length&&!p.paused;){var e=c.shift();if(null===e)return p.emit("end");p.emit("data",e)}}function s(){p.writable=!1,t.call(p),!p.readable&&p.autoDestroy&&p.destroy()}e=e||function(e){this.queue(e)},t=t||function(){this.queue(null)};var u=!1,a=!1,c=[],f=!1,p=new o;return p.readable=p.writable=!0,p.paused=!1,p.autoDestroy=!(n&&n.autoDestroy===!1),p.write=function(t){return e.call(this,t),!p.paused},p.queue=p.push=function(e){return f?p:(null==e&&(f=!0),c.push(e),i(),p)},p.on("end",function(){p.readable=!1,!p.writable&&p.autoDestroy&&r.nextTick(function(){p.destroy()})}),p.end=function(e){return u?void 0:(u=!0,arguments.length&&p.write(e),s(),p)},p.destroy=function(){return a?void 0:(a=!0,u=!0,c.length=0,p.writable=p.readable=!1,p.emit("close"),p)},p.pause=function(){return p.paused?void 0:(p.paused=!0,p)},p.resume=function(){return p.paused&&(p.paused=!1,p.emit("resume")),i(),p.paused||p.emit("drain"),p},p}var o=e("stream");n=t.exports=i,i.through=i})(e("__browserify_process"))},{stream:3,__browserify_process:2}],3:[function(e,t){function n(){r.EventEmitter.call(this)}var r=e("events"),i=e("util");i.inherits(n,r.EventEmitter),t.exports=n,n.Stream=n,n.prototype.pipe=function(e,t){function n(t){e.writable&&!1===e.write(t)&&a.pause&&a.pause()}function r(){a.readable&&a.resume&&a.resume()}function i(){c||(c=!0,e._pipeCount--,u(),e._pipeCount>0||e.end())}function o(){c||(c=!0,e._pipeCount--,u(),e._pipeCount>0||e.destroy())}function s(e){if(u(),0===this.listeners("error").length)throw e}function u(){a.removeListener("data",n),e.removeListener("drain",r),a.removeListener("end",i),a.removeListener("close",o),a.removeListener("error",s),e.removeListener("error",s),a.removeListener("end",u),a.removeListener("close",u),e.removeListener("end",u),e.removeListener("close",u)}var a=this;a.on("data",n),e.on("drain",r),e._isStdio||t&&t.end===!1||(e._pipeCount=e._pipeCount||0,e._pipeCount++,a.on("end",i),a.on("close",o));var c=!1;return a.on("error",s),e.on("error",s),a.on("end",u),a.on("close",u),e.on("end",u),e.on("close",u),e.emit("pipe",a),e}},{events:4,util:5}],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)},o=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(),o=0,s=r.length;s>o;o++)r[o].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:o,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 o=t(r,n);if(0>o)return this;r.splice(o,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:2}],5:[function(e,t,n){function r(e){return e instanceof Array||Array.isArray(e)||e&&e!==Object.prototype&&r(e.__proto__)}function i(e){return e instanceof RegExp||"object"==typeof e&&"[object RegExp]"===Object.prototype.toString.call(e)}function o(e){if(e instanceof Date)return!0;if("object"!=typeof e)return!1;var t=Date.prototype&&u(Date.prototype),n=e.__proto__&&u(e.__proto__);return JSON.stringify(n)===JSON.stringify(t)}e("events"),n.isArray=r,n.isDate=function(e){return"[object Date]"===Object.prototype.toString.call(e)},n.isRegExp=function(e){return"[object RegExp]"===Object.prototype.toString.call(e)},n.print=function(){},n.puts=function(){},n.debug=function(){},n.inspect=function(e,t,a,c){function f(e,a){if(e&&"function"==typeof e.inspect&&e!==n&&(!e.constructor||e.constructor.prototype!==e))return e.inspect(a);switch(typeof e){case"undefined":return l("undefined","undefined");case"string":var c="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return l(c,"string");case"number":return l(""+e,"number");case"boolean":return l(""+e,"boolean")}if(null===e)return l("null","null");var h=s(e),d=t?u(e):h;if("function"==typeof e&&0===d.length){if(i(e))return l(""+e,"regexp");var v=e.name?": "+e.name:"";return l("[Function"+v+"]","special")}if(o(e)&&0===d.length)return l(e.toUTCString(),"date");var y,g,m;if(r(e)?(g="Array",m=["[","]"]):(g="Object",m=["{","}"]),"function"==typeof e){var _=e.name?": "+e.name:"";y=i(e)?" "+e:" [Function"+_+"]"}else y="";if(o(e)&&(y=" "+e.toUTCString()),0===d.length)return m[0]+y+m[1];if(0>a)return i(e)?l(""+e,"regexp"):l("[Object]","special");p.push(e);var b=d.map(function(t){var n,i;if(e.__lookupGetter__&&(e.__lookupGetter__(t)?i=e.__lookupSetter__(t)?l("[Getter/Setter]","special"):l("[Getter]","special"):e.__lookupSetter__(t)&&(i=l("[Setter]","special"))),0>h.indexOf(t)&&(n="["+t+"]"),i||(0>p.indexOf(e[t])?(i=null===a?f(e[t]):f(e[t],a-1),i.indexOf("\n")>-1&&(i=r(e)?i.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+i.split("\n").map(function(e){return" "+e}).join("\n"))):i=l("[Circular]","special")),n===void 0){if("Array"===g&&t.match(/^\d+$/))return i;n=JSON.stringify(""+t),n.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(n=n.substr(1,n.length-2),n=l(n,"name")):(n=n.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),n=l(n,"string"))}return n+": "+i});p.pop();var w=0,x=b.reduce(function(e,t){return w++,t.indexOf("\n")>=0&&w++,e+t.length+1},0);return b=x>50?m[0]+(""===y?"":y+"\n ")+" "+b.join(",\n ")+" "+m[1]:m[0]+y+" "+b.join(", ")+" "+m[1]}var p=[],l=function(e,t){var n={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},r={special:"cyan",number:"blue","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"}[t];return r?"["+n[r][0]+"m"+e+"["+n[r][1]+"m":e};return c||(l=function(e){return e}),f(e,a===void 0?2:a)},n.log=function(){},n.pump=null;var s=Object.keys||function(e){var t=[];for(var n in e)t.push(n);return t},u=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.hasOwnProperty.call(e,n)&&t.push(n);return t},a=Object.create||function(e,t){var n;if(null===e)n={__proto__:null};else{if("object"!=typeof e)throw new TypeError("typeof prototype["+typeof e+"] != 'object'");var r=function(){};r.prototype=e,n=new r,n.__proto__=e}return t!==void 0&&Object.defineProperties&&Object.defineProperties(n,t),n};n.inherits=function(e,t){e.super_=t,e.prototype=a(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})};var c=/%[sdj%]/g;n.format=function(e){if("string"!=typeof e){for(var t=[],r=0;arguments.length>r;r++)t.push(n.inspect(arguments[r]));return t.join(" ")}for(var r=1,i=arguments,o=i.length,s=(e+"").replace(c,function(e){if("%%"===e)return"%";if(r>=o)return e;switch(e){case"%s":return i[r++]+"";case"%d":return Number(i[r++]);case"%j":return JSON.stringify(i[r++]);default:return e}}),u=i[r];o>r;u=i[++r])s+=null===u||"object"!=typeof u?" "+u:" "+n.inspect(u);return s}},{events:4}]},{},[]);var through=require("through"),streamVis=require("stream-vis"),stream=through();setInterval(function(){stream.emit("data",new Date)},500);var transform=through(function(e){var t=10*e.valueOf()%255,n=20*e.valueOf()%255,r=30*e.valueOf()%255,i=[t,n,r].join(",");this.emit("data",i)}),writeStream=createWriteDiv();document.body.appendChild(writeStream.el),stream.pipe(transform).pipe(writeStream);var w=window.innerWidth/8,h=window.innerHeight/4,x=window.innerWidth/4,y=window.innerHeight/2,vis=streamVis(stream,{x:x,y:y,w:w,h:h});document.body.appendChild(vis.el),document.body.style.textAlign="right"; |
This file contains 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