Skip to content

Instantly share code, notes, and snippets.

@maxogden

maxogden/index.js

Created Mar 4, 2014
Embed
What would you like to do?
requirebin sketch
require('console-log').show(true)
console.log('hello!')
require=function e(t,n,r){function i(s,u){if(!n[s]){if(!t[s]){var a="function"==typeof require&&require;if(!u&&a)return a(s,!0);if(o)return o(s,!0);throw Error("Cannot find module '"+s+"'")}var c=n[s]={exports:{}};t[s][0].call(c.exports,function(e){var n=t[s][1][e];return i(n?n:e)},c,c.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;r.length>s;s++)i(r[s]);return i}({M5YfgZ:[function(e,t){function n(e){var t=console[e];console[e]=function(){var e=[].slice.call(arguments);s.write(e),t.apply(console,e)}}var r=e("./widget"),i=e("observable"),o=e("hyperscript");"undefined"==typeof console&&(globals.console={},console.log=function(){},console.error=function(){});var s=r({style:{height:"400px",width:"200px","border-bottom":"1px dotted black"}});n("log"),n("error"),window.addEventListener("error",function(e){s.write([e.stack])}),document.body.appendChild(o("div",{style:{background:"white",border:"1px solid black",position:"fixed",right:"20px",bottom:"20px"}},s.element,o("div",i.boolean(s.show,">","<"),{onclick:function(){s.show(!s.show())}},{style:{margin:"10px","min-width":"20px","min-height":"20px","text-align":"center"}}))),s.show(!1),t.exports=s},{"./widget":12,hyperscript:3,observable:11}],"console-log":[function(e,t){t.exports=e("M5YfgZ")},{}],3:[function(e,t){function n(){function e(t){function c(e){var t=s(e,/([\.#]?[a-zA-Z0-9_-]+)/);i(t,function(e){var t=e.substring(1,e.length);e&&(n?"."===e[0]?u(n).add(t):"#"===e[0]&&n.setAttribute("id",t):n=document.createElement(e))})}var l;if(null==t);else if("string"==typeof t)n?n.appendChild(l=document.createTextNode(t)):c(t);else if("number"==typeof t||"boolean"==typeof t||t instanceof Date||t instanceof RegExp)n.appendChild(l=document.createTextNode(""+t));else if(o(t))i(t,e);else if(r(t))n.appendChild(l=t);else if(t instanceof Text)n.appendChild(l=t);else if("object"==typeof t)for(var f in t)if("function"==typeof t[f])/^on\w+/.test(f)?n.addEventListener?n.addEventListener(f.substring(2),t[f]):n.attachEvent(f,t[f]):(n[f]=t[f](),t[f](function(e){n[f]=e}));else if("style"===f)for(var h in t[f])(function(e,r){"function"==typeof r?(n.style.setProperty(e,r()),r(function(t){n.style.setProperty(e,t)})):n.style.setProperty(e,t[f][e])})(h,t[f][h]);else"data-"===f.substr(0,5)?a(n)[f.substr(5)]=t[f]:n[f]=t[f];else if("function"==typeof t){var p=t();n.appendChild(l=r(p)?p:document.createTextNode(p)),t(function(e){r(e)&&l.parentElement?(l.parentElement.replaceChild(e,l),l=e):l.textContent=e})}return l}for(var t=[].slice.call(arguments),n=null;t.length;)e(t.shift());return n}function r(e){return e&&e.nodeName&&e.nodeType}function i(e,t){if(e.forEach)return e.forEach(t);for(var n=0;e.length>n;n++)t(e[n],n)}function o(e){return"[object Array]"==Object.prototype.toString.call(e)}var s=e("browser-split"),u=e("class-list"),a=e("data-set");t.exports=n},{"browser-split":4,"class-list":5,"data-set":7}],4:[function(e,t){t.exports=function(e){var t,n=String.prototype.split,r=/()??/.exec("")[1]===e;return t=function(t,i,o){if("[object RegExp]"!==Object.prototype.toString.call(i))return n.call(t,i,o);var s,u,a,c,l=[],f=(i.ignoreCase?"i":"")+(i.multiline?"m":"")+(i.extended?"x":"")+(i.sticky?"y":""),h=0,i=RegExp(i.source,f+"g");for(t+="",r||(s=RegExp("^"+i.source+"$(?!\\s)",f)),o=o===e?-1>>>0:o>>>0;(u=i.exec(t))&&(a=u.index+u[0].length,!(a>h&&(l.push(t.slice(h,u.index)),!r&&u.length>1&&u[0].replace(s,function(){for(var t=1;arguments.length-2>t;t++)arguments[t]===e&&(u[t]=e)}),u.length>1&&u.index<t.length&&Array.prototype.push.apply(l,u.slice(1)),c=u[0].length,h=a,l.length>=o)));)i.lastIndex===u.index&&i.lastIndex++;return h===t.length?(c||!i.test(""))&&l.push(""):l.push(t.slice(h)),l.length>o?l.slice(0,o):l}}()},{}],5:[function(e,t){function n(e){function t(e){var t=l();o(t,e)>-1||(t.push(e),f(t))}function n(e){var t=l(),n=o(t,e);-1!==n&&(t.splice(n,1),f(t))}function s(e){return o(l(),e)>-1}function u(e){return s(e)?(n(e),!1):(t(e),!0)}function a(){return e.className}function c(e){var t=l();return t[e]||null}function l(){var t=e.className;return r(t.split(" "),i)}function f(t){var n=t.length;e.className=t.join(" "),p.length=n;for(var r=0;t.length>r;r++)p[r]=t[r];delete t[n]}var h=e.classList;if(h)return h;var p={add:t,remove:n,contains:s,toggle:u,toString:a,length:0,item:c};return p}function r(e,t){for(var n=[],r=0;e.length>r;r++)t(e[r])&&n.push(e[r]);return n}function i(e){return!!e}var o=e("indexof");t.exports=n},{indexof:6}],6:[function(e,t){var n=[].indexOf;t.exports=function(e,t){if(n)return e.indexOf(t);for(var r=0;e.length>r;++r)if(e[r]===t)return r;return-1}},{}],7:[function(e,t){function n(e){if(e.dataset)return e.dataset;var t=s.get(e);return t||(t=r(e),s.set(e,t)),t}function r(e){var t=e.attributes,n={};if(null===t||void 0===t)return n;for(var r=0;t.length>r;r++){var i=t[r];"data-"===i.name.substr(0,5)&&(n[i.name.substr(5)]=i.value)}return n}var i=e("weakmap"),o=e("individual"),s=o("__DATA_SET_WEAKMAP",i());t.exports=n},{individual:8,weakmap:10}],8:[function(e,t){function n(e,t){return r[e]?r[e]:(Object.defineProperty(r,e,{value:t,configurable:!0}),t)}var r=e("global");t.exports=n},{global:9}],9:[function(e,t){(function(e){e!==void 0?t.exports=e:"undefined"!=typeof window&&(t.exports=window)}).call(this,"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],10:[function(e,t,n){void function(e,r,i){function o(e,t,n){return"function"==typeof t&&(n=t,t=s(n).replace(/_$/,"")),c(e,t,{configurable:!0,writable:!0,value:n})}function s(e){return"function"!=typeof e?"":"name"in e?e.name:l.call(e).match(p)[1]}function u(e){function t(t,r){return r||2===arguments.length?n.set(t,r):(r=n.get(t),r===i&&(r=e(t),n.set(t,r))),r}var n=new d;return e||(e=g),t}var a=Object.getOwnPropertyNames,c=Object.defineProperty,l=Function.prototype.toString,f=Object.create,h=Object.prototype.hasOwnProperty,p=/^\n?function\s?(\w*)?_?\(/,v=function(){function e(){var e=s(),r={};this.unlock=function(i){var o=l(i);if(h.call(o,e))return o[e](r);var s=f(null,t);return c(o,e,{value:Function("s","l",n)(r,s)}),s}}var t={value:{writable:!0,value:i}},n="return function(k){if(k===s)return l}",r=f(null),s=function(){var e=Math.random().toString(36).slice(2);return e in r?s():r[e]=e},u=s(),l=function(e){if(h.call(e,u))return e[u];if(!Object.isExtensible(e))throw new TypeError("Object must be extensible");var t=f(null);return c(e,u,{value:t}),t};return o(Object,function(e){var t=a(e);return h.call(e,u)&&t.splice(t.indexOf(u),1),t}),o(e.prototype,function(e){return this.unlock(e).value}),o(e.prototype,function(e,t){this.unlock(e).value=t}),e}(),d=function(t){function n(t){return this===e||null==this||this===n.prototype?new n(t):(p(this,new v),g(this,t),i)}function u(e){h(e);var t=d(this).get(e);return t===r?i:t}function a(e,t){h(e),d(this).set(e,t===i?r:t)}function c(e){return h(e),d(this).get(e)!==i}function l(e){h(e);var t=d(this),n=t.get(e)!==i;return t.set(e,i),n}function f(){return d(this),"[object WeakMap]"}var h=function(e){if(null==e||"object"!=typeof e&&"function"!=typeof e)throw new TypeError("Invalid WeakMap key")},p=function(e,n){var r=t.unlock(e);if(r.value)throw new TypeError("Object is already a WeakMap");r.value=n},d=function(e){var n=t.unlock(e).value;if(!n)throw new TypeError("WeakMap is not generic");return n},g=function(e,t){null!==t&&"object"==typeof t&&"function"==typeof t.forEach&&t.forEach(function(n,r){n instanceof Array&&2===n.length&&a.call(e,t[r][0],t[r][1])})};try{var m=("return "+l).replace("e_","\\u0065"),y=Function("unwrap","validate",m)(d,h)}catch(b){var y=l}var m=(""+Object).split("Object"),w=function f(){return m[0]+s(this)+m[1]};o(w,w);var x={__proto__:[]}instanceof Array?function(e){e.__proto__=w}:function(e){o(e,w)};return x(n),[f,u,a,c,y].forEach(function(e){o(n.prototype,e),x(e)}),n}(new v),g=Object.create?function(){return Object.create(null)}:function(){return{}};t!==i?t.exports=d:n!==i?n.WeakMap=d:"WeakMap"in e||(e.WeakMap=d),d.createStorage=u,e.WeakMap&&(e.WeakMap.createStorage=u)}((0,eval)("this"))},{}],11:[function(e,t){(function(){function e(e,t){e(t()),t(e)}function n(e,t){t(e()),e(t),t(e)}function r(e){return void 0===e}function i(e){return"function"!=typeof e}function o(e,t){for(var n in e)e[n](t)}function s(e,t){delete e[e.indexOf(t)]}function u(e,t,n){(e.on||e.addEventListener).call(e,t,n,!1)}function a(e,t,n){(e.removeListener||e.removeEventListener||e.off).call(e,t,n,!1)}function c(){var e,t=[];return function(n){return r(n)?e:i(n)?o(t,e=n):(t.push(n),function(){s(t,n)})}}function l(e,t){return function(n){return r(n)?e.get(t):i(n)?e.set(t,n):(u(e,"change:"+t,n),function(){a(e,"change:"+t,n)})}}function f(e,t,n){if("function"!=typeof e)throw Error("transform expects an observable");return function(o){return r(o)?t(e()):i(o)?e((n||t)(o)):e(function(e){o(t(e))})}}function h(e){return f(e,function(e){return!e})}function p(e,t,n,r){function i(){r("function"==typeof n?n():e[n])}return u(e,t,i),function(){a(e,t,i)}}function v(e,t,n){return t=t||"value",n=n||"input",function(o){return r(o)?e[t]:i(o)?e[t]=o:p(e,n,t,o)}}function d(e){function t(){return e[e.selectedIndex].value}function n(t){for(var n=0;e.options.length>n;n++)e.options[n].value==t&&(e.selectedIndex=n)}return function(o){return r(o)?e.options[e.selectedIndex].value:i(o)?n(o):p(e,"change",t,o)}}function g(e,t,n){var o=!1;return function(s){function c(){o||s(o=!0)}function l(){o&&s(o=!1)}return r(s)?o:i(s)?void 0:(u(e,t,c),u(e,n||t,l),function(){a(e,t,c),a(e,n||t,l)})}}function m(e){throw Error(e)}function y(e,t){function n(){return t.apply(null,e.map(function(e){return e()}))}return function(t){return r(t)?n():i(t)?m("read-only"):e.forEach(function(e){e(function(){t(n())})})}}function b(e,t,n){return f(e,function(e){return e?t:n},function(e){return e==t?!0:!1})}var w=c;w.bind1=e,w.bind2=n,w.value=c,w.not=h,w.property=l,w.input=w.attribute=v,w.select=d,w.compute=y,w.transform=f,w.boolean=b,w.toggle=g,w.hover=function(e){return g(e,"mouseover","mouseout")},w.focus=function(e){return g(e,"focus","blur")},"object"==typeof t?t.exports=w:this.observable=w})()},{}],12:[function(e,t){var n=e("events").EventEmitter,r=e("hyperscript"),i=e("observable");console.log,t.exports=function(e){e=e||{};var t=new n,o=!0;e.max=1e4,e.margin=e.margin||30,e.style=e.style||{height:"100%",width:"50%"},e.template=e.template||function(e){return r("pre",e.map(function(e,t){if(!t)return e+"";try{return JSON.stringify(e,!1,2)}catch(e){return e+""}}).join(" "))},t.show=i();var s=r("div"),u=r("div",{style:e.style},{style:{overflow:"scroll",display:i.boolean(t.show,"block","none")}},s);return t.follow=function(){var e=s.lastElementChild;e&&e.scrollIntoViewIfNeeded(),o=!0},t.show(function(e){e&&o&&t.follow()}),t.show(!0),t.end=function(){},t.writable=!0,t.log=t.write=function(n){var r=e.template(n),i=s.getBoundingClientRect().bottom,a=u.getBoundingClientRect().bottom;if(o=a+e.margin>i,s.appendChild(r),o&&t.show()){for(;s.clientHeight>e.max&&s.children.length;)s.removeChild(s.firstChild);r.scrollIntoViewIfNeeded()}return!0},t.element=u,t}},{events:13,hyperscript:3,observable:11}],13:[function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function i(e){return"number"==typeof e}function o(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!i(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,i,u,a,c;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length))throw t=arguments[1],t instanceof Error?t:TypeError('Uncaught, unspecified "error" event.');if(n=this._events[e],s(n))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:for(i=arguments.length,u=Array(i-1),a=1;i>a;a++)u[a-1]=arguments[a];n.apply(this,u)}else if(o(n)){for(i=arguments.length,u=Array(i-1),a=1;i>a;a++)u[a-1]=arguments[a];for(c=n.slice(),i=c.length,a=0;i>a;a++)c[a].apply(this,u)}return!0},n.prototype.addListener=function(e,t){var i;if(!r(t))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,r(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned){var i;i=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[e].length>i&&(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())}return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),i||(i=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var i=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,i,s,u;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],s=n.length,i=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(n)){for(u=s;u-->0;)if(n[u]===t||n[u].listener&&n[u].listener===t){i=u;break}if(0>i)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],r(n))this.removeListener(e,n);else for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.listenerCount=function(e,t){var n;return n=e._events&&e._events[t]?r(e._events[t])?1:e._events[t].length:0}},{}]},{},[]),require("console-log").show(!0),console.log("hello!");
<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
You can’t perform that action at this time.