Skip to content

Instantly share code, notes, and snippets.

@nilliams
Created October 21, 2016 20:00
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 nilliams/a6d249325c9a1d80b6512da6fd47fadd to your computer and use it in GitHub Desktop.
Save nilliams/a6d249325c9a1d80b6512da6fd47fadd to your computer and use it in GitHub Desktop.
requirebin sketch
var Promise = require('rsvp').Promise;
function MyCoolErr() {}
function foo() {
return new Promise(function(resolve, reject) {
console.log("We're running...");
// Resolve and all is good ...
resolve();
});
}
foo()
.then(function() {
console.log("We're still running...");
// But then we go and throw ANY exception in here
// and the error is silently swallowed.
throw 'any runtime err, incl. typos, invalid code etc.'
console.log("We won't get here.");
})
.catch(function(err) {
if (err instanceof MyCoolErr) {
console.log('I know this error so will handle here');
return;
}
console.log('I did not recognise the error ...');
// And I re-threw it. I expect this to be an 'unhandled exception' and reach my devtools.
//
// ... But nope, I'll never know this happened :(
throw err;
});
setTimeout(function(){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")}},{}],rsvp:[function(require,module,exports){(function(process,global){(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?factory(exports):typeof define==="function"&&define.amd?define(["exports"],factory):factory(global.RSVP=global.RSVP||{})})(this,function(exports){"use strict";function indexOf(callbacks,callback){for(var i=0,l=callbacks.length;i<l;i++){if(callbacks[i]===callback){return i}}return-1}function callbacksFor(object){var callbacks=object._promiseCallbacks;if(!callbacks){callbacks=object._promiseCallbacks={}}return callbacks}var EventTarget={mixin:function mixin(object){object["on"]=this["on"];object["off"]=this["off"];object["trigger"]=this["trigger"];object._promiseCallbacks=undefined;return object},on:function on(eventName,callback){if(typeof callback!=="function"){throw new TypeError("Callback must be a function")}var allCallbacks=callbacksFor(this),callbacks=undefined;callbacks=allCallbacks[eventName];if(!callbacks){callbacks=allCallbacks[eventName]=[]}if(indexOf(callbacks,callback)===-1){callbacks.push(callback)}},off:function off(eventName,callback){var allCallbacks=callbacksFor(this),callbacks=undefined,index=undefined;if(!callback){allCallbacks[eventName]=[];return}callbacks=allCallbacks[eventName];index=indexOf(callbacks,callback);if(index!==-1){callbacks.splice(index,1)}},trigger:function trigger(eventName,options,label){var allCallbacks=callbacksFor(this),callbacks=undefined,callback=undefined;if(callbacks=allCallbacks[eventName]){for(var i=0;i<callbacks.length;i++){callback=callbacks[i];callback(options,label)}}}};var config={instrument:false};EventTarget["mixin"](config);function configure(name,value){if(name==="onerror"){config["on"]("error",value);return}if(arguments.length===2){config[name]=value}else{return config[name]}}function objectOrFunction(x){return typeof x==="function"||typeof x==="object"&&x!==null}function isFunction(x){return typeof x==="function"}function isMaybeThenable(x){return typeof x==="object"&&x!==null}var _isArray=undefined;if(!Array.isArray){_isArray=function(x){return Object.prototype.toString.call(x)==="[object Array]"}}else{_isArray=Array.isArray}var isArray=_isArray;var now=Date.now||function(){return(new Date).getTime()};function F(){}var o_create=Object.create||function(o){if(arguments.length>1){throw new Error("Second argument not supported")}if(typeof o!=="object"){throw new TypeError("Argument must be an object")}F.prototype=o;return new F};var queue=[];function scheduleFlush(){setTimeout(function(){for(var i=0;i<queue.length;i++){var entry=queue[i];var payload=entry.payload;payload.guid=payload.key+payload.id;payload.childGuid=payload.key+payload.childId;if(payload.error){payload.stack=payload.error.stack}config["trigger"](entry.name,entry.payload)}queue.length=0},50)}function instrument(eventName,promise,child){if(1===queue.push({name:eventName,payload:{key:promise._guidKey,id:promise._id,eventName:eventName,detail:promise._result,childId:child&&child._id,label:promise._label,timeStamp:now(),error:config["instrument-with-stack"]?new Error(promise._label):null}})){scheduleFlush()}}function resolve$1(object,label){var Constructor=this;if(object&&typeof object==="object"&&object.constructor===Constructor){return object}var promise=new Constructor(noop,label);resolve(promise,object);return promise}function withOwnPromise(){return new TypeError("A promises callback cannot return that same promise.")}function noop(){}var PENDING=void 0;var FULFILLED=1;var REJECTED=2;var GET_THEN_ERROR=new ErrorObject;function getThen(promise){try{return promise.then}catch(error){GET_THEN_ERROR.error=error;return GET_THEN_ERROR}}function tryThen(then,value,fulfillmentHandler,rejectionHandler){try{then.call(value,fulfillmentHandler,rejectionHandler)}catch(e){return e}}function handleForeignThenable(promise,thenable,then){config.async(function(promise){var sealed=false;var error=tryThen(then,thenable,function(value){if(sealed){return}sealed=true;if(thenable!==value){resolve(promise,value,undefined)}else{fulfill(promise,value)}},function(reason){if(sealed){return}sealed=true;reject(promise,reason)},"Settle: "+(promise._label||" unknown promise"));if(!sealed&&error){sealed=true;reject(promise,error)}},promise)}function handleOwnThenable(promise,thenable){if(thenable._state===FULFILLED){fulfill(promise,thenable._result)}else if(thenable._state===REJECTED){thenable._onError=null;reject(promise,thenable._result)}else{subscribe(thenable,undefined,function(value){if(thenable!==value){resolve(promise,value,undefined)}else{fulfill(promise,value)}},function(reason){return reject(promise,reason)})}}function handleMaybeThenable(promise,maybeThenable,then$$){if(maybeThenable.constructor===promise.constructor&&then$$===then&&promise.constructor.resolve===resolve$1){handleOwnThenable(promise,maybeThenable)}else{if(then$$===GET_THEN_ERROR){reject(promise,GET_THEN_ERROR.error)}else if(then$$===undefined){fulfill(promise,maybeThenable)}else if(isFunction(then$$)){handleForeignThenable(promise,maybeThenable,then$$)}else{fulfill(promise,maybeThenable)}}}function resolve(promise,value){if(promise===value){fulfill(promise,value)}else if(objectOrFunction(value)){handleMaybeThenable(promise,value,getThen(value))}else{fulfill(promise,value)}}function publishRejection(promise){if(promise._onError){promise._onError(promise._result)}publish(promise)}function fulfill(promise,value){if(promise._state!==PENDING){return}promise._result=value;promise._state=FULFILLED;if(promise._subscribers.length===0){if(config.instrument){instrument("fulfilled",promise)}}else{config.async(publish,promise)}}function reject(promise,reason){if(promise._state!==PENDING){return}promise._state=REJECTED;promise._result=reason;config.async(publishRejection,promise)}function subscribe(parent,child,onFulfillment,onRejection){var subscribers=parent._subscribers;var length=subscribers.length;parent._onError=null;subscribers[length]=child;subscribers[length+FULFILLED]=onFulfillment;subscribers[length+REJECTED]=onRejection;if(length===0&&parent._state){config.async(publish,parent)}}function publish(promise){var subscribers=promise._subscribers;var settled=promise._state;if(config.instrument){instrument(settled===FULFILLED?"fulfilled":"rejected",promise)}if(subscribers.length===0){return}var child=undefined,callback=undefined,detail=promise._result;for(var i=0;i<subscribers.length;i+=3){child=subscribers[i];callback=subscribers[i+settled];if(child){invokeCallback(settled,child,callback,detail)}else{callback(detail)}}promise._subscribers.length=0}function ErrorObject(){this.error=null}var TRY_CATCH_ERROR=new ErrorObject;function tryCatch(callback,detail){try{return callback(detail)}catch(e){TRY_CATCH_ERROR.error=e;return TRY_CATCH_ERROR}}function invokeCallback(settled,promise,callback,detail){var hasCallback=isFunction(callback),value=undefined,error=undefined,succeeded=undefined,failed=undefined;if(hasCallback){value=tryCatch(callback,detail);if(value===TRY_CATCH_ERROR){failed=true;error=value.error;value=null}else{succeeded=true}if(promise===value){reject(promise,withOwnPromise());return}}else{value=detail;succeeded=true}if(promise._state!==PENDING){}else if(hasCallback&&succeeded){resolve(promise,value)}else if(failed){reject(promise,error)}else if(settled===FULFILLED){fulfill(promise,value)}else if(settled===REJECTED){reject(promise,value)}}function initializePromise(promise,resolver){var resolved=false;try{resolver(function(value){if(resolved){return}resolved=true;resolve(promise,value)},function(reason){if(resolved){return}resolved=true;reject(promise,reason)})}catch(e){reject(promise,e)}}function then(onFulfillment,onRejection,label){var _arguments=arguments;var parent=this;var state=parent._state;if(state===FULFILLED&&!onFulfillment||state===REJECTED&&!onRejection){config.instrument&&instrument("chained",parent,parent);return parent}parent._onError=null;var child=new parent.constructor(noop,label);var result=parent._result;config.instrument&&instrument("chained",parent,child);if(state){(function(){var callback=_arguments[state-1];config.async(function(){return invokeCallback(state,child,callback,result)})})()}else{subscribe(parent,child,onFulfillment,onRejection)}return child}function makeSettledResult(state,position,value){if(state===FULFILLED){return{state:"fulfilled",value:value}}else{return{state:"rejected",reason:value}}}function Enumerator(Constructor,input,abortOnReject,label){this._instanceConstructor=Constructor;this.promise=new Constructor(noop,label);this._abortOnReject=abortOnReject;if(this._validateInput(input)){this._input=input;this.length=input.length;this._remaining=input.length;this._init();if(this.length===0){fulfill(this.promise,this._result)}else{this.length=this.length||0;this._enumerate();if(this._remaining===0){fulfill(this.promise,this._result)}}}else{reject(this.promise,this._validationError())}}Enumerator.prototype._validateInput=function(input){return isArray(input)};Enumerator.prototype._validationError=function(){return new Error("Array Methods must be provided an Array")};Enumerator.prototype._init=function(){this._result=new Array(this.length)};Enumerator.prototype._enumerate=function(){var length=this.length;var promise=this.promise;var input=this._input;for(var i=0;promise._state===PENDING&&i<length;i++){this._eachEntry(input[i],i)}};Enumerator.prototype._settleMaybeThenable=function(entry,i){var c=this._instanceConstructor;var resolve=c.resolve;if(resolve===resolve$1){var then$$=getThen(entry);if(then$$===then&&entry._state!==PENDING){entry._onError=null;this._settledAt(entry._state,i,entry._result)}else if(typeof then$$!=="function"){this._remaining--;this._result[i]=this._makeResult(FULFILLED,i,entry)}else if(c===Promise){var promise=new c(noop);handleMaybeThenable(promise,entry,then$$);this._willSettleAt(promise,i)}else{this._willSettleAt(new c(function(resolve){return resolve(entry)}),i)}}else{this._willSettleAt(resolve(entry),i)}};Enumerator.prototype._eachEntry=function(entry,i){if(isMaybeThenable(entry)){this._settleMaybeThenable(entry,i)}else{this._remaining--;this._result[i]=this._makeResult(FULFILLED,i,entry)}};Enumerator.prototype._settledAt=function(state,i,value){var promise=this.promise;if(promise._state===PENDING){this._remaining--;if(this._abortOnReject&&state===REJECTED){reject(promise,value)}else{this._result[i]=this._makeResult(state,i,value)}}if(this._remaining===0){fulfill(promise,this._result)}};Enumerator.prototype._makeResult=function(state,i,value){return value};Enumerator.prototype._willSettleAt=function(promise,i){var enumerator=this;subscribe(promise,undefined,function(value){return enumerator._settledAt(FULFILLED,i,value)},function(reason){return enumerator._settledAt(REJECTED,i,reason)})};function all(entries,label){return new Enumerator(this,entries,true,label).promise}function race(entries,label){var Constructor=this;var promise=new Constructor(noop,label);if(!isArray(entries)){reject(promise,new TypeError("You must pass an array to race."));return promise}for(var i=0;promise._state===PENDING&&i<entries.length;i++){subscribe(Constructor.resolve(entries[i]),undefined,function(value){return resolve(promise,value)},function(reason){return reject(promise,reason)})}return promise}function reject$1(reason,label){var Constructor=this;var promise=new Constructor(noop,label);reject(promise,reason);return promise}var guidKey="rsvp_"+now()+"-";var counter=0;function needsResolver(){throw new TypeError("You must pass a resolver function as the first argument to the promise constructor")}function needsNew(){throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.")}function Promise(resolver,label){this._id=counter++;this._label=label;this._state=undefined;this._result=undefined;this._subscribers=[];config.instrument&&instrument("created",this);if(noop!==resolver){typeof resolver!=="function"&&needsResolver();this instanceof Promise?initializePromise(this,resolver):needsNew()}}Promise.cast=resolve$1;Promise.all=all;Promise.race=race;Promise.resolve=resolve$1;Promise.reject=reject$1;Promise.prototype={constructor:Promise,_guidKey:guidKey,_onError:function _onError(reason){var promise=this;config.after(function(){if(promise._onError){config["trigger"]("error",reason,promise._label)}})},then:then,"catch":function _catch(onRejection,label){return this.then(undefined,onRejection,label)},"finally":function _finally(callback,label){var promise=this;var constructor=promise.constructor;return promise.then(function(value){return constructor.resolve(callback()).then(function(){return value})},function(reason){return constructor.resolve(callback()).then(function(){throw reason})},label)}};function Result(){this.value=undefined}var ERROR=new Result;var GET_THEN_ERROR$1=new Result;function getThen$1(obj){try{return obj.then}catch(error){ERROR.value=error;return ERROR}}function tryApply(f,s,a){try{f.apply(s,a)}catch(error){ERROR.value=error;return ERROR}}function makeObject(_,argumentNames){var obj={};var length=_.length;var args=new Array(length);for(var x=0;x<length;x++){args[x]=_[x]}for(var i=0;i<argumentNames.length;i++){var _name=argumentNames[i];obj[_name]=args[i+1]}return obj}function arrayResult(_){var length=_.length;var args=new Array(length-1);for(var i=1;i<length;i++){args[i-1]=_[i]}return args}function wrapThenable(_then,promise){return{then:function then(onFulFillment,onRejection){return _then.call(promise,onFulFillment,onRejection)}}}function denodeify(nodeFunc,options){var fn=function fn(){var self=this;var l=arguments.length;var args=new Array(l+1);var promiseInput=false;for(var i=0;i<l;++i){var arg=arguments[i];if(!promiseInput){promiseInput=needsPromiseInput(arg);if(promiseInput===GET_THEN_ERROR$1){var p=new Promise(noop);reject(p,GET_THEN_ERROR$1.value);return p}else if(promiseInput&&promiseInput!==true){arg=wrapThenable(promiseInput,arg)}}args[i]=arg}var promise=new Promise(noop);args[l]=function(err,val){if(err)reject(promise,err);else if(options===undefined)resolve(promise,val);else if(options===true)resolve(promise,arrayResult(arguments));else if(isArray(options))resolve(promise,makeObject(arguments,options));else resolve(promise,val)};if(promiseInput){return handlePromiseInput(promise,args,nodeFunc,self)}else{return handleValueInput(promise,args,nodeFunc,self)}};fn.__proto__=nodeFunc;return fn}function handleValueInput(promise,args,nodeFunc,self){var result=tryApply(nodeFunc,self,args);if(result===ERROR){reject(promise,result.value)}return promise}function handlePromiseInput(promise,args,nodeFunc,self){return Promise.all(args).then(function(args){var result=tryApply(nodeFunc,self,args);if(result===ERROR){reject(promise,result.value)}return promise})}function needsPromiseInput(arg){if(arg&&typeof arg==="object"){if(arg.constructor===Promise){return true}else{return getThen$1(arg)}}else{return false}}function all$1(array,label){return Promise.all(array,label)}function AllSettled(Constructor,entries,label){this._superConstructor(Constructor,entries,false,label)}AllSettled.prototype=o_create(Enumerator.prototype);AllSettled.prototype._superConstructor=Enumerator;AllSettled.prototype._makeResult=makeSettledResult;AllSettled.prototype._validationError=function(){return new Error("allSettled must be called with an array")};function allSettled(entries,label){return new AllSettled(Promise,entries,label).promise}function race$1(array,label){return Promise.race(array,label)}function PromiseHash(Constructor,object,label){this._superConstructor(Constructor,object,true,label)}PromiseHash.prototype=o_create(Enumerator.prototype);PromiseHash.prototype._superConstructor=Enumerator;PromiseHash.prototype._init=function(){this._result={}};PromiseHash.prototype._validateInput=function(input){return input&&typeof input==="object"};PromiseHash.prototype._validationError=function(){return new Error("Promise.hash must be called with an object")};PromiseHash.prototype._enumerate=function(){var enumerator=this;var promise=enumerator.promise;var input=enumerator._input;var results=[];for(var key in input){if(promise._state===PENDING&&Object.prototype.hasOwnProperty.call(input,key)){results.push({position:key,entry:input[key]})}}var length=results.length;enumerator._remaining=length;var result=undefined;for(var i=0;promise._state===PENDING&&i<length;i++){result=results[i];enumerator._eachEntry(result.entry,result.position)}};function hash(object,label){return new PromiseHash(Promise,object,label).promise}function HashSettled(Constructor,object,label){this._superConstructor(Constructor,object,false,label)}HashSettled.prototype=o_create(PromiseHash.prototype);HashSettled.prototype._superConstructor=Enumerator;HashSettled.prototype._makeResult=makeSettledResult;HashSettled.prototype._validationError=function(){return new Error("hashSettled must be called with an object")};function hashSettled(object,label){return new HashSettled(Promise,object,label).promise}function rethrow(reason){setTimeout(function(){throw reason});throw reason}function defer(label){var deferred={resolve:undefined,reject:undefined};deferred.promise=new Promise(function(resolve,reject){deferred.resolve=resolve;deferred.reject=reject},label);return deferred}function map(promises,mapFn,label){return Promise.all(promises,label).then(function(values){if(!isFunction(mapFn)){throw new TypeError("You must pass a function as map's second argument.")}var length=values.length;var results=new Array(length);for(var i=0;i<length;i++){results[i]=mapFn(values[i])}return Promise.all(results,label)})}function resolve$2(value,label){return Promise.resolve(value,label)}function reject$2(reason,label){return Promise.reject(reason,label)}function resolveAll(promises,label){return Promise.all(promises,label)}function resolveSingle(promise,label){return Promise.resolve(promise,label).then(function(promises){return resolveAll(promises,label)})}function filter(promises,filterFn,label){var promise=isArray(promises)?resolveAll(promises,label):resolveSingle(promises,label);return promise.then(function(values){if(!isFunction(filterFn)){throw new TypeError("You must pass a function as filter's second argument.")}var length=values.length;var filtered=new Array(length);for(var i=0;i<length;i++){filtered[i]=filterFn(values[i])}return resolveAll(filtered,label).then(function(filtered){var results=new Array(length);var newLength=0;for(var i=0;i<length;i++){if(filtered[i]){results[newLength]=values[i];newLength++}}results.length=newLength;return results})})}var len=0;var vertxNext=undefined;function asap(callback,arg){queue$1[len]=callback;queue$1[len+1]=arg;len+=2;if(len===2){scheduleFlush$1()}}var browserWindow=typeof window!=="undefined"?window:undefined;var browserGlobal=browserWindow||{};var BrowserMutationObserver=browserGlobal.MutationObserver||browserGlobal.WebKitMutationObserver;var isNode=typeof self==="undefined"&&typeof process!=="undefined"&&{}.toString.call(process)==="[object process]";var isWorker=typeof Uint8ClampedArray!=="undefined"&&typeof importScripts!=="undefined"&&typeof MessageChannel!=="undefined";function useNextTick(){var nextTick=process.nextTick;var version=process.versions.node.match(/^(?:(\d+)\.)?(?:(\d+)\.)?(\*|\d+)$/);if(Array.isArray(version)&&version[1]==="0"&&version[2]==="10"){nextTick=setImmediate}return function(){return nextTick(flush)}}function useVertxTimer(){if(typeof vertxNext!=="undefined"){return function(){vertxNext(flush)}}return useSetTimeout()}function useMutationObserver(){var iterations=0;var observer=new BrowserMutationObserver(flush);var node=document.createTextNode("");observer.observe(node,{characterData:true});return function(){return node.data=iterations=++iterations%2}}function useMessageChannel(){var channel=new MessageChannel;channel.port1.onmessage=flush;return function(){return channel.port2.postMessage(0)}}function useSetTimeout(){return function(){return setTimeout(flush,1)}}var queue$1=new Array(1e3);function flush(){for(var i=0;i<len;i+=2){var callback=queue$1[i];var arg=queue$1[i+1];callback(arg);queue$1[i]=undefined;queue$1[i+1]=undefined}len=0}function attemptVertex(){try{var r=require;var vertx=r("vertx");vertxNext=vertx.runOnLoop||vertx.runOnContext;return useVertxTimer()}catch(e){return useSetTimeout()}}var scheduleFlush$1=undefined;if(isNode){scheduleFlush$1=useNextTick()}else if(BrowserMutationObserver){scheduleFlush$1=useMutationObserver()}else if(isWorker){scheduleFlush$1=useMessageChannel()}else if(browserWindow===undefined&&typeof require==="function"){scheduleFlush$1=attemptVertex()}else{scheduleFlush$1=useSetTimeout()}var platform=undefined;if(typeof self==="object"){platform=self}else if(typeof global==="object"){platform=global}else{throw new Error("no global: `self` or `global` found")}var _async$filter;function _defineProperty(obj,key,value){if(key in obj){Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})}else{obj[key]=value}return obj}config.async=asap;config.after=function(cb){return setTimeout(cb,0)};var cast=resolve$2;var async=function async(callback,arg){return config.async(callback,arg)};function on(){config["on"].apply(config,arguments)}function off(){config["off"].apply(config,arguments)}if(typeof window!=="undefined"&&typeof window["__PROMISE_INSTRUMENTATION__"]==="object"){var callbacks=window["__PROMISE_INSTRUMENTATION__"];configure("instrument",true);for(var eventName in callbacks){if(callbacks.hasOwnProperty(eventName)){on(eventName,callbacks[eventName])}}}var rsvp=(_async$filter={cast:cast,Promise:Promise,EventTarget:EventTarget,all:all$1,allSettled:allSettled,race:race$1,hash:hash,hashSettled:hashSettled,rethrow:rethrow,defer:defer,denodeify:denodeify,configure:configure,on:on,off:off,resolve:resolve$2,reject:reject$2,map:map},_defineProperty(_async$filter,"async",async),_defineProperty(_async$filter,"filter",filter),_async$filter);exports["default"]=rsvp;exports.cast=cast;exports.Promise=Promise;exports.EventTarget=EventTarget;exports.all=all$1;exports.allSettled=allSettled;exports.race=race$1;exports.hash=hash;exports.hashSettled=hashSettled;exports.rethrow=rethrow;exports.defer=defer;exports.denodeify=denodeify;exports.configure=configure;exports.on=on;exports.off=off;exports.resolve=resolve$2;exports.reject=reject$2;exports.map=map;exports.async=async;exports.filter=filter;Object.defineProperty(exports,"__esModule",{value:true})})}).call(this,require("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{_process:1}]},{},[]);var Promise=require("rsvp").Promise;function MyCoolErr(){}function foo(){return new Promise(function(resolve,reject){console.log("We're running...");resolve()})}foo().then(function(){console.log("We're still running...");throw"any runtime err, incl. typos, invalid code etc.";console.log("We won't get here.")}).catch(function(err){if(err instanceof MyCoolErr){console.log("I know this error so will handle here");return}console.log("I did not recognise the error ...");throw err})},0);
{
"name": "requirebin-sketch",
"version": "1.0.0",
"dependencies": {
"rsvp": "3.3.3"
}
}
<!-- contents of this file will be placed inside the <body> -->
<div id="foo"></div>
<!-- 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