Skip to content

Instantly share code, notes, and snippets.

@lkptrzk
Created March 13, 2014 15:51
Show Gist options
  • Select an option

  • Save lkptrzk/9531042 to your computer and use it in GitHub Desktop.

Select an option

Save lkptrzk/9531042 to your computer and use it in GitHub Desktop.
requirebin sketch
var q = require('q')
q.fcall(function(resolve, reject) {
resolve(undefined);
}).then(function() {
console.log("Yey");
}, function() {
console.log("Boo");
});
require=function e(t,n,r){function o(u,c){if(!n[u]){if(!t[u]){var s="function"==typeof require&&require;if(!c&&s)return s(u,!0);if(i)return i(u,!0);throw Error("Cannot find module '"+u+"'")}var f=n[u]={exports:{}};t[u][0].call(f.exports,function(n){var e=t[u][1][n];return o(e?e:n)},f,f.exports,e,t,n,r)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;r.length>u;u++)o(r[u]);return o}({1:[function(t,n){var e=n.exports={};e.nextTick=function(){var t="undefined"!=typeof window&&window.setImmediate,n="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(t)return function(t){return window.setImmediate(t)};if(n){var e=[];return window.addEventListener("message",function(t){var n=t.source;if((n===window||null===n)&&"process-tick"===t.data&&(t.stopPropagation(),e.length>0)){var r=e.shift();r()}},!0),function(t){e.push(t),window.postMessage("process-tick","*")}}return function(t){setTimeout(t,0)}}(),e.title="browser",e.browser=!0,e.env={},e.argv=[],e.binding=function(){throw Error("process.binding is not supported")},e.cwd=function(){return"/"},e.chdir=function(){throw Error("process.chdir is not supported")}},{}],qLuPo1:[function(t,n,e){(function(t){(function(t){if("function"==typeof bootstrap)bootstrap("promise",t);else if("object"==typeof e)n.exports=t();else if("function"==typeof define&&define.amd)define(t);else if("undefined"!=typeof ses){if(!ses.ok())return;ses.makeQ=t}else Q=t()})(function(){"use strict";function n(t){return function(){return H.apply(t,arguments)}}function e(t){return t===Object(t)}function r(t){return"[object StopIteration]"===en(t)||t instanceof V}function o(t,n){if(U&&n.stack&&"object"==typeof t&&null!==t&&t.stack&&-1===t.stack.indexOf(rn)){for(var e=[],r=n;r;r=r.source)r.stack&&e.unshift(r.stack);e.unshift(t.stack);var o=e.join("\n"+rn+"\n");t.stack=i(o)}}function i(t){for(var n=t.split("\n"),e=[],r=0;n.length>r;++r){var o=n[r];s(o)||u(o)||!o||e.push(o)}return e.join("\n")}function u(t){return-1!==t.indexOf("(module.js:")||-1!==t.indexOf("(node.js:")}function c(t){var n=/at .+ \((.+):(\d+):(?:\d+)\)$/.exec(t);if(n)return[n[1],Number(n[2])];var e=/at ([^ ]+):(\d+):(?:\d+)$/.exec(t);if(e)return[e[1],Number(e[2])];var r=/.*@(.+):(\d+)$/.exec(t);return r?[r[1],Number(r[2])]:void 0}function s(t){var n=c(t);if(!n)return!1;var e=n[0],r=n[1];return e===Q&&r>=Y&&sn>=r}function f(){if(U)try{throw Error()}catch(t){var n=t.stack.split("\n"),e=n[0].indexOf("@")>0?n[1]:n[2],r=c(e);if(!r)return;return Q=r[0],r[1]}}function p(t,n,e){return function(){return"undefined"!=typeof console&&"function"==typeof console.warn&&console.warn(n+" is deprecated, use "+e+" instead.",Error("").stack),t.apply(t,arguments)}}function a(t){return g(t)?t:w(t)?q(t):O(t)}function l(){function t(t){n=t,i.source=t,K(e,function(n,e){G(function(){t.promiseDispatch.apply(t,e)})},void 0),e=void 0,r=void 0}var n,e=[],r=[],o=Z(l.prototype),i=Z(y.prototype);if(i.promiseDispatch=function(t,o,i){var u=J(arguments);e?(e.push(u),"when"===o&&i[1]&&r.push(i[1])):G(function(){n.promiseDispatch.apply(n,u)})},i.valueOf=function(){if(e)return i;var t=m(n);return g(t)&&(n=t),t},i.inspect=function(){return n?n.inspect():{state:"pending"}},a.longStackSupport&&U)try{throw Error()}catch(u){i.stack=u.stack.substring(u.stack.indexOf("\n")+1)}return o.promise=i,o.resolve=function(e){n||t(a(e))},o.fulfill=function(e){n||t(O(e))},o.reject=function(e){n||t(E(e))},o.notify=function(t){n||K(r,function(n,e){G(function(){e(t)})},void 0)},o}function d(t){if("function"!=typeof t)throw new TypeError("resolver must be a function.");var n=l();try{t(n.resolve,n.reject,n.notify)}catch(e){n.reject(e)}return n.promise}function h(t){return d(function(n,e){for(var r=0,o=t.length;o>r;r++)a(t[r]).then(n,e)})}function y(t,n,e){void 0===n&&(n=function(t){return E(Error("Promise does not support operation: "+t))}),void 0===e&&(e=function(){return{state:"unknown"}});var r=Z(y.prototype);if(r.promiseDispatch=function(e,o,i){var u;try{u=t[o]?t[o].apply(r,i):n.call(r,o,i)}catch(c){u=E(c)}e&&e(u)},r.inspect=e,e){var o=e();"rejected"===o.state&&(r.exception=o.reason),r.valueOf=function(){var t=e();return"pending"===t.state||"rejected"===t.state?r:t.value}}return r}function v(t,n,e,r){return a(t).then(n,e,r)}function m(t){if(g(t)){var n=t.inspect();if("fulfilled"===n.state)return n.value}return t}function g(t){return e(t)&&"function"==typeof t.promiseDispatch&&"function"==typeof t.inspect}function w(t){return e(t)&&"function"==typeof t.then}function k(t){return g(t)&&"pending"===t.inspect().state}function j(t){return!g(t)||"fulfilled"===t.inspect().state}function b(t){return g(t)&&"rejected"===t.inspect().state}function x(){on.length=0,un.length=0,cn||(cn=!0)}function R(t,n){cn&&(un.push(t),n&&n.stack!==void 0?on.push(n.stack):on.push("(no stack) "+n))}function T(t){if(cn){var n=W(un,t);-1!==n&&(un.splice(n,1),on.splice(n,1))}}function E(t){var n=y({when:function(n){return n&&T(this),n?n(t):this}},function(){return this},function(){return{state:"rejected",reason:t}});return R(n,t),n}function O(t){return y({when:function(){return t},get:function(n){return t[n]},set:function(n,e){t[n]=e},"delete":function(n){delete t[n]},post:function(n,e){return null===n||void 0===n?t.apply(void 0,e):t[n].apply(t,e)},apply:function(n,e){return t.apply(n,e)},keys:function(){return nn(t)}},void 0,function(){return{state:"fulfilled",value:t}})}function q(t){var n=l();return G(function(){try{t.then(n.resolve,n.reject,n.notify)}catch(e){n.reject(e)}}),n.promise}function P(t){return y({isDef:function(){}},function(n,e){return _(t,n,e)},function(){return a(t).inspect()})}function S(t,n,e){return a(t).spread(n,e)}function N(t){return function(){function n(t,n){var u;if("undefined"==typeof StopIteration){try{u=e[t](n)}catch(c){return E(c)}return u.done?u.value:v(u.value,o,i)}try{u=e[t](n)}catch(c){return r(c)?c.value:E(c)}return v(u,o,i)}var e=t.apply(this,arguments),o=n.bind(n,"next"),i=n.bind(n,"throw");return o()}}function D(t){a.done(a.async(t)())}function I(t){throw new V(t)}function C(t){return function(){return S([this,A(arguments)],function(n,e){return t.apply(n,e)})}}function _(t,n,e){return a(t).dispatch(n,e)}function A(t){return v(t,function(t){var n=0,e=l();return K(t,function(r,o,i){var u;g(o)&&"fulfilled"===(u=o.inspect()).state?t[i]=u.value:(++n,v(o,function(r){t[i]=r,0===--n&&e.resolve(t)},e.reject,function(t){e.notify({index:i,value:t})}))},void 0),0===n&&e.resolve(t),e.promise})}function M(t){return v(t,function(t){return t=X(t,a),v(A(X(t,function(t){return v(t,z,z)})),function(){return t})})}function F(t){return a(t).allSettled()}function L(t,n){return a(t).then(void 0,void 0,n)}function B(t,n){return a(t).nodeify(n)}var U=!1;try{throw Error()}catch($){U=!!$.stack}var Q,V,Y=f(),z=function(){},G=function(){function n(){for(;e.next;){e=e.next;var t=e.task;e.task=void 0;var r=e.domain;r&&(e.domain=void 0,r.enter());try{t()}catch(i){if(u)throw r&&r.exit(),setTimeout(n,0),r&&r.enter(),i;setTimeout(function(){throw i},0)}r&&r.exit()}o=!1}var e={task:void 0,next:null},r=e,o=!1,i=void 0,u=!1;if(G=function(n){r=r.next={task:n,domain:u&&t.domain,next:null},o||(o=!0,i())},t!==void 0&&t.nextTick)u=!0,i=function(){t.nextTick(n)};else if("function"==typeof setImmediate)i="undefined"!=typeof window?setImmediate.bind(window,n):function(){setImmediate(n)};else if("undefined"!=typeof MessageChannel){var c=new MessageChannel;c.port1.onmessage=function(){i=s,c.port1.onmessage=n,n()};var s=function(){c.port2.postMessage(0)};i=function(){setTimeout(n,0),s()}}else i=function(){setTimeout(n,0)};return G}(),H=Function.call,J=n(Array.prototype.slice),K=n(Array.prototype.reduce||function(t,n){var e=0,r=this.length;if(1===arguments.length)for(;;){if(e in this){n=this[e++];break}if(++e>=r)throw new TypeError}for(;r>e;e++)e in this&&(n=t(n,this[e],e));return n}),W=n(Array.prototype.indexOf||function(t){for(var n=0;this.length>n;n++)if(this[n]===t)return n;return-1}),X=n(Array.prototype.map||function(t,n){var e=this,r=[];return K(e,function(o,i,u){r.push(t.call(n,i,u,e))},void 0),r}),Z=Object.create||function(t){function n(){}return n.prototype=t,new n},tn=n(Object.prototype.hasOwnProperty),nn=Object.keys||function(t){var n=[];for(var e in t)tn(t,e)&&n.push(e);return n},en=n(Object.prototype.toString);V="undefined"!=typeof ReturnValue?ReturnValue:function(t){this.value=t};var rn="From previous event:";a.resolve=a,a.nextTick=G,a.longStackSupport=!1,a.defer=l,l.prototype.makeNodeResolver=function(){var t=this;return function(n,e){n?t.reject(n):arguments.length>2?t.resolve(J(arguments,1)):t.resolve(e)}},a.Promise=d,a.promise=d,d.race=h,d.all=A,d.reject=E,d.resolve=a,a.passByCopy=function(t){return t},y.prototype.passByCopy=function(){return this},a.join=function(t,n){return a(t).join(n)},y.prototype.join=function(t){return a([this,t]).spread(function(t,n){if(t===n)return t;throw Error("Can't join: not the same: "+t+" "+n)})},a.race=h,y.prototype.race=function(){return this.then(a.race)},a.makePromise=y,y.prototype.toString=function(){return"[object Promise]"},y.prototype.then=function(t,n,e){function r(n){try{return"function"==typeof t?t(n):n}catch(e){return E(e)}}function i(t){if("function"==typeof n){o(t,c);try{return n(t)}catch(e){return E(e)}}return E(t)}function u(t){return"function"==typeof e?e(t):t}var c=this,s=l(),f=!1;return G(function(){c.promiseDispatch(function(t){f||(f=!0,s.resolve(r(t)))},"when",[function(t){f||(f=!0,s.resolve(i(t)))}])}),c.promiseDispatch(void 0,"when",[void 0,function(t){var n,e=!1;try{n=u(t)}catch(r){if(e=!0,!a.onerror)throw r;a.onerror(r)}e||s.notify(n)}]),s.promise},a.when=v,y.prototype.thenResolve=function(t){return this.then(function(){return t})},a.thenResolve=function(t,n){return a(t).thenResolve(n)},y.prototype.thenReject=function(t){return this.then(function(){throw t})},a.thenReject=function(t,n){return a(t).thenReject(n)},a.nearer=m,a.isPromise=g,a.isPromiseAlike=w,a.isPending=k,y.prototype.isPending=function(){return"pending"===this.inspect().state},a.isFulfilled=j,y.prototype.isFulfilled=function(){return"fulfilled"===this.inspect().state},a.isRejected=b,y.prototype.isRejected=function(){return"rejected"===this.inspect().state};var on=[],un=[],cn=!0;a.resetUnhandledRejections=x,a.getUnhandledReasons=function(){return on.slice()},a.stopUnhandledRejectionTracking=function(){x(),cn=!1},x(),a.reject=E,a.fulfill=O,a.master=P,a.spread=S,y.prototype.spread=function(t,n){return this.all().then(function(n){return t.apply(void 0,n)},n)},a.async=N,a.spawn=D,a["return"]=I,a.promised=C,a.dispatch=_,y.prototype.dispatch=function(t,n){var e=this,r=l();return G(function(){e.promiseDispatch(r.resolve,t,n)}),r.promise},a.get=function(t,n){return a(t).dispatch("get",[n])},y.prototype.get=function(t){return this.dispatch("get",[t])},a.set=function(t,n,e){return a(t).dispatch("set",[n,e])},y.prototype.set=function(t,n){return this.dispatch("set",[t,n])},a.del=a["delete"]=function(t,n){return a(t).dispatch("delete",[n])},y.prototype.del=y.prototype["delete"]=function(t){return this.dispatch("delete",[t])},a.mapply=a.post=function(t,n,e){return a(t).dispatch("post",[n,e])},y.prototype.mapply=y.prototype.post=function(t,n){return this.dispatch("post",[t,n])},a.send=a.mcall=a.invoke=function(t,n){return a(t).dispatch("post",[n,J(arguments,2)])},y.prototype.send=y.prototype.mcall=y.prototype.invoke=function(t){return this.dispatch("post",[t,J(arguments,1)])},a.fapply=function(t,n){return a(t).dispatch("apply",[void 0,n])},y.prototype.fapply=function(t){return this.dispatch("apply",[void 0,t])},a["try"]=a.fcall=function(t){return a(t).dispatch("apply",[void 0,J(arguments,1)])},y.prototype.fcall=function(){return this.dispatch("apply",[void 0,J(arguments)])},a.fbind=function(t){var n=a(t),e=J(arguments,1);return function(){return n.dispatch("apply",[this,e.concat(J(arguments))])}},y.prototype.fbind=function(){var t=this,n=J(arguments);return function(){return t.dispatch("apply",[this,n.concat(J(arguments))])}},a.keys=function(t){return a(t).dispatch("keys",[])},y.prototype.keys=function(){return this.dispatch("keys",[])},a.all=A,y.prototype.all=function(){return A(this)},a.allResolved=p(M,"allResolved","allSettled"),y.prototype.allResolved=function(){return M(this)},a.allSettled=F,y.prototype.allSettled=function(){return this.then(function(t){return A(X(t,function(t){function n(){return t.inspect()}return t=a(t),t.then(n,n)}))})},a.fail=a["catch"]=function(t,n){return a(t).then(void 0,n)},y.prototype.fail=y.prototype["catch"]=function(t){return this.then(void 0,t)},a.progress=L,y.prototype.progress=function(t){return this.then(void 0,void 0,t)},a.fin=a["finally"]=function(t,n){return a(t)["finally"](n)},y.prototype.fin=y.prototype["finally"]=function(t){return t=a(t),this.then(function(n){return t.fcall().then(function(){return n})},function(n){return t.fcall().then(function(){throw n})})},a.done=function(t,n,e,r){return a(t).done(n,e,r)},y.prototype.done=function(n,e,r){var i=function(t){G(function(){if(o(t,u),!a.onerror)throw t;a.onerror(t)})},u=n||e||r?this.then(n,e,r):this;"object"==typeof t&&t&&t.domain&&(i=t.domain.bind(i)),u.then(void 0,i)},a.timeout=function(t,n,e){return a(t).timeout(n,e)},y.prototype.timeout=function(t,n){var e=l(),r=setTimeout(function(){e.reject(Error(n||"Timed out after "+t+" ms"))},t);return this.then(function(t){clearTimeout(r),e.resolve(t)},function(t){clearTimeout(r),e.reject(t)},e.notify),e.promise},a.delay=function(t,n){return void 0===n&&(n=t,t=void 0),a(t).delay(n)},y.prototype.delay=function(t){return this.then(function(n){var e=l();return setTimeout(function(){e.resolve(n)},t),e.promise})},a.nfapply=function(t,n){return a(t).nfapply(n)},y.prototype.nfapply=function(t){var n=l(),e=J(t);return e.push(n.makeNodeResolver()),this.fapply(e).fail(n.reject),n.promise},a.nfcall=function(t){var n=J(arguments,1);return a(t).nfapply(n)},y.prototype.nfcall=function(){var t=J(arguments),n=l();return t.push(n.makeNodeResolver()),this.fapply(t).fail(n.reject),n.promise},a.nfbind=a.denodeify=function(t){var n=J(arguments,1);return function(){var e=n.concat(J(arguments)),r=l();return e.push(r.makeNodeResolver()),a(t).fapply(e).fail(r.reject),r.promise}},y.prototype.nfbind=y.prototype.denodeify=function(){var t=J(arguments);return t.unshift(this),a.denodeify.apply(void 0,t)},a.nbind=function(t,n){var e=J(arguments,2);return function(){function r(){return t.apply(n,arguments)}var o=e.concat(J(arguments)),i=l();return o.push(i.makeNodeResolver()),a(r).fapply(o).fail(i.reject),i.promise}},y.prototype.nbind=function(){var t=J(arguments,0);return t.unshift(this),a.nbind.apply(void 0,t)},a.nmapply=a.npost=function(t,n,e){return a(t).npost(n,e)},y.prototype.nmapply=y.prototype.npost=function(t,n){var e=J(n||[]),r=l();return e.push(r.makeNodeResolver()),this.dispatch("post",[t,e]).fail(r.reject),r.promise},a.nsend=a.nmcall=a.ninvoke=function(t,n){var e=J(arguments,2),r=l();return e.push(r.makeNodeResolver()),a(t).dispatch("post",[n,e]).fail(r.reject),r.promise},y.prototype.nsend=y.prototype.nmcall=y.prototype.ninvoke=function(t){var n=J(arguments,1),e=l();return n.push(e.makeNodeResolver()),this.dispatch("post",[t,n]).fail(e.reject),e.promise},a.nodeify=B,y.prototype.nodeify=function(t){return t?(this.then(function(n){G(function(){t(null,n)})},function(n){G(function(){t(n)})}),void 0):this};var sn=f();return a})}).call(this,t("/home/admin/browserify-cdn/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js"))},{"/home/admin/browserify-cdn/node_modules/browserify/node_modules/insert-module-globals/node_modules/process/browser.js":1}],q:[function(t,n){n.exports=t("qLuPo1")},{}]},{},[]);var q=require("q");q.fcall(function(t){t(void 0)}).then(function(){console.log("Yey")},function(){console.log("Boo")});
{
"name": "requirebin-sketch",
"version": "1.0.0",
"dependencies": {
"q": "1.0.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