Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.3.4 to 0.3.6

.eslintrc.js

245

browser/AsyncTryCatch.js

@@ -5,7 +5,7 @@ (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){

Async Try-Catch
Copyright (c) 2015 - 2016 Cédric Ronvel
Copyright (c) 2015 - 2018 Cédric Ronvel
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy

@@ -17,6 +17,6 @@ of this software and associated documentation files (the "Software"), to deal

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

@@ -42,11 +42,9 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

if ( global.AsyncTryCatch )
{
if ( global.AsyncTryCatch.prototype.__prototypeUID__ === 'async-try-catch/AsyncTryCatch' )
{
if ( global.AsyncTryCatch ) {
if ( global.AsyncTryCatch.prototype.__prototypeUID__ === 'async-try-catch/AsyncTryCatch' ) {
//console.log( "Already installed:" , global.AsyncTryCatch.prototype.__prototypeVersion__ , "current:" , AsyncTryCatch.prototype.__prototypeVersion__ ) ;
var currentVersions = AsyncTryCatch.prototype.__prototypeVersion__.split( '.' ) ;
var installedVersions = global.AsyncTryCatch.prototype.__prototypeVersion__.split( '.' ) ;
// Basic semver comparison

@@ -56,4 +54,3 @@ if (

( currentVersions[ 0 ] === "0" && installedVersions[ 1 ] !== currentVersions[ 1 ] )
)
{
) {
throw new Error(

@@ -66,9 +63,7 @@ "Incompatible version of AsyncTryCatch already installed on global.AsyncTryCatch: " +

}
else
{
else {
throw new Error( "Incompatible module already installed on global.AsyncTryCatch" ) ;
}
}
else
{
else {
global.AsyncTryCatch = AsyncTryCatch ;

@@ -82,4 +77,3 @@ global.AsyncTryCatch.stack = [] ;

if ( process.browser && ! global.setImmediate )
{
if ( process.browser && ! global.setImmediate ) {
global.setImmediate = function setImmediate( fn ) { return setTimeout( fn , 0 ) ; } ;

@@ -98,4 +92,3 @@ global.clearImmediate = function clearImmediate( timer ) { return clearTimeout( timer ) ; } ;

AsyncTryCatch.try = function try_( fn )
{
AsyncTryCatch.try = function try_( fn ) {
var self = Object.create( AsyncTryCatch.prototype , {

@@ -105,3 +98,3 @@ fn: { value: fn , enumerable: true } ,

} ) ;
return self ;

@@ -112,10 +105,9 @@ } ;

AsyncTryCatch.prototype.catch = function catch_( catchFn )
{
AsyncTryCatch.prototype.catch = function catch_( catchFn ) {
Object.defineProperties( this , {
catchFn: { value: catchFn , enumerable: true }
} ) ;
if ( ! global.AsyncTryCatch.substituted ) { AsyncTryCatch.substitute() ; }
try {

@@ -130,3 +122,3 @@ global.AsyncTryCatch.stack.push( this ) ;

}
} ;

@@ -137,10 +129,8 @@

// Handle the bubble up
AsyncTryCatch.prototype.callCatchFn = function callCatchFn( error )
{
if ( ! this.parent )
{
AsyncTryCatch.prototype.callCatchFn = function callCatchFn( error ) {
if ( ! this.parent ) {
this.catchFn( error ) ;
return ;
}
try {

@@ -151,5 +141,5 @@ global.AsyncTryCatch.stack.push( this.parent ) ;

}
catch ( error ) {
catch ( error_ ) {
global.AsyncTryCatch.stack.pop() ;
this.parent.callCatchFn( error ) ;
this.parent.callCatchFn( error_ ) ;
}

@@ -161,19 +151,19 @@ } ;

// for setTimeout(), setImmediate(), process.nextTick()
AsyncTryCatch.timerWrapper = function timerWrapper( originalMethod , fn )
{
var fn , context , wrapperFn ,
args = Array.prototype.slice.call( arguments , 1 ) ;
if ( typeof fn !== 'function' || ! global.AsyncTryCatch.stack.length )
{
return originalMethod.apply( this , args ) ;
AsyncTryCatch.timerWrapper = function timerWrapper( originalMethod , fn , ... args ) {
var context , wrapperFn ;
if ( typeof fn !== 'function' || ! global.AsyncTryCatch.stack.length ) {
return originalMethod.call( this , fn , ... args ) ;
}
context = global.AsyncTryCatch.stack[ global.AsyncTryCatch.stack.length - 1 ] ;
wrapperFn = function timerWrapperFn() {
wrapperFn = function timerWrapperFn( ... wrapperArgs ) {
var returnVal ;
try {
global.AsyncTryCatch.stack.push( context ) ;
return fn.apply( this , arguments ) ;
returnVal = fn.call( this , ... wrapperArgs ) ;
global.AsyncTryCatch.stack.pop() ;
return returnVal ;
}

@@ -185,6 +175,4 @@ catch ( error ) {

} ;
args[ 0 ] = wrapperFn ;
return originalMethod.apply( this , args ) ;
return originalMethod.call( this , wrapperFn , ... args ) ;
} ;

@@ -195,9 +183,7 @@

// for Node-EventEmitter-compatible .addListener()
AsyncTryCatch.addListenerWrapper = function addListenerWrapper( originalMethod , eventName , fn , options , onceWrapper )
{
var fn , context , wrapperFn , onceWrapperFired ;
AsyncTryCatch.addListenerWrapper = function addListenerWrapper( originalMethod , eventName , fn , options , onceWrapper ) {
var context , wrapperFn , onceWrapperFired ;
// NextGen event compatibility
if ( typeof fn === 'object' )
{
if ( typeof fn === 'object' ) {
options = fn ;

@@ -207,23 +193,24 @@ fn = options.fn ;

}
if ( typeof fn !== 'function' || ! global.AsyncTryCatch.stack.length )
{
if ( typeof fn !== 'function' || ! global.AsyncTryCatch.stack.length ) {
return originalMethod.call( this , eventName , fn , options ) ;
}
context = global.AsyncTryCatch.stack[ global.AsyncTryCatch.stack.length - 1 ] ;
if ( onceWrapper )
{
if ( onceWrapper ) {
onceWrapperFired = false ;
wrapperFn = function listenerOnceWrapperFn() {
wrapperFn = function listenerOnceWrapperFn( ... wrapperArgs ) {
var returnVal ;
if ( onceWrapperFired ) { return ; }
onceWrapperFired = true ;
this.removeListener( eventName , wrapperFn ) ;
try {
global.AsyncTryCatch.stack.push( context ) ;
return fn.apply( this , arguments ) ;
returnVal = fn.call( this , ... wrapperArgs ) ;
global.AsyncTryCatch.stack.pop() ;
return returnVal ;
}

@@ -236,9 +223,11 @@ catch ( error ) {

}
else
{
wrapperFn = function listenerWrapperFn() {
else {
wrapperFn = function listenerWrapperFn( ... wrapperArgs ) {
var returnVal ;
try {
global.AsyncTryCatch.stack.push( context ) ;
return fn.apply( this , arguments ) ;
returnVal = fn.call( this , ... wrapperArgs ) ;
global.AsyncTryCatch.stack.pop() ;
return returnVal ;
}

@@ -251,7 +240,7 @@ catch ( error ) {

}
// This is used to indicate to node.js core events that this function is a wrapper to another.
// E.g. it is used internally by .removeListener() to find the registered wrapper from the original userland listener.
wrapperFn.listener = fn ;
return originalMethod.call( this , eventName , wrapperFn , options ) ;

@@ -267,4 +256,3 @@ } ;

// NodeEvents on()/addListener() replacement
AsyncTryCatch.addListener = function addListener( eventName , fn )
{
AsyncTryCatch.addListener = function addListener( eventName , fn ) {
return AsyncTryCatch.addListenerWrapper.call( this , AsyncTryCatch.NodeEvents.__addListener , eventName , fn ) ;

@@ -274,4 +262,3 @@ } ;

// NodeEvents once() replacement
AsyncTryCatch.addListenerOnce = function addListenerOnce( eventName , fn )
{
AsyncTryCatch.addListenerOnce = function addListenerOnce( eventName , fn ) {
return AsyncTryCatch.addListenerWrapper.call( this , AsyncTryCatch.NodeEvents.__addListener , eventName , fn , undefined , true ) ;

@@ -281,4 +268,3 @@ } ;

// NodeEvents removeListener() replacement
AsyncTryCatch.removeListener = function removeListener( eventName , fn )
{
AsyncTryCatch.removeListener = function removeListener( eventName , fn ) {
return AsyncTryCatch.NodeEvents.__removeListener.call( this , eventName , fn ) ;

@@ -288,7 +274,14 @@ } ;

// NextGen Events on()/addListener() replacement
AsyncTryCatch.ngevAddListener = function ngevAddListener( eventName , fn , options )
{
if ( ! options ) { options = {} ; }
if ( options.id === undefined ) { options.id = fn ; }
AsyncTryCatch.ngevAddListener = function ngevAddListener( eventName , fn , options ) {
// Ensure there is an id argument
if ( fn && typeof fn === 'object' ) {
if ( fn.id === undefined ) { fn.id = fn.fn ; }
}
else if ( options && typeof options === 'object' ) {
if ( options.id === undefined ) { options.id = fn ; }
}
else {
options = { id: fn } ;
}
return AsyncTryCatch.addListenerWrapper.call( this ,

@@ -300,7 +293,14 @@ AsyncTryCatch.NextGenEvents[ this.asyncTryCatchId ].on ,

// NextGen Events once() replacement
AsyncTryCatch.ngevAddListenerOnce = function ngevAddListenerOnce( eventName , fn , options )
{
if ( ! options ) { options = {} ; }
if ( options.id === undefined ) { options.id = fn ; }
AsyncTryCatch.ngevAddListenerOnce = function ngevAddListenerOnce( eventName , fn , options ) {
// Ensure there is an id argument
if ( fn && typeof fn === 'object' ) {
if ( fn.id === undefined ) { fn.id = fn.fn ; }
}
else if ( options && typeof options === 'object' ) {
if ( options.id === undefined ) { options.id = fn ; }
}
else {
options = { id: fn } ;
}
return AsyncTryCatch.addListenerWrapper.call( this ,

@@ -312,4 +312,3 @@ AsyncTryCatch.NextGenEvents[ this.asyncTryCatchId ].once ,

// NextGen Events off()/removeListener() replacement
AsyncTryCatch.ngevRemoveListener = function ngevRemoveListener( eventName , id )
{
AsyncTryCatch.ngevRemoveListener = function ngevRemoveListener( eventName , id ) {
return AsyncTryCatch.NextGenEvents[ this.asyncTryCatchId ].off.call( this , eventName , id ) ;

@@ -320,36 +319,32 @@ } ;

AsyncTryCatch.substitute = function substitute()
{
AsyncTryCatch.substitute = function substitute() {
// This test should be done by the caller, because substitution could be incomplete
// E.g. browser case: Node Events or NextGen Events are not loaded/accessible at time
//if ( global.AsyncTryCatch.substituted ) { return ; }
global.AsyncTryCatch.substituted = true ;
global.setTimeout = AsyncTryCatch.setTimeout ;
global.setImmediate = AsyncTryCatch.setTimeout ;
process.nextTick = AsyncTryCatch.nextTick ;
// Global is checked first, in case we are running inside a browser
try {
AsyncTryCatch.NodeEvents = global.EventEmitter || require( 'events' ) ;
} catch ( error ) {}
if ( AsyncTryCatch.NodeEvents )
{
if ( ! AsyncTryCatch.NodeEvents.__addListener )
{
}
catch ( error ) {}
if ( AsyncTryCatch.NodeEvents ) {
if ( ! AsyncTryCatch.NodeEvents.__addListener ) {
AsyncTryCatch.NodeEvents.__addListener = AsyncTryCatch.NodeEvents.prototype.on ;
}
if ( ! AsyncTryCatch.NodeEvents.__addListenerOnce )
{
if ( ! AsyncTryCatch.NodeEvents.__addListenerOnce ) {
AsyncTryCatch.NodeEvents.__addListenerOnce = AsyncTryCatch.NodeEvents.prototype.once ;
}
if ( ! AsyncTryCatch.NodeEvents.__removeListener )
{
if ( ! AsyncTryCatch.NodeEvents.__removeListener ) {
AsyncTryCatch.NodeEvents.__removeListener = AsyncTryCatch.NodeEvents.prototype.removeListener ;
}
AsyncTryCatch.NodeEvents.prototype.on = AsyncTryCatch.addListener ;

@@ -360,5 +355,4 @@ AsyncTryCatch.NodeEvents.prototype.addListener = AsyncTryCatch.addListener ;

}
for ( var i = 0 ; i < AsyncTryCatch.NextGenEvents.length ; i ++ )
{
for ( var i = 0 ; i < AsyncTryCatch.NextGenEvents.length ; i ++ ) {
//console.log( 'substituting NextGenEvents' , i ) ;

@@ -375,16 +369,14 @@ AsyncTryCatch.NextGenEvents[ i ].prototype.on = AsyncTryCatch.ngevAddListener ;

AsyncTryCatch.restore = function restore()
{
AsyncTryCatch.restore = function restore() {
// This test should be done by the caller, because substitution could be incomplete
// E.g. browser case: Node Events or NextGen Events are not loaded/accessible at time
//if ( ! global.AsyncTryCatch.substituted ) { return ; }
global.AsyncTryCatch.substituted = false ;
global.setTimeout = global.Vanilla.setTimeout ;
global.setImmediate = global.Vanilla.setImmediate ;
process.nextTick = global.Vanilla.nextTick ;
if ( AsyncTryCatch.NodeEvents )
{
if ( AsyncTryCatch.NodeEvents ) {
AsyncTryCatch.NodeEvents.prototype.on = AsyncTryCatch.NodeEvents.__addListener ;

@@ -395,5 +387,4 @@ AsyncTryCatch.NodeEvents.prototype.addListener = AsyncTryCatch.NodeEvents.__addListener ;

}
for ( var i = 0 ; i < AsyncTryCatch.NextGenEvents.length ; i ++ )
{
for ( var i = 0 ; i < AsyncTryCatch.NextGenEvents.length ; i ++ ) {
AsyncTryCatch.NextGenEvents[ i ].prototype.on = AsyncTryCatch.NextGenEvents[ i ].on ;

@@ -597,3 +588,3 @@ AsyncTryCatch.NextGenEvents[ i ].prototype.addListener = AsyncTryCatch.NextGenEvents[ i ].on ;

"name": "async-try-catch",
"version": "0.3.4",
"version": "0.3.6",
"description": "Async try catch",

@@ -610,4 +601,4 @@ "main": "lib/AsyncTryCatch.js",

"mocha": "^3.0.2",
"nextgen-events": "^0.9.7",
"uglify-js": "^2.7.3"
"nextgen-events": "^0.12.3",
"uglify-js-es6": "^2.8.9"
},

@@ -635,3 +626,3 @@ "scripts": {

2015,
2016
2018
],

@@ -638,0 +629,0 @@ "owner": "Cédric Ronvel"

@@ -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 e(t,n,r){function s(i,c){if(!n[i]){if(!t[i]){var a=typeof require=="function"&&require;if(!c&&a)return a(i,!0);if(o)return o(i,!0);var y=new Error("Cannot find module '"+i+"'");throw y.code="MODULE_NOT_FOUND",y}var p=n[i]={exports:{}};t[i][0].call(p.exports,function(e){var n=t[i][1][e];return s(n?n:e)},p,p.exports,e,t,n,r)}return n[i].exports}var o=typeof require=="function"&&require;for(var i=0;i<r.length;i++)s(r[i]);return s}({1:[function(e,t,n){(function(n,r){"use strict";function s(){throw new Error("Use AsyncTryCatch.try() instead.")}t.exports=s;s.prototype.__prototypeUID__="async-try-catch/AsyncTryCatch";s.prototype.__prototypeVersion__=e("../package.json").version;if(r.AsyncTryCatch){if(r.AsyncTryCatch.prototype.__prototypeUID__==="async-try-catch/AsyncTryCatch"){var o=s.prototype.__prototypeVersion__.split(".");var i=r.AsyncTryCatch.prototype.__prototypeVersion__.split(".");if(i[0]!==o[0]||o[0]==="0"&&i[1]!==o[1]){throw new Error("Incompatible version of AsyncTryCatch already installed on global.AsyncTryCatch: "+r.AsyncTryCatch.prototype.__prototypeVersion__+", current version: "+s.prototype.__prototypeVersion__)}}else{throw new Error("Incompatible module already installed on global.AsyncTryCatch")}}else{r.AsyncTryCatch=s;r.AsyncTryCatch.stack=[];r.AsyncTryCatch.substituted=false;r.AsyncTryCatch.NextGenEvents=[]}if(n.browser&&!r.setImmediate){r.setImmediate=function e(t){return setTimeout(t,0)};r.clearImmediate=function e(t){return clearTimeout(t)}}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}s.try=function e(t){var n=Object.create(s.prototype,{fn:{value:t,enumerable:true},parent:{value:r.AsyncTryCatch.stack[r.AsyncTryCatch.stack.length-1]}});return n};s.prototype.catch=function e(t){Object.defineProperties(this,{catchFn:{value:t,enumerable:true}});if(!r.AsyncTryCatch.substituted){s.substitute()}try{r.AsyncTryCatch.stack.push(this);this.fn();r.AsyncTryCatch.stack.pop()}catch(e){r.AsyncTryCatch.stack.pop();this.callCatchFn(e)}};s.prototype.callCatchFn=function e(t){if(!this.parent){this.catchFn(t);return}try{r.AsyncTryCatch.stack.push(this.parent);this.catchFn(t);r.AsyncTryCatch.stack.pop()}catch(e){r.AsyncTryCatch.stack.pop();this.parent.callCatchFn(e)}};s.timerWrapper=function e(t,n){var n,s,o,i=Array.prototype.slice.call(arguments,1);if(typeof n!=="function"||!r.AsyncTryCatch.stack.length){return t.apply(this,i)}s=r.AsyncTryCatch.stack[r.AsyncTryCatch.stack.length-1];o=function e(){try{r.AsyncTryCatch.stack.push(s);return n.apply(this,arguments);r.AsyncTryCatch.stack.pop()}catch(e){r.AsyncTryCatch.stack.pop();s.callCatchFn(e)}};i[0]=o;return t.apply(this,i)};s.addListenerWrapper=function e(t,n,s,o,i){var s,c,a,y;if(typeof s==="object"){o=s;s=o.fn;delete o.fn}if(typeof s!=="function"||!r.AsyncTryCatch.stack.length){return t.call(this,n,s,o)}c=r.AsyncTryCatch.stack[r.AsyncTryCatch.stack.length-1];if(i){y=false;a=function e(){if(y){return}y=true;this.removeListener(n,a);try{r.AsyncTryCatch.stack.push(c);return s.apply(this,arguments);r.AsyncTryCatch.stack.pop()}catch(e){r.AsyncTryCatch.stack.pop();c.callCatchFn(e)}}}else{a=function e(){try{r.AsyncTryCatch.stack.push(c);return s.apply(this,arguments);r.AsyncTryCatch.stack.pop()}catch(e){r.AsyncTryCatch.stack.pop();c.callCatchFn(e)}}}a.listener=s;return t.call(this,n,a,o)};s.setTimeout=s.timerWrapper.bind(undefined,r.Vanilla.setTimeout);s.setImmediate=s.timerWrapper.bind(undefined,r.Vanilla.setImmediate);s.nextTick=s.timerWrapper.bind(n,r.Vanilla.nextTick);s.addListener=function e(t,n){return s.addListenerWrapper.call(this,s.NodeEvents.__addListener,t,n)};s.addListenerOnce=function e(t,n){return s.addListenerWrapper.call(this,s.NodeEvents.__addListener,t,n,undefined,true)};s.removeListener=function e(t,n){return s.NodeEvents.__removeListener.call(this,t,n)};s.ngevAddListener=function e(t,n,r){if(!r){r={}}if(r.id===undefined){r.id=n}return s.addListenerWrapper.call(this,s.NextGenEvents[this.asyncTryCatchId].on,t,n,r)};s.ngevAddListenerOnce=function e(t,n,r){if(!r){r={}}if(r.id===undefined){r.id=n}return s.addListenerWrapper.call(this,s.NextGenEvents[this.asyncTryCatchId].once,t,n,r)};s.ngevRemoveListener=function e(t,n){return s.NextGenEvents[this.asyncTryCatchId].off.call(this,t,n)};s.substitute=function t(){r.AsyncTryCatch.substituted=true;r.setTimeout=s.setTimeout;r.setImmediate=s.setTimeout;n.nextTick=s.nextTick;try{s.NodeEvents=r.EventEmitter||e("events")}catch(e){}if(s.NodeEvents){if(!s.NodeEvents.__addListener){s.NodeEvents.__addListener=s.NodeEvents.prototype.on}if(!s.NodeEvents.__addListenerOnce){s.NodeEvents.__addListenerOnce=s.NodeEvents.prototype.once}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}for(var o=0;o<s.NextGenEvents.length;o++){s.NextGenEvents[o].prototype.on=s.ngevAddListener;s.NextGenEvents[o].prototype.addListener=s.ngevAddListener;s.NextGenEvents[o].prototype.once=s.ngevAddListenerOnce;s.NextGenEvents[o].prototype.off=s.ngevRemoveListener;s.NextGenEvents[o].prototype.removeListener=s.ngevRemoveListener}};s.restore=function e(){r.AsyncTryCatch.substituted=false;r.setTimeout=r.Vanilla.setTimeout;r.setImmediate=r.Vanilla.setImmediate;n.nextTick=r.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}for(var t=0;t<s.NextGenEvents.length;t++){s.NextGenEvents[t].prototype.on=s.NextGenEvents[t].on;s.NextGenEvents[t].prototype.addListener=s.NextGenEvents[t].on;s.NextGenEvents[t].prototype.once=s.NextGenEvents[t].once;s.NextGenEvents[t].prototype.off=s.NextGenEvents[t].off;s.NextGenEvents[t].prototype.removeListener=s.NextGenEvents[t].removeListener}}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"../package.json":4,_process:3,events:2}],2:[function(e,t,n){},{}],3:[function(e,t,n){var r=t.exports={};var s;var o;function i(){throw new Error("setTimeout has not been defined")}function c(){throw new Error("clearTimeout has not been defined")}(function(){try{if(typeof setTimeout==="function"){s=setTimeout}else{s=i}}catch(e){s=i}try{if(typeof clearTimeout==="function"){o=clearTimeout}else{o=c}}catch(e){o=c}})();function a(e){if(s===setTimeout){return setTimeout(e,0)}if((s===i||!s)&&setTimeout){s=setTimeout;return setTimeout(e,0)}try{return s(e,0)}catch(t){try{return s.call(null,e,0)}catch(t){return s.call(this,e,0)}}}function y(e){if(o===clearTimeout){return clearTimeout(e)}if((o===c||!o)&&clearTimeout){o=clearTimeout;return clearTimeout(e)}try{return o(e)}catch(t){try{return o.call(null,e)}catch(t){return o.call(this,e)}}}var p=[];var u=false;var l;var d=-1;function f(){if(!u||!l){return}u=false;if(l.length){p=l.concat(p)}else{d=-1}if(p.length){h()}}function h(){if(u){return}var e=a(f);u=true;var t=p.length;while(t){l=p;p=[];while(++d<t){if(l){l[d].run()}}d=-1;t=p.length}l=null;u=false;y(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]}}p.push(new v(e,t));if(p.length===1&&!u){a(h)}};function v(e,t){this.fun=e;this.array=t}v.prototype.run=function(){this.fun.apply(null,this.array)};r.title="browser";r.browser=true;r.env={};r.argv=[];r.version="";r.versions={};function m(){}r.on=m;r.addListener=m;r.once=m;r.off=m;r.removeListener=m;r.removeAllListeners=m;r.emit=m;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}},{}],4:[function(e,t,n){t.exports={name:"async-try-catch",version:"0.3.4",description:"Async try catch",main:"lib/AsyncTryCatch.js",directories:{test:"test"},dependencies:{},devDependencies:{browserify:"^13.1.0","expect.js":"^0.3.1",jshint:"^2.9.3",mocha:"^3.0.2","nextgen-events":"^0.9.7","uglify-js":"^2.7.3"},scripts:{test:"mocha -R dot"},repository:{type:"git",url:"https://github.com/cronvel/async-try-catch.git"},keywords:["async","try","catch"],author:"Cédric Ronvel",license:"MIT",bugs:{url:"https://github.com/cronvel/async-try-catch/issues"},copyright:{title:"Async Try-Catch",years:[2015,2016],owner:"Cédric Ronvel"}}},{}]},{},[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 e(t,n,r){function s(i,c){if(!n[i]){if(!t[i]){var a=typeof require=="function"&&require;if(!c&&a)return a(i,!0);if(o)return o(i,!0);var y=new Error("Cannot find module '"+i+"'");throw y.code="MODULE_NOT_FOUND",y}var u=n[i]={exports:{}};t[i][0].call(u.exports,function(e){var n=t[i][1][e];return s(n?n:e)},u,u.exports,e,t,n,r)}return n[i].exports}var o=typeof require=="function"&&require;for(var i=0;i<r.length;i++)s(r[i]);return s}({1:[function(e,t,n){(function(n,r){"use strict";function s(){throw new Error("Use AsyncTryCatch.try() instead.")}t.exports=s;s.prototype.__prototypeUID__="async-try-catch/AsyncTryCatch";s.prototype.__prototypeVersion__=e("../package.json").version;if(r.AsyncTryCatch){if(r.AsyncTryCatch.prototype.__prototypeUID__==="async-try-catch/AsyncTryCatch"){var o=s.prototype.__prototypeVersion__.split(".");var i=r.AsyncTryCatch.prototype.__prototypeVersion__.split(".");if(i[0]!==o[0]||o[0]==="0"&&i[1]!==o[1]){throw new Error("Incompatible version of AsyncTryCatch already installed on global.AsyncTryCatch: "+r.AsyncTryCatch.prototype.__prototypeVersion__+", current version: "+s.prototype.__prototypeVersion__)}}else{throw new Error("Incompatible module already installed on global.AsyncTryCatch")}}else{r.AsyncTryCatch=s;r.AsyncTryCatch.stack=[];r.AsyncTryCatch.substituted=false;r.AsyncTryCatch.NextGenEvents=[]}if(n.browser&&!r.setImmediate){r.setImmediate=function e(t){return setTimeout(t,0)};r.clearImmediate=function e(t){return clearTimeout(t)}}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}s.try=function e(t){var n=Object.create(s.prototype,{fn:{value:t,enumerable:true},parent:{value:r.AsyncTryCatch.stack[r.AsyncTryCatch.stack.length-1]}});return n};s.prototype.catch=function e(t){Object.defineProperties(this,{catchFn:{value:t,enumerable:true}});if(!r.AsyncTryCatch.substituted){s.substitute()}try{r.AsyncTryCatch.stack.push(this);this.fn();r.AsyncTryCatch.stack.pop()}catch(e){r.AsyncTryCatch.stack.pop();this.callCatchFn(e)}};s.prototype.callCatchFn=function e(t){if(!this.parent){this.catchFn(t);return}try{r.AsyncTryCatch.stack.push(this.parent);this.catchFn(t);r.AsyncTryCatch.stack.pop()}catch(e){r.AsyncTryCatch.stack.pop();this.parent.callCatchFn(e)}};s.timerWrapper=function e(t,n,...s){var o,i;if(typeof n!=="function"||!r.AsyncTryCatch.stack.length){return t.call(this,n,...s)}o=r.AsyncTryCatch.stack[r.AsyncTryCatch.stack.length-1];i=function e(...t){var s;try{r.AsyncTryCatch.stack.push(o);s=n.call(this,...t);r.AsyncTryCatch.stack.pop();return s}catch(e){r.AsyncTryCatch.stack.pop();o.callCatchFn(e)}};return t.call(this,i,...s)};s.addListenerWrapper=function e(t,n,s,o,i){var c,a,y;if(typeof s==="object"){o=s;s=o.fn;delete o.fn}if(typeof s!=="function"||!r.AsyncTryCatch.stack.length){return t.call(this,n,s,o)}c=r.AsyncTryCatch.stack[r.AsyncTryCatch.stack.length-1];if(i){y=false;a=function e(...t){var o;if(y){return}y=true;this.removeListener(n,a);try{r.AsyncTryCatch.stack.push(c);o=s.call(this,...t);r.AsyncTryCatch.stack.pop();return o}catch(e){r.AsyncTryCatch.stack.pop();c.callCatchFn(e)}}}else{a=function e(...t){var n;try{r.AsyncTryCatch.stack.push(c);n=s.call(this,...t);r.AsyncTryCatch.stack.pop();return n}catch(e){r.AsyncTryCatch.stack.pop();c.callCatchFn(e)}}}a.listener=s;return t.call(this,n,a,o)};s.setTimeout=s.timerWrapper.bind(undefined,r.Vanilla.setTimeout);s.setImmediate=s.timerWrapper.bind(undefined,r.Vanilla.setImmediate);s.nextTick=s.timerWrapper.bind(n,r.Vanilla.nextTick);s.addListener=function e(t,n){return s.addListenerWrapper.call(this,s.NodeEvents.__addListener,t,n)};s.addListenerOnce=function e(t,n){return s.addListenerWrapper.call(this,s.NodeEvents.__addListener,t,n,undefined,true)};s.removeListener=function e(t,n){return s.NodeEvents.__removeListener.call(this,t,n)};s.ngevAddListener=function e(t,n,r){if(n&&typeof n==="object"){if(n.id===undefined){n.id=n.fn}}else if(r&&typeof r==="object"){if(r.id===undefined){r.id=n}}else{r={id:n}}return s.addListenerWrapper.call(this,s.NextGenEvents[this.asyncTryCatchId].on,t,n,r)};s.ngevAddListenerOnce=function e(t,n,r){if(n&&typeof n==="object"){if(n.id===undefined){n.id=n.fn}}else if(r&&typeof r==="object"){if(r.id===undefined){r.id=n}}else{r={id:n}}return s.addListenerWrapper.call(this,s.NextGenEvents[this.asyncTryCatchId].once,t,n,r)};s.ngevRemoveListener=function e(t,n){return s.NextGenEvents[this.asyncTryCatchId].off.call(this,t,n)};s.substitute=function t(){r.AsyncTryCatch.substituted=true;r.setTimeout=s.setTimeout;r.setImmediate=s.setTimeout;n.nextTick=s.nextTick;try{s.NodeEvents=r.EventEmitter||e("events")}catch(e){}if(s.NodeEvents){if(!s.NodeEvents.__addListener){s.NodeEvents.__addListener=s.NodeEvents.prototype.on}if(!s.NodeEvents.__addListenerOnce){s.NodeEvents.__addListenerOnce=s.NodeEvents.prototype.once}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}for(var o=0;o<s.NextGenEvents.length;o++){s.NextGenEvents[o].prototype.on=s.ngevAddListener;s.NextGenEvents[o].prototype.addListener=s.ngevAddListener;s.NextGenEvents[o].prototype.once=s.ngevAddListenerOnce;s.NextGenEvents[o].prototype.off=s.ngevRemoveListener;s.NextGenEvents[o].prototype.removeListener=s.ngevRemoveListener}};s.restore=function e(){r.AsyncTryCatch.substituted=false;r.setTimeout=r.Vanilla.setTimeout;r.setImmediate=r.Vanilla.setImmediate;n.nextTick=r.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}for(var t=0;t<s.NextGenEvents.length;t++){s.NextGenEvents[t].prototype.on=s.NextGenEvents[t].on;s.NextGenEvents[t].prototype.addListener=s.NextGenEvents[t].on;s.NextGenEvents[t].prototype.once=s.NextGenEvents[t].once;s.NextGenEvents[t].prototype.off=s.NextGenEvents[t].off;s.NextGenEvents[t].prototype.removeListener=s.NextGenEvents[t].removeListener}}}).call(this,e("_process"),typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"../package.json":4,_process:3,events:2}],2:[function(e,t,n){},{}],3:[function(e,t,n){var r=t.exports={};var s;var o;function i(){throw new Error("setTimeout has not been defined")}function c(){throw new Error("clearTimeout has not been defined")}(function(){try{if(typeof setTimeout==="function"){s=setTimeout}else{s=i}}catch(e){s=i}try{if(typeof clearTimeout==="function"){o=clearTimeout}else{o=c}}catch(e){o=c}})();function a(e){if(s===setTimeout){return setTimeout(e,0)}if((s===i||!s)&&setTimeout){s=setTimeout;return setTimeout(e,0)}try{return s(e,0)}catch(t){try{return s.call(null,e,0)}catch(t){return s.call(this,e,0)}}}function y(e){if(o===clearTimeout){return clearTimeout(e)}if((o===c||!o)&&clearTimeout){o=clearTimeout;return clearTimeout(e)}try{return o(e)}catch(t){try{return o.call(null,e)}catch(t){return o.call(this,e)}}}var u=[];var d=false;var l;var p=-1;function f(){if(!d||!l){return}d=false;if(l.length){u=l.concat(u)}else{p=-1}if(u.length){h()}}function h(){if(d){return}var e=a(f);d=true;var t=u.length;while(t){l=u;u=[];while(++p<t){if(l){l[p].run()}}p=-1;t=u.length}l=null;d=false;y(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]}}u.push(new v(e,t));if(u.length===1&&!d){a(h)}};function v(e,t){this.fun=e;this.array=t}v.prototype.run=function(){this.fun.apply(null,this.array)};r.title="browser";r.browser=true;r.env={};r.argv=[];r.version="";r.versions={};function m(){}r.on=m;r.addListener=m;r.once=m;r.off=m;r.removeListener=m;r.removeAllListeners=m;r.emit=m;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}},{}],4:[function(e,t,n){t.exports={name:"async-try-catch",version:"0.3.6",description:"Async try catch",main:"lib/AsyncTryCatch.js",directories:{test:"test"},dependencies:{},devDependencies:{browserify:"^13.1.0","expect.js":"^0.3.1",jshint:"^2.9.3",mocha:"^3.0.2","nextgen-events":"^0.12.3","uglify-js-es6":"^2.8.9"},scripts:{test:"mocha -R dot"},repository:{type:"git",url:"https://github.com/cronvel/async-try-catch.git"},keywords:["async","try","catch"],author:"Cédric Ronvel",license:"MIT",bugs:{url:"https://github.com/cronvel/async-try-catch/issues"},copyright:{title:"Async Try-Catch",years:[2015,2018],owner:"Cédric Ronvel"}}},{}]},{},[1])(1)});
/*
Async Try-Catch
Copyright (c) 2015 - 2016 Cédric Ronvel
Copyright (c) 2015 - 2018 Cédric Ronvel
The MIT License (MIT)
Permission is hereby granted, free of charge, to any person obtaining a copy

@@ -14,6 +14,6 @@ of this software and associated documentation files (the "Software"), to deal

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

@@ -39,11 +39,9 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

if ( global.AsyncTryCatch )
{
if ( global.AsyncTryCatch.prototype.__prototypeUID__ === 'async-try-catch/AsyncTryCatch' )
{
if ( global.AsyncTryCatch ) {
if ( global.AsyncTryCatch.prototype.__prototypeUID__ === 'async-try-catch/AsyncTryCatch' ) {
//console.log( "Already installed:" , global.AsyncTryCatch.prototype.__prototypeVersion__ , "current:" , AsyncTryCatch.prototype.__prototypeVersion__ ) ;
var currentVersions = AsyncTryCatch.prototype.__prototypeVersion__.split( '.' ) ;
var installedVersions = global.AsyncTryCatch.prototype.__prototypeVersion__.split( '.' ) ;
// Basic semver comparison

@@ -53,4 +51,3 @@ if (

( currentVersions[ 0 ] === "0" && installedVersions[ 1 ] !== currentVersions[ 1 ] )
)
{
) {
throw new Error(

@@ -63,9 +60,7 @@ "Incompatible version of AsyncTryCatch already installed on global.AsyncTryCatch: " +

}
else
{
else {
throw new Error( "Incompatible module already installed on global.AsyncTryCatch" ) ;
}
}
else
{
else {
global.AsyncTryCatch = AsyncTryCatch ;

@@ -79,4 +74,3 @@ global.AsyncTryCatch.stack = [] ;

if ( process.browser && ! global.setImmediate )
{
if ( process.browser && ! global.setImmediate ) {
global.setImmediate = function setImmediate( fn ) { return setTimeout( fn , 0 ) ; } ;

@@ -95,4 +89,3 @@ global.clearImmediate = function clearImmediate( timer ) { return clearTimeout( timer ) ; } ;

AsyncTryCatch.try = function try_( fn )
{
AsyncTryCatch.try = function try_( fn ) {
var self = Object.create( AsyncTryCatch.prototype , {

@@ -102,3 +95,3 @@ fn: { value: fn , enumerable: true } ,

} ) ;
return self ;

@@ -109,10 +102,9 @@ } ;

AsyncTryCatch.prototype.catch = function catch_( catchFn )
{
AsyncTryCatch.prototype.catch = function catch_( catchFn ) {
Object.defineProperties( this , {
catchFn: { value: catchFn , enumerable: true }
} ) ;
if ( ! global.AsyncTryCatch.substituted ) { AsyncTryCatch.substitute() ; }
try {

@@ -127,3 +119,3 @@ global.AsyncTryCatch.stack.push( this ) ;

}
} ;

@@ -134,10 +126,8 @@

// Handle the bubble up
AsyncTryCatch.prototype.callCatchFn = function callCatchFn( error )
{
if ( ! this.parent )
{
AsyncTryCatch.prototype.callCatchFn = function callCatchFn( error ) {
if ( ! this.parent ) {
this.catchFn( error ) ;
return ;
}
try {

@@ -148,5 +138,5 @@ global.AsyncTryCatch.stack.push( this.parent ) ;

}
catch ( error ) {
catch ( error_ ) {
global.AsyncTryCatch.stack.pop() ;
this.parent.callCatchFn( error ) ;
this.parent.callCatchFn( error_ ) ;
}

@@ -158,19 +148,19 @@ } ;

// for setTimeout(), setImmediate(), process.nextTick()
AsyncTryCatch.timerWrapper = function timerWrapper( originalMethod , fn )
{
var fn , context , wrapperFn ,
args = Array.prototype.slice.call( arguments , 1 ) ;
if ( typeof fn !== 'function' || ! global.AsyncTryCatch.stack.length )
{
return originalMethod.apply( this , args ) ;
AsyncTryCatch.timerWrapper = function timerWrapper( originalMethod , fn , ... args ) {
var context , wrapperFn ;
if ( typeof fn !== 'function' || ! global.AsyncTryCatch.stack.length ) {
return originalMethod.call( this , fn , ... args ) ;
}
context = global.AsyncTryCatch.stack[ global.AsyncTryCatch.stack.length - 1 ] ;
wrapperFn = function timerWrapperFn() {
wrapperFn = function timerWrapperFn( ... wrapperArgs ) {
var returnVal ;
try {
global.AsyncTryCatch.stack.push( context ) ;
return fn.apply( this , arguments ) ;
returnVal = fn.call( this , ... wrapperArgs ) ;
global.AsyncTryCatch.stack.pop() ;
return returnVal ;
}

@@ -182,6 +172,4 @@ catch ( error ) {

} ;
args[ 0 ] = wrapperFn ;
return originalMethod.apply( this , args ) ;
return originalMethod.call( this , wrapperFn , ... args ) ;
} ;

@@ -192,9 +180,7 @@

// for Node-EventEmitter-compatible .addListener()
AsyncTryCatch.addListenerWrapper = function addListenerWrapper( originalMethod , eventName , fn , options , onceWrapper )
{
var fn , context , wrapperFn , onceWrapperFired ;
AsyncTryCatch.addListenerWrapper = function addListenerWrapper( originalMethod , eventName , fn , options , onceWrapper ) {
var context , wrapperFn , onceWrapperFired ;
// NextGen event compatibility
if ( typeof fn === 'object' )
{
if ( typeof fn === 'object' ) {
options = fn ;

@@ -204,23 +190,24 @@ fn = options.fn ;

}
if ( typeof fn !== 'function' || ! global.AsyncTryCatch.stack.length )
{
if ( typeof fn !== 'function' || ! global.AsyncTryCatch.stack.length ) {
return originalMethod.call( this , eventName , fn , options ) ;
}
context = global.AsyncTryCatch.stack[ global.AsyncTryCatch.stack.length - 1 ] ;
if ( onceWrapper )
{
if ( onceWrapper ) {
onceWrapperFired = false ;
wrapperFn = function listenerOnceWrapperFn() {
wrapperFn = function listenerOnceWrapperFn( ... wrapperArgs ) {
var returnVal ;
if ( onceWrapperFired ) { return ; }
onceWrapperFired = true ;
this.removeListener( eventName , wrapperFn ) ;
try {
global.AsyncTryCatch.stack.push( context ) ;
return fn.apply( this , arguments ) ;
returnVal = fn.call( this , ... wrapperArgs ) ;
global.AsyncTryCatch.stack.pop() ;
return returnVal ;
}

@@ -233,9 +220,11 @@ catch ( error ) {

}
else
{
wrapperFn = function listenerWrapperFn() {
else {
wrapperFn = function listenerWrapperFn( ... wrapperArgs ) {
var returnVal ;
try {
global.AsyncTryCatch.stack.push( context ) ;
return fn.apply( this , arguments ) ;
returnVal = fn.call( this , ... wrapperArgs ) ;
global.AsyncTryCatch.stack.pop() ;
return returnVal ;
}

@@ -248,7 +237,7 @@ catch ( error ) {

}
// This is used to indicate to node.js core events that this function is a wrapper to another.
// E.g. it is used internally by .removeListener() to find the registered wrapper from the original userland listener.
wrapperFn.listener = fn ;
return originalMethod.call( this , eventName , wrapperFn , options ) ;

@@ -264,4 +253,3 @@ } ;

// NodeEvents on()/addListener() replacement
AsyncTryCatch.addListener = function addListener( eventName , fn )
{
AsyncTryCatch.addListener = function addListener( eventName , fn ) {
return AsyncTryCatch.addListenerWrapper.call( this , AsyncTryCatch.NodeEvents.__addListener , eventName , fn ) ;

@@ -271,4 +259,3 @@ } ;

// NodeEvents once() replacement
AsyncTryCatch.addListenerOnce = function addListenerOnce( eventName , fn )
{
AsyncTryCatch.addListenerOnce = function addListenerOnce( eventName , fn ) {
return AsyncTryCatch.addListenerWrapper.call( this , AsyncTryCatch.NodeEvents.__addListener , eventName , fn , undefined , true ) ;

@@ -278,4 +265,3 @@ } ;

// NodeEvents removeListener() replacement
AsyncTryCatch.removeListener = function removeListener( eventName , fn )
{
AsyncTryCatch.removeListener = function removeListener( eventName , fn ) {
return AsyncTryCatch.NodeEvents.__removeListener.call( this , eventName , fn ) ;

@@ -285,7 +271,14 @@ } ;

// NextGen Events on()/addListener() replacement
AsyncTryCatch.ngevAddListener = function ngevAddListener( eventName , fn , options )
{
if ( ! options ) { options = {} ; }
if ( options.id === undefined ) { options.id = fn ; }
AsyncTryCatch.ngevAddListener = function ngevAddListener( eventName , fn , options ) {
// Ensure there is an id argument
if ( fn && typeof fn === 'object' ) {
if ( fn.id === undefined ) { fn.id = fn.fn ; }
}
else if ( options && typeof options === 'object' ) {
if ( options.id === undefined ) { options.id = fn ; }
}
else {
options = { id: fn } ;
}
return AsyncTryCatch.addListenerWrapper.call( this ,

@@ -297,7 +290,14 @@ AsyncTryCatch.NextGenEvents[ this.asyncTryCatchId ].on ,

// NextGen Events once() replacement
AsyncTryCatch.ngevAddListenerOnce = function ngevAddListenerOnce( eventName , fn , options )
{
if ( ! options ) { options = {} ; }
if ( options.id === undefined ) { options.id = fn ; }
AsyncTryCatch.ngevAddListenerOnce = function ngevAddListenerOnce( eventName , fn , options ) {
// Ensure there is an id argument
if ( fn && typeof fn === 'object' ) {
if ( fn.id === undefined ) { fn.id = fn.fn ; }
}
else if ( options && typeof options === 'object' ) {
if ( options.id === undefined ) { options.id = fn ; }
}
else {
options = { id: fn } ;
}
return AsyncTryCatch.addListenerWrapper.call( this ,

@@ -309,4 +309,3 @@ AsyncTryCatch.NextGenEvents[ this.asyncTryCatchId ].once ,

// NextGen Events off()/removeListener() replacement
AsyncTryCatch.ngevRemoveListener = function ngevRemoveListener( eventName , id )
{
AsyncTryCatch.ngevRemoveListener = function ngevRemoveListener( eventName , id ) {
return AsyncTryCatch.NextGenEvents[ this.asyncTryCatchId ].off.call( this , eventName , id ) ;

@@ -317,36 +316,32 @@ } ;

AsyncTryCatch.substitute = function substitute()
{
AsyncTryCatch.substitute = function substitute() {
// This test should be done by the caller, because substitution could be incomplete
// E.g. browser case: Node Events or NextGen Events are not loaded/accessible at time
//if ( global.AsyncTryCatch.substituted ) { return ; }
global.AsyncTryCatch.substituted = true ;
global.setTimeout = AsyncTryCatch.setTimeout ;
global.setImmediate = AsyncTryCatch.setTimeout ;
process.nextTick = AsyncTryCatch.nextTick ;
// Global is checked first, in case we are running inside a browser
try {
AsyncTryCatch.NodeEvents = global.EventEmitter || require( 'events' ) ;
} catch ( error ) {}
if ( AsyncTryCatch.NodeEvents )
{
if ( ! AsyncTryCatch.NodeEvents.__addListener )
{
}
catch ( error ) {}
if ( AsyncTryCatch.NodeEvents ) {
if ( ! AsyncTryCatch.NodeEvents.__addListener ) {
AsyncTryCatch.NodeEvents.__addListener = AsyncTryCatch.NodeEvents.prototype.on ;
}
if ( ! AsyncTryCatch.NodeEvents.__addListenerOnce )
{
if ( ! AsyncTryCatch.NodeEvents.__addListenerOnce ) {
AsyncTryCatch.NodeEvents.__addListenerOnce = AsyncTryCatch.NodeEvents.prototype.once ;
}
if ( ! AsyncTryCatch.NodeEvents.__removeListener )
{
if ( ! AsyncTryCatch.NodeEvents.__removeListener ) {
AsyncTryCatch.NodeEvents.__removeListener = AsyncTryCatch.NodeEvents.prototype.removeListener ;
}
AsyncTryCatch.NodeEvents.prototype.on = AsyncTryCatch.addListener ;

@@ -357,5 +352,4 @@ AsyncTryCatch.NodeEvents.prototype.addListener = AsyncTryCatch.addListener ;

}
for ( var i = 0 ; i < AsyncTryCatch.NextGenEvents.length ; i ++ )
{
for ( var i = 0 ; i < AsyncTryCatch.NextGenEvents.length ; i ++ ) {
//console.log( 'substituting NextGenEvents' , i ) ;

@@ -372,16 +366,14 @@ AsyncTryCatch.NextGenEvents[ i ].prototype.on = AsyncTryCatch.ngevAddListener ;

AsyncTryCatch.restore = function restore()
{
AsyncTryCatch.restore = function restore() {
// This test should be done by the caller, because substitution could be incomplete
// E.g. browser case: Node Events or NextGen Events are not loaded/accessible at time
//if ( ! global.AsyncTryCatch.substituted ) { return ; }
global.AsyncTryCatch.substituted = false ;
global.setTimeout = global.Vanilla.setTimeout ;
global.setImmediate = global.Vanilla.setImmediate ;
process.nextTick = global.Vanilla.nextTick ;
if ( AsyncTryCatch.NodeEvents )
{
if ( AsyncTryCatch.NodeEvents ) {
AsyncTryCatch.NodeEvents.prototype.on = AsyncTryCatch.NodeEvents.__addListener ;

@@ -392,5 +384,4 @@ AsyncTryCatch.NodeEvents.prototype.addListener = AsyncTryCatch.NodeEvents.__addListener ;

}
for ( var i = 0 ; i < AsyncTryCatch.NextGenEvents.length ; i ++ )
{
for ( var i = 0 ; i < AsyncTryCatch.NextGenEvents.length ; i ++ ) {
AsyncTryCatch.NextGenEvents[ i ].prototype.on = AsyncTryCatch.NextGenEvents[ i ].on ;

@@ -397,0 +388,0 @@ AsyncTryCatch.NextGenEvents[ i ].prototype.addListener = AsyncTryCatch.NextGenEvents[ i ].on ;

{
"name": "async-try-catch",
"version": "0.3.4",
"version": "0.3.6",
"description": "Async try catch",

@@ -15,4 +15,4 @@ "main": "lib/AsyncTryCatch.js",

"mocha": "^3.0.2",
"nextgen-events": "^0.9.7",
"uglify-js": "^2.7.3"
"nextgen-events": "^0.12.3",
"uglify-js-es6": "^2.8.9"
},

@@ -40,3 +40,3 @@ "scripts": {

2015,
2016
2018
],

@@ -43,0 +43,0 @@ "owner": "Cédric Ronvel"

/*
Async Try-Catch
Copyright (c) 2015 - 2016 Cédric Ronvel
Copyright (c) 2015 - 2018 Cédric Ronvel

@@ -6,0 +6,0 @@ The MIT License (MIT)

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