Skip to content

Instantly share code, notes, and snippets.

@moimikey
Last active November 20, 2015 21:18
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 moimikey/8394988344ff2514df5e to your computer and use it in GitHub Desktop.
Save moimikey/8394988344ff2514df5e to your computer and use it in GitHub Desktop.
requirebin sketch
// require() some stuff from npm (like you were using browserify)
// and then hit Run Code to run it on the right
var locale2 = require('locale2');
document.write(locale2);
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);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.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}({1:[function(require,module,exports){var process=module.exports={};process.nextTick=function(){var canSetImmediate=typeof window!=="undefined"&&window.setImmediate;var canMutationObserver=typeof window!=="undefined"&&window.MutationObserver;var canPost=typeof window!=="undefined"&&window.postMessage&&window.addEventListener;if(canSetImmediate){return function(f){return window.setImmediate(f)}}var queue=[];if(canMutationObserver){var hiddenDiv=document.createElement("div");var observer=new MutationObserver(function(){var queueList=queue.slice();queue.length=0;queueList.forEach(function(fn){fn()})});observer.observe(hiddenDiv,{attributes:true});return function nextTick(fn){if(!queue.length){hiddenDiv.setAttribute("yes","no")}queue.push(fn)}}if(canPost){window.addEventListener("message",function(ev){var source=ev.source;if((source===window||source===null)&&ev.data==="process-tick"){ev.stopPropagation();if(queue.length>0){var fn=queue.shift();fn()}}},true);return function nextTick(fn){queue.push(fn);window.postMessage("process-tick","*")}}return function nextTick(fn){setTimeout(fn,0)}}();process.title="browser";process.browser=true;process.env={};process.argv=[];function noop(){}process.on=noop;process.addListener=noop;process.once=noop;process.off=noop;process.removeListener=noop;process.removeAllListeners=noop;process.emit=noop;process.binding=function(name){throw new Error("process.binding is not supported")};process.cwd=function(){return"/"};process.chdir=function(dir){throw new Error("process.chdir is not supported")}},{}],2:[function(require,module,exports){(function(process,global){"use strict";var formatLocale=require("./utils").formatLocale;function getLocale(locale){if(locale)return locale;if(global.Intl&&typeof global.Intl.DateTimeFormat==="function"){return global.Intl.DateTimeFormat().resolved.locale}if(global.chrome&&typeof global.chrome.app.getDetails==="function"){return global.chrome.app.getDetails().current_locale}locale=(global.clientInformation||global.navigator||Object.create(null)).language||global.navigator&&(global.navigator.userLanguage||global.navigator.languages&&global.navigator.languages[0]||global.navigator.userAgent&&global.navigator.userAgent.match(/;.(\w+\-\w+)/i)[1]);if(!locale&&["LANG","LANGUAGE"].some(Object.hasOwnProperty,process.env)){return(process.env.LANG||process.env.LANGUAGE||Object.create(null)).replace(/[.:].*/,"").replace("_","-")}return locale}var locale2=function(locale){return formatLocale(getLocale(locale))};exports.locale2=locale2}).call(this,require("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./utils":3,_process:1}],3:[function(require,module,exports){"use strict";exports.formatLocale=function(locale){if(typeof locale!=="string")return locale;return locale.split("-").map(function(chunk,index){if(index!==0&&chunk.length===2)return chunk.toUpperCase();return chunk}).join("-")}},{}],locale2:[function(require,module,exports){"use strict";module.exports=require("./src").locale2()},{"./src":2}]},{},[]);var locale2=require("locale2");document.write(locale2);
{
"name": "requirebin-sketch",
"version": "1.0.0",
"dependencies": {
"locale2": "2.0.0"
}
}
<!-- contents of this file will be placed inside the <body> -->
<!-- contents of this file will be placed inside the <head> -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment