view on requirebin
Created
December 4, 2013 05:49
-
-
Save supershabam/7782984 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
// require something | |
var URL = require('websocket-url') | |
console.log(URL.parse('ws://test.com')) |
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(t,e,r){function o(r,a){if(!e[r]){if(!t[r]){var s="function"==typeof require&&require;if(!a&&s)return s(r,!0);if(n)return n(r,!0);throw Error("Cannot find module '"+r+"'")}var h=e[r]={exports:{}};t[r][0].call(h.exports,function(e){var n=t[r][1][e];return o(n?n:e)},h,h.exports)}return e[r].exports}for(var n="function"==typeof require&&require,a=0;r.length>a;a++)o(r[a]);return o}({"websocket-url":[function(t,e){e.exports=t("6muCHw")},{}],"6muCHw":[function(t,e,r){var o=t("url");r.parse=function(t){var e=o.parse(t),r=!1;if("ws:"!==e.protocol&&"wss:"!==e.protocol)throw new SyntaxError('scheme component must be "ws" or "wss"');if(e.hash)throw new SyntaxError("expected null fragment component");return"wss:"===e.protocol&&(r=!0),e.port||(e.port="ws:"===e.protocol?"80":"443"),{host:e.hostname,port:e.port,resource:e.path,secure:r}}},{url:1}],1:[function(t,e,r){function o(t,e){for(var r=0,o=t.length;o>r;r++)if(t[r]==e)return r;return-1}function n(t,e,r){if(t&&"object"==typeof t&&t.href)return t;if("string"!=typeof t)throw new TypeError("Parameter 'url' must be a string, not "+typeof t);for(var n={},s=t,h=0,p=s.length;p>h&&-1!==o(l,s.charAt(h));h++);0!==h&&(s=s.substr(h));var m=f.exec(s);if(m){m=m[0];var C=m.toLowerCase();n.protocol=C,s=s.substr(m.length)}if(r||m||s.match(/^\/\/[^@\/]+@[^@\/]+/)){var R="//"===s.substr(0,2);!R||m&&q[m]||(s=s.substr(2),n.slashes=!0)}if(!q[m]&&(R||m&&!A[m])){var U=o(s,"@");if(-1!==U){for(var E=!0,h=0,p=y.length;p>h;h++){var I=o(s,y[h]);if(-1!==I&&U>I){E=!1;break}}E&&(n.auth=s.substr(0,U),s=s.substr(U+1))}for(var O=-1,h=0,p=g.length;p>h;h++){var I=o(s,g[h]);-1!==I&&(0>O||O>I)&&(O=I)}-1!==O?(n.host=s.substr(0,O),s=s.substr(O)):(n.host=s,s="");for(var k=i(n.host),z=u(k),h=0,p=z.length;p>h;h++){var Z=z[h];n[Z]=k[Z]}if(n.hostname=n.hostname||"",n.hostname.length>b)n.hostname="";else for(var L=n.hostname.split(/\./),h=0,p=L.length;p>h;h++){var T=L[h];if(T&&!T.match(d)){for(var $="",S=0,_=T.length;_>S;S++)$+=T.charCodeAt(S)>127?"x":T[S];if(!$.match(d)){var H=L.slice(0,h),P=L.slice(h+1),M=T.match(j);M&&(H.push(M[1]),P.unshift(M[2])),P.length&&(s="/"+P.join(".")+s),n.hostname=H.join(".");break}}}n.hostname=n.hostname.toLowerCase();for(var B=n.hostname.split("."),D=[],h=0;B.length>h;++h){var F=B[h];D.push(F.match(/[^A-Za-z0-9_-]/)?"xn--"+c.encode(F):F)}n.hostname=D.join("."),n.host=(n.hostname||"")+(n.port?":"+n.port:""),n.href+=n.host}if(!w[C]){for(var h=0,p=v.length;p>h;h++){var G=v[h],J=encodeURIComponent(G);J===G&&(J=escape(G)),s=s.split(G).join(J)}for(var K=s.length,h=0,p=l.length;p>h;h++){var N=o(s,l[h]);-1!==N&&(K=Math.min(N,K))}s=s.substr(0,K)}var Q=o(s,"#");-1!==Q&&(n.hash=s.substr(Q),s=s.slice(0,Q));var V=o(s,"?");return-1!==V?(n.search=s.substr(V),n.query=s.substr(V+1),e&&(n.query=x.parse(n.query)),s=s.slice(0,V)):e&&(n.search="",n.query={}),s&&(n.pathname=s),A[m]&&n.hostname&&!n.pathname&&(n.pathname="/"),(n.pathname||n.search)&&(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=a(n),n}function a(t){"string"==typeof t&&(t=n(t));var e=t.auth||"";if(e){e=e.split("@").join("%40");for(var r=0,o=y.length;o>r;r++){var a=y[r];e=e.split(a).join(encodeURIComponent(a))}e+="@"}var s=t.protocol||"",h=void 0!==t.host?e+t.host:void 0!==t.hostname?e+t.hostname+(t.port?":"+t.port:""):!1,i=t.pathname||"",c=t.query&&("object"==typeof t.query&&u(t.query).length?x.stringify(t.query):"")||"",f=t.search||c&&"?"+c||"",p=t.hash||"";return s&&":"!==s.substr(-1)&&(s+=":"),t.slashes||(!s||A[s])&&h!==!1?(h="//"+(h||""),i&&"/"!==i.charAt(0)&&(i="/"+i)):h||(h=""),p&&"#"!==p.charAt(0)&&(p="#"+p),f&&"?"!==f.charAt(0)&&(f="?"+f),s+h+i+f+p}function s(t,e){return a(h(t,e))}function h(t,e){if(!t)return e;if(t=n(a(t),!1,!0),e=n(a(e),!1,!0),t.hash=e.hash,""===e.href)return t.href=a(t),t;if(e.slashes&&!e.protocol)return e.protocol=t.protocol,A[e.protocol]&&e.hostname&&!e.pathname&&(e.path=e.pathname="/"),e.href=a(e),e;if(e.protocol&&e.protocol!==t.protocol){if(!A[e.protocol])return e.href=a(e),e;if(t.protocol=e.protocol,!e.host&&!q[e.protocol]){for(var r=(e.pathname||"").split("/");r.length&&!(e.host=r.shift()););e.host||(e.host=""),e.hostname||(e.hostname=""),""!==r[0]&&r.unshift(""),2>r.length&&r.unshift(""),e.pathname=r.join("/")}return t.pathname=e.pathname,t.search=e.search,t.query=e.query,t.host=e.host||"",t.auth=e.auth,t.hostname=e.hostname||e.host,t.port=e.port,(void 0!==t.pathname||void 0!==t.search)&&(t.path=(t.pathname?t.pathname:"")+(t.search?t.search:"")),t.slashes=t.slashes||e.slashes,t.href=a(t),t}var s=t.pathname&&"/"===t.pathname.charAt(0),h=void 0!==e.host||e.pathname&&"/"===e.pathname.charAt(0),i=h||s||t.host&&e.pathname,c=i,u=t.pathname&&t.pathname.split("/")||[],r=e.pathname&&e.pathname.split("/")||[],f=t.protocol&&!A[t.protocol];if(f&&(delete t.hostname,delete t.port,t.host&&(""===u[0]?u[0]=t.host:u.unshift(t.host)),delete t.host,e.protocol&&(delete e.hostname,delete e.port,e.host&&(""===r[0]?r[0]=e.host:r.unshift(e.host)),delete e.host),i=i&&(""===r[0]||""===u[0])),h)t.host=e.host||""===e.host?e.host:t.host,t.hostname=e.hostname||""===e.hostname?e.hostname:t.hostname,t.search=e.search,t.query=e.query,u=r;else if(r.length)u||(u=[]),u.pop(),u=u.concat(r),t.search=e.search,t.query=e.query;else if("search"in e){if(f){t.hostname=t.host=u.shift();var p=t.host&&o(t.host,"@")>0?t.host.split("@"):!1;p&&(t.auth=p.shift(),t.host=t.hostname=p.shift())}return t.search=e.search,t.query=e.query,(void 0!==t.pathname||void 0!==t.search)&&(t.path=(t.pathname?t.pathname:"")+(t.search?t.search:"")),t.href=a(t),t}if(!u.length)return delete t.pathname,t.search?delete t.path:t.path="/"+t.search,t.href=a(t),t;for(var l=u.slice(-1)[0],m=(t.host||e.host)&&("."===l||".."===l)||""===l,v=0,g=u.length;g>=0;g--)l=u[g],"."==l?u.splice(g,1):".."===l?(u.splice(g,1),v++):v&&(u.splice(g,1),v--);if(!i&&!c)for(;v--;v)u.unshift("..");!i||""===u[0]||u[0]&&"/"===u[0].charAt(0)||u.unshift(""),m&&"/"!==u.join("/").substr(-1)&&u.push("");var y=""===u[0]||u[0]&&"/"===u[0].charAt(0);if(f){t.hostname=t.host=y?"":u.length?u.shift():"";var p=t.host&&o(t.host,"@")>0?t.host.split("@"):!1;p&&(t.auth=p.shift(),t.host=t.hostname=p.shift())}return i=i||t.host&&u.length,i&&!y&&u.unshift(""),t.pathname=u.join("/"),(void 0!==t.pathname||void 0!==t.search)&&(t.path=(t.pathname?t.pathname:"")+(t.search?t.search:"")),t.auth=e.auth||t.auth,t.slashes=t.slashes||e.slashes,t.href=a(t),t}function i(t){var e={},r=p.exec(t);return r&&(r=r[0],e.port=r.substr(1),t=t.substr(0,t.length-r.length)),t&&(e.hostname=t),e}var c={encode:function(t){return t}};r.parse=n,r.resolve=s,r.resolveObject=h,r.format=a;var u=Object.keys||function u(t){if(t!==Object(t))throw new TypeError("Invalid object");var e=[];for(var r in t)t.hasOwnProperty(r)&&(e[e.length]=r);return e},f=/^([a-z0-9.+-]+:)/i,p=/:[0-9]+$/,l=["<",">",'"',"`"," ","\r","\n"," "],m=["{","}","|","\\","^","~","[","]","`"].concat(l),v=["'"],g=["%","/","?",";","#"].concat(m).concat(v),y=["/","@","?","#"].concat(l),b=255,d=/^[a-zA-Z0-9][a-z0-9A-Z_-]{0,62}$/,j=/^([a-zA-Z0-9][a-z0-9A-Z_-]{0,62})(.*)$/,w={javascript:!0,"javascript:":!0},q={javascript:!0,"javascript:":!0},A={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0},x=t("querystring")},{querystring:2}],2:[function(t,e,r){function o(t,e){if(0==t[e].length)return t[e]={};var r={};for(var o in t[e])r[o]=t[e][o];return t[e]=r,r}function n(t,e,r,a){var s=t.shift();if(s){var h=e[r]=e[r]||[];"]"==s?g(h)?""!=a&&h.push(a):"object"==typeof h?h[y(h).length]=a:h=e[r]=[e[r],a]:~v(s,"]")?(s=s.substr(0,s.length-1),!j.test(s)&&g(h)&&(h=o(e,r)),n(t,h,s,a)):(!j.test(s)&&g(h)&&(h=o(e,r)),n(t,h,s,a))}else g(e[r])?e[r].push(a):e[r]="object"==typeof e[r]?a:e[r]===void 0?a:[e[r],a]}function a(t,e,r){if(~v(e,"]")){var o=e.split("[");o.length,n(o,t,"base",r)}else{if(!j.test(e)&&g(t.base)){var a={};for(var s in t.base)a[s]=t.base[s];t.base=a}f(t.base,e,r)}return t}function s(t){var e={base:{}};return b(y(t),function(r){a(e,r,t[r])}),e.base}function h(t){return d((t+"").split("&"),function(t,e){var r=v(e,"="),o=p(e),n=e.substr(0,o||r),s=e.substr(o||r,e.length),s=s.substr(v(s,"=")+1,s.length);return""==n&&(n=e,s=""),""==n?t:a(t,l(n),l(s))},{base:{}}).base}function i(t,e){if(!e)throw new TypeError("stringify expects an object");return e+"="+encodeURIComponent(t)}function c(t,e){var r=[];if(!e)throw new TypeError("stringify expects an object");for(var o=0;t.length>o;o++)r.push(w(t[o],e+"["+o+"]"));return r.join("&")}function u(t,e){for(var r,o=[],n=y(t),a=0,s=n.length;s>a;++a)r=n[a],null==t[r]?o.push(encodeURIComponent(r)+"="):o.push(w(t[r],e?e+"["+encodeURIComponent(r)+"]":encodeURIComponent(r)));return o.join("&")}function f(t,e,r){var o=t[e];void 0===o?t[e]=r:g(o)?o.push(r):t[e]=[o,r]}function p(t){for(var e,r,o=t.length,n=0;o>n;++n)if(r=t[n],"]"==r&&(e=!1),"["==r&&(e=!0),"="==r&&!e)return n}function l(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(e){return t}}var m=Object.prototype.toString,v="function"==typeof Array.prototype.indexOf?function(t,e){return t.indexOf(e)}:function(t,e){for(var r=0;t.length>r;r++)if(t[r]===e)return r;return-1},g=Array.isArray||function(t){return"[object Array]"==m.call(t)},y=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e},b="function"==typeof Array.prototype.forEach?function(t,e){return t.forEach(e)}:function(t,e){for(var r=0;t.length>r;r++)e(t[r])},d=function(t,e,r){if("function"==typeof t.reduce)return t.reduce(e,r);for(var o=r,n=0;t.length>n;n++)o=e(o,t[n]);return o},j=/^[0-9]+$/;r.parse=function(t){return null==t||""==t?{}:"object"==typeof t?s(t):h(t)};var w=r.stringify=function(t,e){return g(t)?c(t,e):"[object Object]"==m.call(t)?u(t,e):"string"==typeof t?i(t,e):e+"="+encodeURIComponent(t+"")}},{}]},{},[]);var URL=require("websocket-url");console.log(URL.parse("ws://test.com")); |
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