Socket
Socket
Sign inDemoInstall

async-try-catch

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

async-try-catch - npm Package Compare versions

Comparing version 0.1.5 to 0.1.6

1020

browser/AsyncTryCatch.js

@@ -372,302 +372,4 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.AsyncTryCatch = f()}})(function(){var define,module,exports;return (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){

}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"_process":3,"events":2,"nextgen-events":4}],2:[function(require,module,exports){
// Copyright Joyent, Inc. and other Node contributors.
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to permit
// persons to whom the Software is furnished to do so, subject to the
// following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
// USE OR OTHER DEALINGS IN THE SOFTWARE.
},{"_process":3,"events":2,"nextgen-events":2}],2:[function(require,module,exports){
function EventEmitter() {
this._events = this._events || {};
this._maxListeners = this._maxListeners || undefined;
}
module.exports = EventEmitter;
// Backwards-compat with node 0.10.x
EventEmitter.EventEmitter = EventEmitter;
EventEmitter.prototype._events = undefined;
EventEmitter.prototype._maxListeners = undefined;
// By default EventEmitters will print a warning if more than 10 listeners are
// added to it. This is a useful default which helps finding memory leaks.
EventEmitter.defaultMaxListeners = 10;
// Obviously not all Emitters should be limited to 10. This function allows
// that to be increased. Set to zero for unlimited.
EventEmitter.prototype.setMaxListeners = function(n) {
if (!isNumber(n) || n < 0 || isNaN(n))
throw TypeError('n must be a positive number');
this._maxListeners = n;
return this;
};
EventEmitter.prototype.emit = function(type) {
var er, handler, len, args, i, listeners;
if (!this._events)
this._events = {};
// If there is no 'error' event listener then throw.
if (type === 'error') {
if (!this._events.error ||
(isObject(this._events.error) && !this._events.error.length)) {
er = arguments[1];
if (er instanceof Error) {
throw er; // Unhandled 'error' event
}
throw TypeError('Uncaught, unspecified "error" event.');
}
}
handler = this._events[type];
if (isUndefined(handler))
return false;
if (isFunction(handler)) {
switch (arguments.length) {
// fast cases
case 1:
handler.call(this);
break;
case 2:
handler.call(this, arguments[1]);
break;
case 3:
handler.call(this, arguments[1], arguments[2]);
break;
// slower
default:
args = Array.prototype.slice.call(arguments, 1);
handler.apply(this, args);
}
} else if (isObject(handler)) {
args = Array.prototype.slice.call(arguments, 1);
listeners = handler.slice();
len = listeners.length;
for (i = 0; i < len; i++)
listeners[i].apply(this, args);
}
return true;
};
EventEmitter.prototype.addListener = function(type, listener) {
var m;
if (!isFunction(listener))
throw TypeError('listener must be a function');
if (!this._events)
this._events = {};
// To avoid recursion in the case that type === "newListener"! Before
// adding it to the listeners, first emit "newListener".
if (this._events.newListener)
this.emit('newListener', type,
isFunction(listener.listener) ?
listener.listener : listener);
if (!this._events[type])
// Optimize the case of one listener. Don't need the extra array object.
this._events[type] = listener;
else if (isObject(this._events[type]))
// If we've already got an array, just append.
this._events[type].push(listener);
else
// Adding the second element, need to change to array.
this._events[type] = [this._events[type], listener];
// Check for listener leak
if (isObject(this._events[type]) && !this._events[type].warned) {
if (!isUndefined(this._maxListeners)) {
m = this._maxListeners;
} else {
m = EventEmitter.defaultMaxListeners;
}
if (m && m > 0 && this._events[type].length > m) {
this._events[type].warned = true;
console.error('(node) warning: possible EventEmitter memory ' +
'leak detected. %d listeners added. ' +
'Use emitter.setMaxListeners() to increase limit.',
this._events[type].length);
if (typeof console.trace === 'function') {
// not supported in IE 10
console.trace();
}
}
}
return this;
};
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
EventEmitter.prototype.once = function(type, listener) {
if (!isFunction(listener))
throw TypeError('listener must be a function');
var fired = false;
function g() {
this.removeListener(type, g);
if (!fired) {
fired = true;
listener.apply(this, arguments);
}
}
g.listener = listener;
this.on(type, g);
return this;
};
// emits a 'removeListener' event iff the listener was removed
EventEmitter.prototype.removeListener = function(type, listener) {
var list, position, length, i;
if (!isFunction(listener))
throw TypeError('listener must be a function');
if (!this._events || !this._events[type])
return this;
list = this._events[type];
length = list.length;
position = -1;
if (list === listener ||
(isFunction(list.listener) && list.listener === listener)) {
delete this._events[type];
if (this._events.removeListener)
this.emit('removeListener', type, listener);
} else if (isObject(list)) {
for (i = length; i-- > 0;) {
if (list[i] === listener ||
(list[i].listener && list[i].listener === listener)) {
position = i;
break;
}
}
if (position < 0)
return this;
if (list.length === 1) {
list.length = 0;
delete this._events[type];
} else {
list.splice(position, 1);
}
if (this._events.removeListener)
this.emit('removeListener', type, listener);
}
return this;
};
EventEmitter.prototype.removeAllListeners = function(type) {
var key, listeners;
if (!this._events)
return this;
// not listening for removeListener, no need to emit
if (!this._events.removeListener) {
if (arguments.length === 0)
this._events = {};
else if (this._events[type])
delete this._events[type];
return this;
}
// emit removeListener for all listeners on all events
if (arguments.length === 0) {
for (key in this._events) {
if (key === 'removeListener') continue;
this.removeAllListeners(key);
}
this.removeAllListeners('removeListener');
this._events = {};
return this;
}
listeners = this._events[type];
if (isFunction(listeners)) {
this.removeListener(type, listeners);
} else if (listeners) {
// LIFO order
while (listeners.length)
this.removeListener(type, listeners[listeners.length - 1]);
}
delete this._events[type];
return this;
};
EventEmitter.prototype.listeners = function(type) {
var ret;
if (!this._events || !this._events[type])
ret = [];
else if (isFunction(this._events[type]))
ret = [this._events[type]];
else
ret = this._events[type].slice();
return ret;
};
EventEmitter.prototype.listenerCount = function(type) {
if (this._events) {
var evlistener = this._events[type];
if (isFunction(evlistener))
return 1;
else if (evlistener)
return evlistener.length;
}
return 0;
};
EventEmitter.listenerCount = function(emitter, type) {
return emitter.listenerCount(type);
};
function isFunction(arg) {
return typeof arg === 'function';
}
function isNumber(arg) {
return typeof arg === 'number';
}
function isObject(arg) {
return typeof arg === 'object' && arg !== null;
}
function isUndefined(arg) {
return arg === void 0;
}
},{}],3:[function(require,module,exports){

@@ -769,723 +471,3 @@ // shim for using process in browser

},{}],4:[function(require,module,exports){
/*
Next Gen Events
Copyright (c) 2015 - 2016 Cédric Ronvel
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
"use strict" ;
// Create the object && export it
function NextGenEvents() { return Object.create( NextGenEvents.prototype ) ; }
module.exports = NextGenEvents ;
/* Basic features, more or less compatible with Node.js */
NextGenEvents.SYNC = -Infinity ;
// Not part of the prototype, because it should not pollute userland's prototype.
// It has an eventEmitter as 'this' anyway (always called using call()).
NextGenEvents.init = function init()
{
Object.defineProperty( this , '__ngev' , { value: {
nice: NextGenEvents.SYNC ,
interruptible: false ,
recursion: 0 ,
contexts: {} ,
events: {
// Special events
error: [] ,
interrupt: [] ,
newListener: [] ,
removeListener: []
}
} } ) ;
} ;
// Use it with .bind()
NextGenEvents.filterOutCallback = function( what , currentElement ) { return what !== currentElement ; } ;
// .addListener( eventName , [fn] , [options] )
NextGenEvents.prototype.addListener = function addListener( eventName , fn , options )
{
var listener = {} ;
if ( ! this.__ngev ) { NextGenEvents.init.call( this ) ; }
if ( ! this.__ngev.events[ eventName ] ) { this.__ngev.events[ eventName ] = [] ; }
if ( ! eventName || typeof eventName !== 'string' ) { throw new TypeError( ".addListener(): argument #0 should be a non-empty string" ) ; }
if ( typeof fn !== 'function' )
{
options = fn ;
fn = undefined ;
}
if ( ! options || typeof options !== 'object' ) { options = {} ; }
listener.fn = fn || options.fn ;
listener.id = typeof options.id === 'string' ? options.id : listener.fn ;
listener.once = !! options.once ;
listener.async = !! options.async ;
listener.nice = options.nice !== undefined ? Math.floor( options.nice ) : NextGenEvents.SYNC ;
listener.context = typeof options.context === 'string' ? options.context : null ;
if ( typeof listener.fn !== 'function' )
{
throw new TypeError( ".addListener(): a function or an object with a 'fn' property which value is a function should be provided" ) ;
}
// Implicit context creation
if ( listener.context && typeof listener.context === 'string' && ! this.__ngev.contexts[ listener.context ] )
{
this.addListenerContext( listener.context ) ;
}
// Note: 'newListener' and 'removeListener' event return an array of listener, but not the event name.
// So the event's name can be retrieved in the listener itself.
listener.event = eventName ;
// We should emit 'newListener' first, before adding it to the listeners,
// to avoid recursion in the case that eventName === 'newListener'
if ( this.__ngev.events.newListener.length )
{
// Return an array, because .addListener() may support multiple event addition at once
// e.g.: .addListener( { request: onRequest, close: onClose, error: onError } ) ;
this.emit( 'newListener' , [ listener ] ) ;
}
this.__ngev.events[ eventName ].push( listener ) ;
return this ;
} ;
NextGenEvents.prototype.on = NextGenEvents.prototype.addListener ;
// Shortcut
NextGenEvents.prototype.once = function once( eventName , fn , options )
{
if ( fn && typeof fn === 'object' ) { fn.once = true ; }
else if ( options && typeof options === 'object' ) { options.once = true ; }
else { options = { once: true } ; }
return this.addListener( eventName , fn , options ) ;
} ;
NextGenEvents.prototype.removeListener = function removeListener( eventName , id )
{
var i , length , newListeners = [] , removedListeners = [] ;
if ( ! eventName || typeof eventName !== 'string' ) { throw new TypeError( ".removeListener(): argument #0 should be a non-empty string" ) ; }
if ( ! this.__ngev ) { NextGenEvents.init.call( this ) ; }
if ( ! this.__ngev.events[ eventName ] ) { this.__ngev.events[ eventName ] = [] ; }
length = this.__ngev.events[ eventName ].length ;
// It's probably faster to create a new array of listeners
for ( i = 0 ; i < length ; i ++ )
{
if ( this.__ngev.events[ eventName ][ i ].id === id )
{
removedListeners.push( this.__ngev.events[ eventName ][ i ] ) ;
}
else
{
newListeners.push( this.__ngev.events[ eventName ][ i ] ) ;
}
}
this.__ngev.events[ eventName ] = newListeners ;
if ( removedListeners.length && this.__ngev.events.removeListener.length )
{
this.emit( 'removeListener' , removedListeners ) ;
}
return this ;
} ;
NextGenEvents.prototype.off = NextGenEvents.prototype.removeListener ;
NextGenEvents.prototype.removeAllListeners = function removeAllListeners( eventName )
{
var removedListeners ;
if ( ! this.__ngev ) { NextGenEvents.init.call( this ) ; }
if ( eventName )
{
// Remove all listeners for a particular event
if ( ! eventName || typeof eventName !== 'string' ) { throw new TypeError( ".removeAllListener(): argument #0 should be undefined or a non-empty string" ) ; }
if ( ! this.__ngev.events[ eventName ] ) { this.__ngev.events[ eventName ] = [] ; }
removedListeners = this.__ngev.events[ eventName ] ;
this.__ngev.events[ eventName ] = [] ;
if ( removedListeners.length && this.__ngev.events.removeListener.length )
{
this.emit( 'removeListener' , removedListeners ) ;
}
}
else
{
// Remove all listeners for any events
// 'removeListener' listeners cannot be triggered: they are already deleted
this.__ngev.events = {} ;
}
return this ;
} ;
NextGenEvents.listenerWrapper = function listenerWrapper( listener , event , context )
{
var returnValue , serial ;
if ( event.interrupt ) { return ; }
if ( listener.async )
{
//serial = context && context.serial ;
if ( context )
{
serial = context.serial ;
context.ready = ! serial ;
}
returnValue = listener.fn.apply( undefined , event.args.concat( function( arg ) {
event.listenersDone ++ ;
// Async interrupt
if ( arg && event.emitter.__ngev.interruptible && ! event.interrupt && event.name !== 'interrupt' )
{
event.interrupt = arg ;
if ( event.callback )
{
event.callback( event.interrupt , event ) ;
delete event.callback ;
}
event.emitter.emit( 'interrupt' , event.interrupt ) ;
}
else if ( event.listenersDone >= event.listeners && event.callback )
{
event.callback( undefined , event ) ;
delete event.callback ;
}
// Process the queue if serialized
if ( serial ) { NextGenEvents.processQueue.call( event.emitter , listener.context , true ) ; }
} ) ) ;
}
else
{
returnValue = listener.fn.apply( undefined , event.args ) ;
event.listenersDone ++ ;
}
// Interrupt if non-falsy return value, if the emitter is interruptible, not already interrupted (emit once),
// and not within an 'interrupt' event.
if ( returnValue && event.emitter.__ngev.interruptible && ! event.interrupt && event.name !== 'interrupt' )
{
event.interrupt = returnValue ;
if ( event.callback )
{
event.callback( event.interrupt , event ) ;
delete event.callback ;
}
event.emitter.emit( 'interrupt' , event.interrupt ) ;
}
else if ( event.listenersDone >= event.listeners && event.callback )
{
event.callback( undefined , event ) ;
delete event.callback ;
}
} ;
// A unique event ID
var nextEventId = 0 ;
/*
emit( [nice] , eventName , [arg1] , [arg2] , [...] , [emitCallback] )
*/
NextGenEvents.prototype.emit = function emit()
{
var i , iMax , count = 0 ,
event , listener , context , currentNice ,
listeners , removedListeners = [] ;
event = {
emitter: this ,
id: nextEventId ++ ,
name: null ,
args: null ,
nice: null ,
interrupt: null ,
listeners: null ,
listenersDone: 0 ,
callback: null ,
} ;
if ( ! this.__ngev ) { NextGenEvents.init.call( this ) ; }
// Arguments handling
if ( typeof arguments[ 0 ] === 'number' )
{
event.nice = Math.floor( arguments[ 0 ] ) ;
event.name = arguments[ 1 ] ;
if ( ! event.name || typeof event.name !== 'string' ) { throw new TypeError( ".emit(): when argument #0 is a number, argument #1 should be a non-empty string" ) ; }
if ( typeof arguments[ arguments.length - 1 ] === 'function' )
{
event.callback = arguments[ arguments.length - 1 ] ;
event.args = Array.prototype.slice.call( arguments , 2 , -1 ) ;
}
else
{
event.args = Array.prototype.slice.call( arguments , 2 ) ;
}
}
else
{
event.nice = this.__ngev.nice ;
event.name = arguments[ 0 ] ;
if ( ! event.name || typeof event.name !== 'string' ) { throw new TypeError( ".emit(): argument #0 should be an number or a non-empty string" ) ; }
event.args = Array.prototype.slice.call( arguments , 1 ) ;
if ( typeof arguments[ arguments.length - 1 ] === 'function' )
{
event.callback = arguments[ arguments.length - 1 ] ;
event.args = Array.prototype.slice.call( arguments , 1 , -1 ) ;
}
else
{
event.args = Array.prototype.slice.call( arguments , 1 ) ;
}
}
if ( ! this.__ngev.events[ event.name ] ) { this.__ngev.events[ event.name ] = [] ; }
// Increment this.__ngev.recursion
event.listeners = this.__ngev.events[ event.name ].length ;
this.__ngev.recursion ++ ;
// Trouble arise when a listener is removed from another listener, while we are still in the loop.
// So we have to COPY the listener array right now!
listeners = this.__ngev.events[ event.name ].slice() ;
for ( i = 0 , iMax = listeners.length ; i < iMax ; i ++ )
{
count ++ ;
listener = listeners[ i ] ;
context = listener.context && this.__ngev.contexts[ listener.context ] ;
// If the listener context is disabled...
if ( context && context.status === NextGenEvents.CONTEXT_DISABLED ) { continue ; }
// The nice value for this listener...
if ( context ) { currentNice = Math.max( event.nice , listener.nice , context.nice ) ; }
else { currentNice = Math.max( event.nice , listener.nice ) ; }
if ( listener.once )
{
// We should remove the current listener RIGHT NOW because of recursive .emit() issues:
// one listener may eventually fire this very same event synchronously during the current loop.
this.__ngev.events[ event.name ] = this.__ngev.events[ event.name ].filter(
NextGenEvents.filterOutCallback.bind( undefined , listener )
) ;
removedListeners.push( listener ) ;
}
if ( context && ( context.status === NextGenEvents.CONTEXT_QUEUED || ! context.ready ) )
{
// Almost all works should be done by .emit(), and little few should be done by .processQueue()
context.queue.push( { event: event , listener: listener , nice: currentNice } ) ;
}
else
{
try {
if ( currentNice < 0 )
{
if ( this.__ngev.recursion >= - currentNice )
{
setImmediate( NextGenEvents.listenerWrapper.bind( this , listener , event , context ) ) ;
}
else
{
NextGenEvents.listenerWrapper.call( this , listener , event , context ) ;
}
}
else
{
setTimeout( NextGenEvents.listenerWrapper.bind( this , listener , event , context ) , currentNice ) ;
}
}
catch ( error ) {
// Catch error, just to decrement this.__ngev.recursion, re-throw after that...
this.__ngev.recursion -- ;
throw error ;
}
}
}
// Decrement recursion
this.__ngev.recursion -- ;
// Emit 'removeListener' after calling listeners
if ( removedListeners.length && this.__ngev.events.removeListener.length )
{
this.emit( 'removeListener' , removedListeners ) ;
}
// 'error' event is a special case: it should be listened for, or it will throw an error
if ( ! count )
{
if ( event.name === 'error' )
{
if ( arguments[ 1 ] ) { throw arguments[ 1 ] ; }
else { throw Error( "Uncaught, unspecified 'error' event." ) ; }
}
if ( event.callback )
{
event.callback( undefined , event ) ;
delete event.callback ;
}
}
return event ;
} ;
NextGenEvents.prototype.listeners = function listeners( eventName )
{
if ( ! eventName || typeof eventName !== 'string' ) { throw new TypeError( ".listeners(): argument #0 should be a non-empty string" ) ; }
if ( ! this.__ngev ) { NextGenEvents.init.call( this ) ; }
if ( ! this.__ngev.events[ eventName ] ) { this.__ngev.events[ eventName ] = [] ; }
// Do not return the array, shallow copy it
return this.__ngev.events[ eventName ].slice() ;
} ;
NextGenEvents.listenerCount = function( emitter , eventName )
{
if ( ! emitter || ! ( emitter instanceof NextGenEvents ) ) { throw new TypeError( ".listenerCount(): argument #0 should be an instance of NextGenEvents" ) ; }
return emitter.listenerCount( eventName ) ;
} ;
NextGenEvents.prototype.listenerCount = function( eventName )
{
if ( ! eventName || typeof eventName !== 'string' ) { throw new TypeError( ".listenerCount(): argument #1 should be a non-empty string" ) ; }
if ( ! this.__ngev ) { NextGenEvents.init.call( this ) ; }
if ( ! this.__ngev.events[ eventName ] ) { this.__ngev.events[ eventName ] = [] ; }
return this.__ngev.events[ eventName ].length ;
} ;
NextGenEvents.prototype.setNice = function setNice( nice )
{
if ( ! this.__ngev ) { NextGenEvents.init.call( this ) ; }
//if ( typeof nice !== 'number' ) { throw new TypeError( ".setNice(): argument #0 should be a number" ) ; }
this.__ngev.nice = Math.floor( +nice || 0 ) ;
} ;
NextGenEvents.prototype.setInterruptible = function setInterruptible( value )
{
if ( ! this.__ngev ) { NextGenEvents.init.call( this ) ; }
//if ( typeof nice !== 'number' ) { throw new TypeError( ".setNice(): argument #0 should be a number" ) ; }
this.__ngev.interruptible = !! value ;
} ;
// There is no such thing in NextGenEvents, however, we need to be compatible with node.js events at best
NextGenEvents.prototype.setMaxListeners = function() {} ;
// Sometime useful as a no-op callback...
NextGenEvents.noop = function() {} ;
/* Next Gen feature: contexts! */
NextGenEvents.CONTEXT_ENABLED = 0 ;
NextGenEvents.CONTEXT_DISABLED = 1 ;
NextGenEvents.CONTEXT_QUEUED = 2 ;
NextGenEvents.prototype.addListenerContext = function addListenerContext( contextName , options )
{
if ( ! this.__ngev ) { NextGenEvents.init.call( this ) ; }
if ( ! contextName || typeof contextName !== 'string' ) { throw new TypeError( ".addListenerContext(): argument #0 should be a non-empty string" ) ; }
if ( ! options || typeof options !== 'object' ) { options = {} ; }
if ( ! this.__ngev.contexts[ contextName ] )
{
// A context IS an event emitter too!
this.__ngev.contexts[ contextName ] = Object.create( NextGenEvents.prototype ) ;
this.__ngev.contexts[ contextName ].nice = NextGenEvents.SYNC ;
this.__ngev.contexts[ contextName ].ready = true ;
this.__ngev.contexts[ contextName ].status = NextGenEvents.CONTEXT_ENABLED ;
this.__ngev.contexts[ contextName ].serial = false ;
this.__ngev.contexts[ contextName ].queue = [] ;
}
if ( options.nice !== undefined ) { this.__ngev.contexts[ contextName ].nice = Math.floor( options.nice ) ; }
if ( options.status !== undefined ) { this.__ngev.contexts[ contextName ].status = options.status ; }
if ( options.serial !== undefined ) { this.__ngev.contexts[ contextName ].serial = !! options.serial ; }
return this ;
} ;
NextGenEvents.prototype.disableListenerContext = function disableListenerContext( contextName )
{
if ( ! this.__ngev ) { NextGenEvents.init.call( this ) ; }
if ( ! contextName || typeof contextName !== 'string' ) { throw new TypeError( ".disableListenerContext(): argument #0 should be a non-empty string" ) ; }
if ( ! this.__ngev.contexts[ contextName ] ) { this.addListenerContext( contextName ) ; }
this.__ngev.contexts[ contextName ].status = NextGenEvents.CONTEXT_DISABLED ;
return this ;
} ;
NextGenEvents.prototype.enableListenerContext = function enableListenerContext( contextName )
{
if ( ! this.__ngev ) { NextGenEvents.init.call( this ) ; }
if ( ! contextName || typeof contextName !== 'string' ) { throw new TypeError( ".enableListenerContext(): argument #0 should be a non-empty string" ) ; }
if ( ! this.__ngev.contexts[ contextName ] ) { this.addListenerContext( contextName ) ; }
this.__ngev.contexts[ contextName ].status = NextGenEvents.CONTEXT_ENABLED ;
if ( this.__ngev.contexts[ contextName ].queue.length > 0 ) { NextGenEvents.processQueue.call( this , contextName ) ; }
return this ;
} ;
NextGenEvents.prototype.queueListenerContext = function queueListenerContext( contextName )
{
if ( ! this.__ngev ) { NextGenEvents.init.call( this ) ; }
if ( ! contextName || typeof contextName !== 'string' ) { throw new TypeError( ".queueListenerContext(): argument #0 should be a non-empty string" ) ; }
if ( ! this.__ngev.contexts[ contextName ] ) { this.addListenerContext( contextName ) ; }
this.__ngev.contexts[ contextName ].status = NextGenEvents.CONTEXT_QUEUED ;
return this ;
} ;
NextGenEvents.prototype.serializeListenerContext = function serializeListenerContext( contextName , value )
{
if ( ! this.__ngev ) { NextGenEvents.init.call( this ) ; }
if ( ! contextName || typeof contextName !== 'string' ) { throw new TypeError( ".serializeListenerContext(): argument #0 should be a non-empty string" ) ; }
if ( ! this.__ngev.contexts[ contextName ] ) { this.addListenerContext( contextName ) ; }
this.__ngev.contexts[ contextName ].serial = value === undefined ? true : !! value ;
return this ;
} ;
NextGenEvents.prototype.setListenerContextNice = function setListenerContextNice( contextName , nice )
{
if ( ! this.__ngev ) { NextGenEvents.init.call( this ) ; }
if ( ! contextName || typeof contextName !== 'string' ) { throw new TypeError( ".setListenerContextNice(): argument #0 should be a non-empty string" ) ; }
if ( ! this.__ngev.contexts[ contextName ] ) { this.addListenerContext( contextName ) ; }
this.__ngev.contexts[ contextName ].nice = Math.floor( nice ) ;
return this ;
} ;
NextGenEvents.prototype.destroyListenerContext = function destroyListenerContext( contextName )
{
var i , length , eventName , newListeners , removedListeners = [] ;
if ( ! contextName || typeof contextName !== 'string' ) { throw new TypeError( ".disableListenerContext(): argument #0 should be a non-empty string" ) ; }
if ( ! this.__ngev ) { NextGenEvents.init.call( this ) ; }
// We don't care if a context actually exists, all listeners tied to that contextName will be removed
for ( eventName in this.__ngev.events )
{
newListeners = null ;
length = this.__ngev.events[ eventName ].length ;
for ( i = 0 ; i < length ; i ++ )
{
if ( this.__ngev.events[ eventName ][ i ].context === contextName )
{
newListeners = [] ;
removedListeners.push( this.__ngev.events[ eventName ][ i ] ) ;
}
else if ( newListeners )
{
newListeners.push( this.__ngev.events[ eventName ][ i ] ) ;
}
}
if ( newListeners ) { this.__ngev.events[ eventName ] = newListeners ; }
}
if ( this.__ngev.contexts[ contextName ] ) { delete this.__ngev.contexts[ contextName ] ; }
if ( removedListeners.length && this.__ngev.events.removeListener.length )
{
this.emit( 'removeListener' , removedListeners ) ;
}
return this ;
} ;
// To be used with .call(), it should not pollute the prototype
NextGenEvents.processQueue = function processQueue( contextName , isCompletionCallback )
{
var context , job ;
// The context doesn't exist anymore, so just abort now
if ( ! this.__ngev.contexts[ contextName ] ) { return ; }
context = this.__ngev.contexts[ contextName ] ;
if ( isCompletionCallback ) { context.ready = true ; }
// Should work on serialization here
//console.log( ">>> " , context ) ;
// Increment recursion
this.__ngev.recursion ++ ;
while ( context.ready && context.queue.length )
{
job = context.queue.shift() ;
// This event has been interrupted, drop it now!
if ( job.event.interrupt ) { continue ; }
try {
if ( job.nice < 0 )
{
if ( this.__ngev.recursion >= - job.nice )
{
setImmediate( NextGenEvents.listenerWrapper.bind( this , job.listener , job.event , context ) ) ;
}
else
{
NextGenEvents.listenerWrapper.call( this , job.listener , job.event , context ) ;
}
}
else
{
setTimeout( NextGenEvents.listenerWrapper.bind( this , job.listener , job.event , context ) , job.nice ) ;
}
}
catch ( error ) {
// Catch error, just to decrement this.__ngev.recursion, re-throw after that...
this.__ngev.recursion -- ;
throw error ;
}
}
// Decrement recursion
this.__ngev.recursion -- ;
} ;
// Backup for the AsyncTryCatch
NextGenEvents.on = NextGenEvents.prototype.on ;
NextGenEvents.once = NextGenEvents.prototype.once ;
NextGenEvents.off = NextGenEvents.prototype.off ;
},{}]},{},[1])(1)
});

2

browser/AsyncTryCatch.min.js

@@ -1,1 +0,1 @@

(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.AsyncTryCatch=e()}})(function(){var e,t,n;return function i(e,t,n){function s(o,a){if(!t[o]){if(!e[o]){var l=typeof require=="function"&&require;if(!a&&l)return l(o,!0);if(r)return r(o,!0);var c=new Error("Cannot find module '"+o+"'");throw c.code="MODULE_NOT_FOUND",c}var f=t[o]={exports:{}};e[o][0].call(f.exports,function(t){var n=e[o][1][t];return s(n?n:t)},f,f.exports,i,e,t,n)}return t[o].exports}var r=typeof require=="function"&&require;for(var o=0;o<n.length;o++)s(n[o]);return s}({1:[function(e,t,n){(function(n,i){"use strict";function s(){throw new Error("Use AsyncTryCatch.try() instead.")}t.exports=s;i.AsyncTryCatch=s;if(n.browser&&!i.setImmediate){i.setImmediate=function r(e){return setTimeout(e,0)};i.clearImmediate=function o(e){return clearTimeout(e)}}if(!i.Vanilla){i.Vanilla={};if(!i.Vanilla.setTimeout){i.Vanilla.setTimeout=setTimeout}if(!i.Vanilla.setImmediate){i.Vanilla.setImmediate=setImmediate}if(!i.Vanilla.nextTick){i.Vanilla.nextTick=n.nextTick}}s.stack=[];s.substituted=false;s.try=function a(e){var t=Object.create(s.prototype,{fn:{value:e,enumerable:true},parent:{value:s.stack[s.stack.length-1]}});return t};s.prototype.catch=function l(e){Object.defineProperties(this,{catchFn:{value:e,enumerable:true}});if(!s.substituted){s.substitute()}try{s.stack.push(this);this.fn();s.stack.pop()}catch(t){s.stack.pop();this.callCatchFn(t)}};s.prototype.callCatchFn=function c(e){if(!this.parent){this.catchFn(e);return}try{s.stack.push(this.parent);this.catchFn(e);s.stack.pop()}catch(e){s.stack.pop();this.parent.callCatchFn(e)}};s.timerWrapper=function f(e,t){var t,n,i,r=Array.prototype.slice.call(arguments,1);if(typeof t!=="function"||!s.stack.length){return e.apply(this,r)}n=s.stack[s.stack.length-1];i=function(){try{s.stack.push(n);t.apply(this,arguments);s.stack.pop()}catch(e){s.stack.pop();n.callCatchFn(e)}};r[0]=i;return e.apply(this,r)};s.addListenerWrapper=function h(e,t,n,i){var n,r,o;if(typeof n==="object"){i=n;n=i.fn;delete i.fn}if(typeof n!=="function"||!s.stack.length){return e.call(this,t,n,i)}r=s.stack[s.stack.length-1];if(this.__fnToWrapperMap){o=this.__fnToWrapperMap.get(n)}else{Object.defineProperty(this,"__fnToWrapperMap",{value:new WeakMap})}if(!o){o=function(){try{s.stack.push(r);n.apply(this,arguments);s.stack.pop()}catch(e){s.stack.pop();r.callCatchFn(e)}};this.__fnToWrapperMap.set(n,o)}return e.call(this,t,o,i)};s.removeListenerWrapper=function u(e,t,n){if(typeof n==="function"&&this.__fnToWrapperMap){n=this.__fnToWrapperMap.get(n)||n}return e.call(this,t,n)};s.setTimeout=s.timerWrapper.bind(undefined,i.Vanilla.setTimeout);s.setImmediate=s.timerWrapper.bind(undefined,i.Vanilla.setImmediate);s.nextTick=s.timerWrapper.bind(n,i.Vanilla.nextTick);s.addListener=function p(e,t){s.addListenerWrapper.call(this,s.NodeEvents.__addListener,e,t)};s.addListenerOnce=function v(e,t){s.addListenerWrapper.call(this,s.NodeEvents.__addListenerOnce,e,t)};s.removeListener=function _(e,t){s.removeListenerWrapper.call(this,s.NodeEvents.__removeListener,e,t)};s.ngevAddListener=function d(e,t,n){s.addListenerWrapper.call(this,s.NextGenEvents.on,e,t,n)};s.ngevAddListenerOnce=function g(e,t,n){s.addListenerWrapper.call(this,s.NextGenEvents.once,e,t,n)};s.ngevRemoveListener=function y(e,t){s.removeListenerWrapper.call(this,s.NextGenEvents.off,e,t)};s.substitute=function m(){s.substituted=true;i.setTimeout=s.setTimeout;i.setImmediate=s.setTimeout;n.nextTick=s.nextTick;try{s.NodeEvents=i.EventEmitter||e("events")}catch(t){}try{s.NextGenEvents=i.NextGenEvents||e("nextgen-events")}catch(t){}if(s.NodeEvents){if(!s.NodeEvents.__addListener){s.NodeEvents.__addListener=s.NodeEvents.prototype.on}if(!s.NodeEvents.__addListenerOnce){s.NodeEvents.__addListenerOnce=s.NodeEvents.prototype.addListenerOnce}if(!s.NodeEvents.__removeListener){s.NodeEvents.__removeListener=s.NodeEvents.prototype.removeListener}s.NodeEvents.prototype.on=s.addListener;s.NodeEvents.prototype.addListener=s.addListener;s.NodeEvents.prototype.once=s.addListenerOnce;s.NodeEvents.prototype.removeListener=s.removeListener}if(s.NextGenEvents){s.NextGenEvents.prototype.on=s.ngevAddListener;s.NextGenEvents.prototype.addListener=s.ngevAddListener;s.NextGenEvents.prototype.once=s.ngevAddListenerOnce;s.NextGenEvents.prototype.off=s.ngevRemoveListener;s.NextGenEvents.prototype.removeListener=s.ngevRemoveListener}};s.restore=function L(){s.substituted=false;i.setTimeout=i.Vanilla.setTimeout;i.setImmediate=i.Vanilla.setImmediate;n.nextTick=i.Vanilla.nextTick;if(s.NodeEvents){s.NodeEvents.prototype.on=s.NodeEvents.__addListener;s.NodeEvents.prototype.addListener=s.NodeEvents.__addListener;s.NodeEvents.prototype.once=s.NodeEvents.__addListenerOnce;s.NodeEvents.prototype.removeListener=s.NodeEvents.__removeListener}if(s.NextGenEvents){s.NextGenEvents.prototype.on=s.NextGenEvents.on;s.NextGenEvents.prototype.addListener=s.NextGenEvents.on;s.NextGenEvents.prototype.once=s.NextGenEvents.once;s.NextGenEvents.prototype.off=s.NextGenEvents.off;s.NextGenEvents.prototype.removeListener=s.NextGenEvents.removeListener}}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{_process:3,events:2,"nextgen-events":4}],2:[function(e,t,n){function i(){this._events=this._events||{};this._maxListeners=this._maxListeners||undefined}t.exports=i;i.EventEmitter=i;i.prototype._events=undefined;i.prototype._maxListeners=undefined;i.defaultMaxListeners=10;i.prototype.setMaxListeners=function(e){if(!r(e)||e<0||isNaN(e))throw TypeError("n must be a positive number");this._maxListeners=e;return this};i.prototype.emit=function(e){var t,n,i,r,l,c;if(!this._events)this._events={};if(e==="error"){if(!this._events.error||o(this._events.error)&&!this._events.error.length){t=arguments[1];if(t instanceof Error){throw t}throw TypeError('Uncaught, unspecified "error" event.')}}n=this._events[e];if(a(n))return false;if(s(n)){switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:r=Array.prototype.slice.call(arguments,1);n.apply(this,r)}}else if(o(n)){r=Array.prototype.slice.call(arguments,1);c=n.slice();i=c.length;for(l=0;l<i;l++)c[l].apply(this,r)}return true};i.prototype.addListener=function(e,t){var n;if(!s(t))throw TypeError("listener must be a function");if(!this._events)this._events={};if(this._events.newListener)this.emit("newListener",e,s(t.listener)?t.listener:t);if(!this._events[e])this._events[e]=t;else if(o(this._events[e]))this._events[e].push(t);else this._events[e]=[this._events[e],t];if(o(this._events[e])&&!this._events[e].warned){if(!a(this._maxListeners)){n=this._maxListeners}else{n=i.defaultMaxListeners}if(n&&n>0&&this._events[e].length>n){this._events[e].warned=true;console.error("(node) warning: possible EventEmitter memory "+"leak detected. %d listeners added. "+"Use emitter.setMaxListeners() to increase limit.",this._events[e].length);if(typeof console.trace==="function"){console.trace()}}}return this};i.prototype.on=i.prototype.addListener;i.prototype.once=function(e,t){if(!s(t))throw TypeError("listener must be a function");var n=false;function i(){this.removeListener(e,i);if(!n){n=true;t.apply(this,arguments)}}i.listener=t;this.on(e,i);return this};i.prototype.removeListener=function(e,t){var n,i,r,a;if(!s(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;n=this._events[e];r=n.length;i=-1;if(n===t||s(n.listener)&&n.listener===t){delete this._events[e];if(this._events.removeListener)this.emit("removeListener",e,t)}else if(o(n)){for(a=r;a-- >0;){if(n[a]===t||n[a].listener&&n[a].listener===t){i=a;break}}if(i<0)return this;if(n.length===1){n.length=0;delete this._events[e]}else{n.splice(i,1)}if(this._events.removeListener)this.emit("removeListener",e,t)}return this};i.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener){if(arguments.length===0)this._events={};else if(this._events[e])delete this._events[e];return this}if(arguments.length===0){for(t in this._events){if(t==="removeListener")continue;this.removeAllListeners(t)}this.removeAllListeners("removeListener");this._events={};return this}n=this._events[e];if(s(n)){this.removeListener(e,n)}else if(n){while(n.length)this.removeListener(e,n[n.length-1])}delete this._events[e];return this};i.prototype.listeners=function(e){var t;if(!this._events||!this._events[e])t=[];else if(s(this._events[e]))t=[this._events[e]];else t=this._events[e].slice();return t};i.prototype.listenerCount=function(e){if(this._events){var t=this._events[e];if(s(t))return 1;else if(t)return t.length}return 0};i.listenerCount=function(e,t){return e.listenerCount(t)};function s(e){return typeof e==="function"}function r(e){return typeof e==="number"}function o(e){return typeof e==="object"&&e!==null}function a(e){return e===void 0}},{}],3:[function(e,t,n){var i=t.exports={};var s=[];var r=false;var o;var a=-1;function l(){if(!r||!o){return}r=false;if(o.length){s=o.concat(s)}else{a=-1}if(s.length){c()}}function c(){if(r){return}var e=setTimeout(l);r=true;var t=s.length;while(t){o=s;s=[];while(++a<t){if(o){o[a].run()}}a=-1;t=s.length}o=null;r=false;clearTimeout(e)}i.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1){for(var n=1;n<arguments.length;n++){t[n-1]=arguments[n]}}s.push(new f(e,t));if(s.length===1&&!r){setTimeout(c,0)}};function f(e,t){this.fun=e;this.array=t}f.prototype.run=function(){this.fun.apply(null,this.array)};i.title="browser";i.browser=true;i.env={};i.argv=[];i.version="";i.versions={};function h(){}i.on=h;i.addListener=h;i.once=h;i.off=h;i.removeListener=h;i.removeAllListeners=h;i.emit=h;i.binding=function(e){throw new Error("process.binding is not supported")};i.cwd=function(){return"/"};i.chdir=function(e){throw new Error("process.chdir is not supported")};i.umask=function(){return 0}},{}],4:[function(e,t,n){"use strict";function i(){return Object.create(i.prototype)}t.exports=i;i.SYNC=-Infinity;i.init=function r(){Object.defineProperty(this,"__ngev",{value:{nice:i.SYNC,interruptible:false,recursion:0,contexts:{},events:{error:[],interrupt:[],newListener:[],removeListener:[]}}})};i.filterOutCallback=function(e,t){return e!==t};i.prototype.addListener=function o(e,t,n){var s={};if(!this.__ngev){i.init.call(this)}if(!this.__ngev.events[e]){this.__ngev.events[e]=[]}if(!e||typeof e!=="string"){throw new TypeError(".addListener(): argument #0 should be a non-empty string")}if(typeof t!=="function"){n=t;t=undefined}if(!n||typeof n!=="object"){n={}}s.fn=t||n.fn;s.id=typeof n.id==="string"?n.id:s.fn;s.once=!!n.once;s.async=!!n.async;s.nice=n.nice!==undefined?Math.floor(n.nice):i.SYNC;s.context=typeof n.context==="string"?n.context:null;if(typeof s.fn!=="function"){throw new TypeError(".addListener(): a function or an object with a 'fn' property which value is a function should be provided")}if(s.context&&typeof s.context==="string"&&!this.__ngev.contexts[s.context]){this.addListenerContext(s.context)}s.event=e;if(this.__ngev.events.newListener.length){this.emit("newListener",[s])}this.__ngev.events[e].push(s);return this};i.prototype.on=i.prototype.addListener;i.prototype.once=function a(e,t,n){if(t&&typeof t==="object"){t.once=true}else if(n&&typeof n==="object"){n.once=true}else{n={once:true}}return this.addListener(e,t,n)};i.prototype.removeListener=function l(e,t){var n,s,r=[],o=[];if(!e||typeof e!=="string"){throw new TypeError(".removeListener(): argument #0 should be a non-empty string")}if(!this.__ngev){i.init.call(this)}if(!this.__ngev.events[e]){this.__ngev.events[e]=[]}s=this.__ngev.events[e].length;for(n=0;n<s;n++){if(this.__ngev.events[e][n].id===t){o.push(this.__ngev.events[e][n])}else{r.push(this.__ngev.events[e][n])}}this.__ngev.events[e]=r;if(o.length&&this.__ngev.events.removeListener.length){this.emit("removeListener",o)}return this};i.prototype.off=i.prototype.removeListener;i.prototype.removeAllListeners=function c(e){var t;if(!this.__ngev){i.init.call(this)}if(e){if(!e||typeof e!=="string"){throw new TypeError(".removeAllListener(): argument #0 should be undefined or a non-empty string")}if(!this.__ngev.events[e]){this.__ngev.events[e]=[]}t=this.__ngev.events[e];this.__ngev.events[e]=[];if(t.length&&this.__ngev.events.removeListener.length){this.emit("removeListener",t)}}else{this.__ngev.events={}}return this};i.listenerWrapper=function f(e,t,n){var s,r;if(t.interrupt){return}if(e.async){if(n){r=n.serial;n.ready=!r}s=e.fn.apply(undefined,t.args.concat(function(n){t.listenersDone++;if(n&&t.emitter.__ngev.interruptible&&!t.interrupt&&t.name!=="interrupt"){t.interrupt=n;if(t.callback){t.callback(t.interrupt,t);delete t.callback}t.emitter.emit("interrupt",t.interrupt)}else if(t.listenersDone>=t.listeners&&t.callback){t.callback(undefined,t);delete t.callback}if(r){i.processQueue.call(t.emitter,e.context,true)}}))}else{s=e.fn.apply(undefined,t.args);t.listenersDone++}if(s&&t.emitter.__ngev.interruptible&&!t.interrupt&&t.name!=="interrupt"){t.interrupt=s;if(t.callback){t.callback(t.interrupt,t);delete t.callback}t.emitter.emit("interrupt",t.interrupt)}else if(t.listenersDone>=t.listeners&&t.callback){t.callback(undefined,t);delete t.callback}};var s=0;i.prototype.emit=function h(){var e,t,n=0,r,o,a,l,c,f=[];r={emitter:this,id:s++,name:null,args:null,nice:null,interrupt:null,listeners:null,listenersDone:0,callback:null};if(!this.__ngev){i.init.call(this)}if(typeof arguments[0]==="number"){r.nice=Math.floor(arguments[0]);r.name=arguments[1];if(!r.name||typeof r.name!=="string"){throw new TypeError(".emit(): when argument #0 is a number, argument #1 should be a non-empty string")}if(typeof arguments[arguments.length-1]==="function"){r.callback=arguments[arguments.length-1];r.args=Array.prototype.slice.call(arguments,2,-1)}else{r.args=Array.prototype.slice.call(arguments,2)}}else{r.nice=this.__ngev.nice;r.name=arguments[0];if(!r.name||typeof r.name!=="string"){throw new TypeError(".emit(): argument #0 should be an number or a non-empty string")}r.args=Array.prototype.slice.call(arguments,1);if(typeof arguments[arguments.length-1]==="function"){r.callback=arguments[arguments.length-1];r.args=Array.prototype.slice.call(arguments,1,-1)}else{r.args=Array.prototype.slice.call(arguments,1)}}if(!this.__ngev.events[r.name]){this.__ngev.events[r.name]=[]}r.listeners=this.__ngev.events[r.name].length;this.__ngev.recursion++;c=this.__ngev.events[r.name].slice();for(e=0,t=c.length;e<t;e++){n++;o=c[e];a=o.context&&this.__ngev.contexts[o.context];if(a&&a.status===i.CONTEXT_DISABLED){continue}if(a){l=Math.max(r.nice,o.nice,a.nice)}else{l=Math.max(r.nice,o.nice)}if(o.once){this.__ngev.events[r.name]=this.__ngev.events[r.name].filter(i.filterOutCallback.bind(undefined,o));f.push(o)}if(a&&(a.status===i.CONTEXT_QUEUED||!a.ready)){a.queue.push({event:r,listener:o,nice:l})}else{try{if(l<0){if(this.__ngev.recursion>=-l){setImmediate(i.listenerWrapper.bind(this,o,r,a))}else{i.listenerWrapper.call(this,o,r,a)}}else{setTimeout(i.listenerWrapper.bind(this,o,r,a),l)}}catch(h){this.__ngev.recursion--;throw h}}}this.__ngev.recursion--;if(f.length&&this.__ngev.events.removeListener.length){this.emit("removeListener",f)}if(!n){if(r.name==="error"){if(arguments[1]){throw arguments[1]}else{throw Error("Uncaught, unspecified 'error' event.")}}if(r.callback){r.callback(undefined,r);delete r.callback}}return r};i.prototype.listeners=function u(e){if(!e||typeof e!=="string"){throw new TypeError(".listeners(): argument #0 should be a non-empty string")}if(!this.__ngev){i.init.call(this)}if(!this.__ngev.events[e]){this.__ngev.events[e]=[]}return this.__ngev.events[e].slice()};i.listenerCount=function(e,t){if(!e||!(e instanceof i)){throw new TypeError(".listenerCount(): argument #0 should be an instance of NextGenEvents")}return e.listenerCount(t)};i.prototype.listenerCount=function(e){if(!e||typeof e!=="string"){throw new TypeError(".listenerCount(): argument #1 should be a non-empty string")}if(!this.__ngev){i.init.call(this)}if(!this.__ngev.events[e]){this.__ngev.events[e]=[]}return this.__ngev.events[e].length};i.prototype.setNice=function p(e){if(!this.__ngev){i.init.call(this)}this.__ngev.nice=Math.floor(+e||0)};i.prototype.setInterruptible=function v(e){if(!this.__ngev){i.init.call(this)}this.__ngev.interruptible=!!e};i.prototype.setMaxListeners=function(){};i.noop=function(){};i.CONTEXT_ENABLED=0;i.CONTEXT_DISABLED=1;i.CONTEXT_QUEUED=2;i.prototype.addListenerContext=function _(e,t){if(!this.__ngev){i.init.call(this)}if(!e||typeof e!=="string"){throw new TypeError(".addListenerContext(): argument #0 should be a non-empty string")}if(!t||typeof t!=="object"){t={}}if(!this.__ngev.contexts[e]){this.__ngev.contexts[e]=Object.create(i.prototype);this.__ngev.contexts[e].nice=i.SYNC;this.__ngev.contexts[e].ready=true;this.__ngev.contexts[e].status=i.CONTEXT_ENABLED;this.__ngev.contexts[e].serial=false;this.__ngev.contexts[e].queue=[]}if(t.nice!==undefined){this.__ngev.contexts[e].nice=Math.floor(t.nice)}if(t.status!==undefined){this.__ngev.contexts[e].status=t.status}if(t.serial!==undefined){this.__ngev.contexts[e].serial=!!t.serial}return this};i.prototype.disableListenerContext=function d(e){if(!this.__ngev){i.init.call(this)}if(!e||typeof e!=="string"){throw new TypeError(".disableListenerContext(): argument #0 should be a non-empty string")}if(!this.__ngev.contexts[e]){this.addListenerContext(e)}this.__ngev.contexts[e].status=i.CONTEXT_DISABLED;return this};i.prototype.enableListenerContext=function g(e){if(!this.__ngev){i.init.call(this)}if(!e||typeof e!=="string"){throw new TypeError(".enableListenerContext(): argument #0 should be a non-empty string")}if(!this.__ngev.contexts[e]){this.addListenerContext(e)}this.__ngev.contexts[e].status=i.CONTEXT_ENABLED;if(this.__ngev.contexts[e].queue.length>0){i.processQueue.call(this,e)}return this};i.prototype.queueListenerContext=function y(e){if(!this.__ngev){i.init.call(this)}if(!e||typeof e!=="string"){throw new TypeError(".queueListenerContext(): argument #0 should be a non-empty string")}if(!this.__ngev.contexts[e]){this.addListenerContext(e)}this.__ngev.contexts[e].status=i.CONTEXT_QUEUED;return this};i.prototype.serializeListenerContext=function m(e,t){if(!this.__ngev){i.init.call(this)}if(!e||typeof e!=="string"){throw new TypeError(".serializeListenerContext(): argument #0 should be a non-empty string")}if(!this.__ngev.contexts[e]){this.addListenerContext(e)}this.__ngev.contexts[e].serial=t===undefined?true:!!t;return this};i.prototype.setListenerContextNice=function L(e,t){if(!this.__ngev){i.init.call(this)}if(!e||typeof e!=="string"){throw new TypeError(".setListenerContextNice(): argument #0 should be a non-empty string")}if(!this.__ngev.contexts[e]){this.addListenerContext(e)}this.__ngev.contexts[e].nice=Math.floor(t);return this};i.prototype.destroyListenerContext=function x(e){var t,n,s,r,o=[];if(!e||typeof e!=="string"){throw new TypeError(".disableListenerContext(): argument #0 should be a non-empty string")}if(!this.__ngev){i.init.call(this)}for(s in this.__ngev.events){r=null;n=this.__ngev.events[s].length;for(t=0;t<n;t++){if(this.__ngev.events[s][t].context===e){r=[];o.push(this.__ngev.events[s][t])}else if(r){r.push(this.__ngev.events[s][t])}}if(r){this.__ngev.events[s]=r}}if(this.__ngev.contexts[e]){delete this.__ngev.contexts[e]}if(o.length&&this.__ngev.events.removeListener.length){this.emit("removeListener",o)}return this};i.processQueue=function E(e,t){var n,s;if(!this.__ngev.contexts[e]){return}n=this.__ngev.contexts[e];if(t){n.ready=true}this.__ngev.recursion++;while(n.ready&&n.queue.length){s=n.queue.shift();if(s.event.interrupt){continue}try{if(s.nice<0){if(this.__ngev.recursion>=-s.nice){setImmediate(i.listenerWrapper.bind(this,s.listener,s.event,n))}else{i.listenerWrapper.call(this,s.listener,s.event,n)}}else{setTimeout(i.listenerWrapper.bind(this,s.listener,s.event,n),s.nice)}}catch(r){this.__ngev.recursion--;throw r}}this.__ngev.recursion--};i.on=i.prototype.on;i.once=i.prototype.once;i.off=i.prototype.off},{}]},{},[1])(1)});
(function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.AsyncTryCatch=e()}})(function(){var e,t,n;return function r(e,t,n){function i(s,a){if(!t[s]){if(!e[s]){var p=typeof require=="function"&&require;if(!a&&p)return p(s,!0);if(o)return o(s,!0);var c=new Error("Cannot find module '"+s+"'");throw c.code="MODULE_NOT_FOUND",c}var d=t[s]={exports:{}};e[s][0].call(d.exports,function(t){var n=e[s][1][t];return i(n?n:t)},d,d.exports,r,e,t,n)}return t[s].exports}var o=typeof require=="function"&&require;for(var s=0;s<n.length;s++)i(n[s]);return i}({1:[function(e,t,n){(function(n,r){"use strict";function i(){throw new Error("Use AsyncTryCatch.try() instead.")}t.exports=i;r.AsyncTryCatch=i;if(n.browser&&!r.setImmediate){r.setImmediate=function o(e){return setTimeout(e,0)};r.clearImmediate=function s(e){return clearTimeout(e)}}if(!r.Vanilla){r.Vanilla={};if(!r.Vanilla.setTimeout){r.Vanilla.setTimeout=setTimeout}if(!r.Vanilla.setImmediate){r.Vanilla.setImmediate=setImmediate}if(!r.Vanilla.nextTick){r.Vanilla.nextTick=n.nextTick}}i.stack=[];i.substituted=false;i.try=function a(e){var t=Object.create(i.prototype,{fn:{value:e,enumerable:true},parent:{value:i.stack[i.stack.length-1]}});return t};i.prototype.catch=function p(e){Object.defineProperties(this,{catchFn:{value:e,enumerable:true}});if(!i.substituted){i.substitute()}try{i.stack.push(this);this.fn();i.stack.pop()}catch(t){i.stack.pop();this.callCatchFn(t)}};i.prototype.callCatchFn=function c(e){if(!this.parent){this.catchFn(e);return}try{i.stack.push(this.parent);this.catchFn(e);i.stack.pop()}catch(e){i.stack.pop();this.parent.callCatchFn(e)}};i.timerWrapper=function d(e,t){var t,n,r,o=Array.prototype.slice.call(arguments,1);if(typeof t!=="function"||!i.stack.length){return e.apply(this,o)}n=i.stack[i.stack.length-1];r=function(){try{i.stack.push(n);t.apply(this,arguments);i.stack.pop()}catch(e){i.stack.pop();n.callCatchFn(e)}};o[0]=r;return e.apply(this,o)};i.addListenerWrapper=function f(e,t,n,r){var n,o,s;if(typeof n==="object"){r=n;n=r.fn;delete r.fn}if(typeof n!=="function"||!i.stack.length){return e.call(this,t,n,r)}o=i.stack[i.stack.length-1];if(this.__fnToWrapperMap){s=this.__fnToWrapperMap.get(n)}else{Object.defineProperty(this,"__fnToWrapperMap",{value:new WeakMap})}if(!s){s=function(){try{i.stack.push(o);n.apply(this,arguments);i.stack.pop()}catch(e){i.stack.pop();o.callCatchFn(e)}};this.__fnToWrapperMap.set(n,s)}return e.call(this,t,s,r)};i.removeListenerWrapper=function u(e,t,n){if(typeof n==="function"&&this.__fnToWrapperMap){n=this.__fnToWrapperMap.get(n)||n}return e.call(this,t,n)};i.setTimeout=i.timerWrapper.bind(undefined,r.Vanilla.setTimeout);i.setImmediate=i.timerWrapper.bind(undefined,r.Vanilla.setImmediate);i.nextTick=i.timerWrapper.bind(n,r.Vanilla.nextTick);i.addListener=function l(e,t){i.addListenerWrapper.call(this,i.NodeEvents.__addListener,e,t)};i.addListenerOnce=function v(e,t){i.addListenerWrapper.call(this,i.NodeEvents.__addListenerOnce,e,t)};i.removeListener=function h(e,t){i.removeListenerWrapper.call(this,i.NodeEvents.__removeListener,e,t)};i.ngevAddListener=function m(e,t,n){i.addListenerWrapper.call(this,i.NextGenEvents.on,e,t,n)};i.ngevAddListenerOnce=function y(e,t,n){i.addListenerWrapper.call(this,i.NextGenEvents.once,e,t,n)};i.ngevRemoveListener=function E(e,t){i.removeListenerWrapper.call(this,i.NextGenEvents.off,e,t)};i.substitute=function L(){i.substituted=true;r.setTimeout=i.setTimeout;r.setImmediate=i.setTimeout;n.nextTick=i.nextTick;try{i.NodeEvents=r.EventEmitter||e("events")}catch(t){}try{i.NextGenEvents=r.NextGenEvents||e("nextgen-events")}catch(t){}if(i.NodeEvents){if(!i.NodeEvents.__addListener){i.NodeEvents.__addListener=i.NodeEvents.prototype.on}if(!i.NodeEvents.__addListenerOnce){i.NodeEvents.__addListenerOnce=i.NodeEvents.prototype.addListenerOnce}if(!i.NodeEvents.__removeListener){i.NodeEvents.__removeListener=i.NodeEvents.prototype.removeListener}i.NodeEvents.prototype.on=i.addListener;i.NodeEvents.prototype.addListener=i.addListener;i.NodeEvents.prototype.once=i.addListenerOnce;i.NodeEvents.prototype.removeListener=i.removeListener}if(i.NextGenEvents){i.NextGenEvents.prototype.on=i.ngevAddListener;i.NextGenEvents.prototype.addListener=i.ngevAddListener;i.NextGenEvents.prototype.once=i.ngevAddListenerOnce;i.NextGenEvents.prototype.off=i.ngevRemoveListener;i.NextGenEvents.prototype.removeListener=i.ngevRemoveListener}};i.restore=function N(){i.substituted=false;r.setTimeout=r.Vanilla.setTimeout;r.setImmediate=r.Vanilla.setImmediate;n.nextTick=r.Vanilla.nextTick;if(i.NodeEvents){i.NodeEvents.prototype.on=i.NodeEvents.__addListener;i.NodeEvents.prototype.addListener=i.NodeEvents.__addListener;i.NodeEvents.prototype.once=i.NodeEvents.__addListenerOnce;i.NodeEvents.prototype.removeListener=i.NodeEvents.__removeListener}if(i.NextGenEvents){i.NextGenEvents.prototype.on=i.NextGenEvents.on;i.NextGenEvents.prototype.addListener=i.NextGenEvents.on;i.NextGenEvents.prototype.once=i.NextGenEvents.once;i.NextGenEvents.prototype.off=i.NextGenEvents.off;i.NextGenEvents.prototype.removeListener=i.NextGenEvents.removeListener}}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{_process:3,events:2,"nextgen-events":2}],2:[function(e,t,n){},{}],3:[function(e,t,n){var r=t.exports={};var i=[];var o=false;var s;var a=-1;function p(){if(!o||!s){return}o=false;if(s.length){i=s.concat(i)}else{a=-1}if(i.length){c()}}function c(){if(o){return}var e=setTimeout(p);o=true;var t=i.length;while(t){s=i;i=[];while(++a<t){if(s){s[a].run()}}a=-1;t=i.length}s=null;o=false;clearTimeout(e)}r.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1){for(var n=1;n<arguments.length;n++){t[n-1]=arguments[n]}}i.push(new d(e,t));if(i.length===1&&!o){setTimeout(c,0)}};function d(e,t){this.fun=e;this.array=t}d.prototype.run=function(){this.fun.apply(null,this.array)};r.title="browser";r.browser=true;r.env={};r.argv=[];r.version="";r.versions={};function f(){}r.on=f;r.addListener=f;r.once=f;r.off=f;r.removeListener=f;r.removeAllListeners=f;r.emit=f;r.binding=function(e){throw new Error("process.binding is not supported")};r.cwd=function(){return"/"};r.chdir=function(e){throw new Error("process.chdir is not supported")};r.umask=function(){return 0}},{}]},{},[1])(1)});
{
"name": "async-try-catch",
"version": "0.1.5",
"version": "0.1.6",
"description": "Async try catch",

@@ -5,0 +5,0 @@ "main": "lib/AsyncTryCatch.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc