Skip to content

Instantly share code, notes, and snippets.

@hannahherbig
Created May 15, 2014 18:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hannahherbig/823e31bbd1e196e43275 to your computer and use it in GitHub Desktop.
Save hannahherbig/823e31bbd1e196e43275 to your computer and use it in GitHub Desktop.
requirebin sketch
var console = require('demo-console')
process.nextTick(function () {
console.log('hi')
})
require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({R7XjId:[function(require,module,exports){"use strict";var themeBase="//rawgithub.com/DamonOehlman/demo-console/master/";var reSpace=/\s/;var theme;var items;exports.log=function(data){var item=document.createElement("li");items=items||initConsole();theme=theme||initTheme();item.innerHTML=renderData(data);items.appendChild(item);setTimeout(function(){items.parentNode.scrollTop=items.offsetHeight},100)};exports.useTheme=function(name){theme=initTheme(name)};function initConsole(){var container;var list=document.querySelector(".democonsole ul");if(list){return list}container=document.createElement("div");list=document.createElement("ul");container.className="democonsole";container.appendChild(list);document.body.appendChild(container);return list}function initTheme(theme){var stylesheet=document.getElementById("democonsole-theme");if(stylesheet){document.head.removeChild(stylesheet)}stylesheet=document.createElement("link");stylesheet.id="democonsole-theme";stylesheet.setAttribute("rel","stylesheet");stylesheet.setAttribute("href",themeBase+"themes/"+(theme||"default")+".css");document.head.appendChild(stylesheet);return stylesheet}function renderData(data){function extractData(key){var hasSpace=reSpace.test(key);var quoteChar=hasSpace?"'":"";return'<div data-type="object-key">'+span(quoteChar+key+quoteChar+": ","key")+renderData(data[key])+"</div>"}if(typeof data=="undefined"){return span("undefined","undefined")}if(data===true||data===false){return span(data,"boolean")}else if(Array.isArray(data)){return span("[")+data.map(renderData).join(", ")+span("]")}else if(typeof data=="string"||data instanceof String){return span("'"+data+"'","string")}else if(data===null){return span("null","null")}else if(data instanceof Window){return span("window","window")}else if(data instanceof DocumentType){return"doctype: "+data.name}else if(data instanceof HTMLCollection){return span("[]","html-collection")}else if(data instanceof HTMLDocument){return[].slice.call(document.childNodes).map(renderData)}else if(data instanceof HTMLElement){return data.tagName}else if(typeof data=="object"){return'<div data-type="object">'+span("{")+Object.keys(data).map(extractData).join('<div class="comma-float">,</div>')+span("}")+"</div>"}else{return span(data,typeof data)}}function span(content,dataType){return'<span data-type="'+(dataType||"")+'">'+content+"</span>"}},{}],"demo-console":[function(require,module,exports){module.exports=require("R7XjId")},{}]},{},[]);var console=require("demo-console");process.nextTick(function(){console.log("hi")});
{
"name": "requirebin-sketch",
"version": "1.0.0",
"dependencies": {
"demo-console": "1.1.1"
}
}
<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