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.3.2 to 0.3.3

187

browser/AsyncTryCatch.js

@@ -61,3 +61,2 @@ (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){

}
//global.AsyncTryCatch = AsyncTryCatch ;
}

@@ -235,13 +234,9 @@ else

AsyncTryCatch.removeListenerWrapper = function removeListenerWrapper( originalMethod , eventName , fn )
/*
// Not useful anymore
AsyncTryCatch.removeListenerWrapper = function removeListenerWrapper( originalMethod , eventName , fnOrId )
{
//console.log( 'fn:' , fn ) ;
if ( typeof fn === 'function' && this.__fnToWrapperMap )
{
fn = this.__fnToWrapperMap.get( fn ) || fn ;
}
return originalMethod.call( this , eventName , fn ) ;
return originalMethod.call( this , eventName , fnOrId ) ;
} ;
*/

@@ -269,3 +264,9 @@

{
return AsyncTryCatch.removeListenerWrapper.call( this , AsyncTryCatch.NodeEvents.__removeListener , eventName , fn ) ;
if ( typeof fn === 'function' && this.__fnToWrapperMap )
{
fn = this.__fnToWrapperMap.get( fn ) || fn ;
}
//return AsyncTryCatch.removeListenerWrapper.call( this , AsyncTryCatch.NodeEvents.__removeListener , eventName , fn ) ;
return AsyncTryCatch.NodeEvents.__removeListener.call( this , eventName , fn ) ;
} ;

@@ -276,14 +277,8 @@

{
/*
console.log( 'this:' , this ) ;
console.log( 'this.asyncTryCatchId:' , this.asyncTryCatchId ) ;
console.log( 'called with:' , Array.from( arguments ) ) ;
try {*/
return AsyncTryCatch.addListenerWrapper.call( this , AsyncTryCatch.NextGenEvents[ this.asyncTryCatchId ].on , eventName , fn , options ) ;
/*}
catch ( error ) {
console.error( error ) ;
console.log( index ) ;
throw error ;
}*/
if ( ! options ) { options = {} ; }
if ( options.id === undefined ) { options.id = fn ; }
return AsyncTryCatch.addListenerWrapper.call( this ,
AsyncTryCatch.NextGenEvents[ this.asyncTryCatchId ].on ,
eventName , fn , options ) ;
} ;

@@ -294,9 +289,15 @@

{
return AsyncTryCatch.addListenerWrapper.call( this , AsyncTryCatch.NextGenEvents[ this.asyncTryCatchId ].once , eventName , fn , options ) ;
if ( ! options ) { options = {} ; }
if ( options.id === undefined ) { options.id = fn ; }
return AsyncTryCatch.addListenerWrapper.call( this ,
AsyncTryCatch.NextGenEvents[ this.asyncTryCatchId ].once ,
eventName , fn , options ) ;
} ;
// NextGen Events off()/removeListener() replacement
AsyncTryCatch.ngevRemoveListener = function ngevRemoveListener( eventName , fn )
AsyncTryCatch.ngevRemoveListener = function ngevRemoveListener( eventName , id )
{
return AsyncTryCatch.removeListenerWrapper.call( this , AsyncTryCatch.NextGenEvents[ this.asyncTryCatchId ].off , eventName , fn ) ;
//return AsyncTryCatch.removeListenerWrapper.call( this , AsyncTryCatch.NextGenEvents[ this.asyncTryCatchId ].off , eventName , id ) ;
return AsyncTryCatch.NextGenEvents[ this.asyncTryCatchId ].off.call( this , eventName , id ) ;
} ;

@@ -323,8 +324,2 @@

/*
try {
AsyncTryCatch.NextGenEvents = global.NextGenEvents || require( 'nextgen-events' ) ;
} catch ( error ) {}
*/
if ( AsyncTryCatch.NodeEvents )

@@ -362,13 +357,2 @@ {

}
/*
if ( AsyncTryCatch.NextGenEvents )
{
AsyncTryCatch.NextGenEvents.prototype.on = AsyncTryCatch.ngevAddListener ;
AsyncTryCatch.NextGenEvents.prototype.addListener = AsyncTryCatch.ngevAddListener ;
AsyncTryCatch.NextGenEvents.prototype.once = AsyncTryCatch.ngevAddListenerOnce ;
AsyncTryCatch.NextGenEvents.prototype.off = AsyncTryCatch.ngevRemoveListener ;
AsyncTryCatch.NextGenEvents.prototype.removeListener = AsyncTryCatch.ngevRemoveListener ;
}
*/
} ;

@@ -406,13 +390,2 @@

}
/*
if ( AsyncTryCatch.NextGenEvents )
{
AsyncTryCatch.NextGenEvents.prototype.on = AsyncTryCatch.NextGenEvents.on ;
AsyncTryCatch.NextGenEvents.prototype.addListener = AsyncTryCatch.NextGenEvents.on ;
AsyncTryCatch.NextGenEvents.prototype.once = AsyncTryCatch.NextGenEvents.once ;
AsyncTryCatch.NextGenEvents.prototype.off = AsyncTryCatch.NextGenEvents.off ;
AsyncTryCatch.NextGenEvents.prototype.removeListener = AsyncTryCatch.NextGenEvents.removeListener ;
}
*/
} ;

@@ -427,4 +400,90 @@

// shim for using process in browser
var process = module.exports = {};
var process = module.exports = {};
// cached from whatever global is present so that test runners that stub it
// don't break things. But we need to wrap it in a try catch in case it is
// wrapped in strict mode code which doesn't define any globals. It's inside a
// function because try/catches deoptimize in certain engines.
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout () {
throw new Error('clearTimeout has not been defined');
}
(function () {
try {
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
} ())
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
//normal enviroments in sane situations
return setTimeout(fun, 0);
}
// if setTimeout wasn't available but was latter defined
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedSetTimeout(fun, 0);
} catch(e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedSetTimeout.call(null, fun, 0);
} catch(e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
//normal enviroments in sane situations
return clearTimeout(marker);
}
// if clearTimeout wasn't available but was latter defined
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
// when when somebody has screwed with setTimeout but no I.E. maddness
return cachedClearTimeout(marker);
} catch (e){
try {
// When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
return cachedClearTimeout.call(null, marker);
} catch (e){
// same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
// Some versions of I.E. have different rules for clearTimeout vs setTimeout
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];

@@ -454,3 +513,3 @@ var draining = false;

}
var timeout = setTimeout(cleanUpNextTick);
var timeout = runTimeout(cleanUpNextTick);
draining = true;

@@ -472,3 +531,3 @@

draining = false;
clearTimeout(timeout);
runClearTimeout(timeout);
}

@@ -485,3 +544,3 @@

if (queue.length === 1 && !draining) {
setTimeout(drainQueue, 0);
runTimeout(drainQueue);
}

@@ -528,3 +587,3 @@ };

"name": "async-try-catch",
"version": "0.3.2",
"version": "0.3.3",
"description": "Async try catch",

@@ -537,8 +596,8 @@ "main": "lib/AsyncTryCatch.js",

"devDependencies": {
"browserify": "^13.0.1",
"browserify": "^13.1.0",
"expect.js": "^0.3.1",
"jshint": "^2.9.2",
"mocha": "^2.5.3",
"nextgen-events": "^0.9.5",
"uglify-js": "^2.6.2"
"jshint": "^2.9.3",
"mocha": "^3.0.2",
"nextgen-events": "^0.9.7",
"uglify-js": "^2.7.3"
},

@@ -545,0 +604,0 @@ "scripts": {

@@ -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 r(e,t,n){function s(i,a){if(!t[i]){if(!e[i]){var c=typeof require=="function"&&require;if(!a&&c)return c(i,!0);if(o)return o(i,!0);var p=new Error("Cannot find module '"+i+"'");throw p.code="MODULE_NOT_FOUND",p}var y=t[i]={exports:{}};e[i][0].call(y.exports,function(t){var n=e[i][1][t];return s(n?n:t)},y,y.exports,r,e,t,n)}return t[i].exports}var o=typeof require=="function"&&require;for(var i=0;i<n.length;i++)s(n[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 a(e){return setTimeout(e,0)};r.clearImmediate=function c(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}s.try=function p(e){var t=Object.create(s.prototype,{fn:{value:e,enumerable:true},parent:{value:r.AsyncTryCatch.stack[r.AsyncTryCatch.stack.length-1]}});return t};s.prototype.catch=function y(e){Object.defineProperties(this,{catchFn:{value:e,enumerable:true}});if(!r.AsyncTryCatch.substituted){s.substitute()}try{r.AsyncTryCatch.stack.push(this);this.fn();r.AsyncTryCatch.stack.pop()}catch(t){r.AsyncTryCatch.stack.pop();this.callCatchFn(t)}};s.prototype.callCatchFn=function d(e){if(!this.parent){this.catchFn(e);return}try{r.AsyncTryCatch.stack.push(this.parent);this.catchFn(e);r.AsyncTryCatch.stack.pop()}catch(e){r.AsyncTryCatch.stack.pop();this.parent.callCatchFn(e)}};s.timerWrapper=function l(e,t){var t,n,s,o=Array.prototype.slice.call(arguments,1);if(typeof t!=="function"||!r.AsyncTryCatch.stack.length){return e.apply(this,o)}n=r.AsyncTryCatch.stack[r.AsyncTryCatch.stack.length-1];s=function(){try{r.AsyncTryCatch.stack.push(n);return t.apply(this,arguments);r.AsyncTryCatch.stack.pop()}catch(e){r.AsyncTryCatch.stack.pop();n.callCatchFn(e)}};o[0]=s;return e.apply(this,o)};s.addListenerWrapper=function u(e,t,n,s){var n,o,i;if(typeof n==="object"){s=n;n=s.fn;delete s.fn}if(typeof n!=="function"||!r.AsyncTryCatch.stack.length){return e.call(this,t,n,s)}o=r.AsyncTryCatch.stack[r.AsyncTryCatch.stack.length-1];if(this.__fnToWrapperMap){i=this.__fnToWrapperMap.get(n)}else{Object.defineProperty(this,"__fnToWrapperMap",{value:new WeakMap})}if(!i){i=function(){try{r.AsyncTryCatch.stack.push(o);return n.apply(this,arguments);r.AsyncTryCatch.stack.pop()}catch(e){r.AsyncTryCatch.stack.pop();o.callCatchFn(e)}};this.__fnToWrapperMap.set(n,i)}return e.call(this,t,i,s)};s.removeListenerWrapper=function f(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,r.Vanilla.setTimeout);s.setImmediate=s.timerWrapper.bind(undefined,r.Vanilla.setImmediate);s.nextTick=s.timerWrapper.bind(n,r.Vanilla.nextTick);s.addListener=function h(e,t){return s.addListenerWrapper.call(this,s.NodeEvents.__addListener,e,t)};s.addListenerOnce=function v(e,t){return s.addListenerWrapper.call(this,s.NodeEvents.__addListenerOnce,e,t)};s.removeListener=function m(e,t){return s.removeListenerWrapper.call(this,s.NodeEvents.__removeListener,e,t)};s.ngevAddListener=function T(e,t,n){return s.addListenerWrapper.call(this,s.NextGenEvents[this.asyncTryCatchId].on,e,t,n)};s.ngevAddListenerOnce=function _(e,t,n){return s.addListenerWrapper.call(this,s.NextGenEvents[this.asyncTryCatchId].once,e,t,n)};s.ngevRemoveListener=function E(e,t){return s.removeListenerWrapper.call(this,s.NextGenEvents[this.asyncTryCatchId].off,e,t)};s.substitute=function C(){r.AsyncTryCatch.substituted=true;r.setTimeout=s.setTimeout;r.setImmediate=s.setTimeout;n.nextTick=s.nextTick;try{s.NodeEvents=r.EventEmitter||e("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.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 L(){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 e=0;e<s.NextGenEvents.length;e++){s.NextGenEvents[e].prototype.on=s.NextGenEvents[e].on;s.NextGenEvents[e].prototype.addListener=s.NextGenEvents[e].on;s.NextGenEvents[e].prototype.once=s.NextGenEvents[e].once;s.NextGenEvents[e].prototype.off=s.NextGenEvents[e].off;s.NextGenEvents[e].prototype.removeListener=s.NextGenEvents[e].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=false;var i;var a=-1;function c(){if(!o||!i){return}o=false;if(i.length){s=i.concat(s)}else{a=-1}if(s.length){p()}}function p(){if(o){return}var e=setTimeout(c);o=true;var t=s.length;while(t){i=s;s=[];while(++a<t){if(i){i[a].run()}}a=-1;t=s.length}i=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]}}s.push(new y(e,t));if(s.length===1&&!o){setTimeout(p,0)}};function y(e,t){this.fun=e;this.array=t}y.prototype.run=function(){this.fun.apply(null,this.array)};r.title="browser";r.browser=true;r.env={};r.argv=[];r.version="";r.versions={};function d(){}r.on=d;r.addListener=d;r.once=d;r.off=d;r.removeListener=d;r.removeAllListeners=d;r.emit=d;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.2",description:"Async try catch",main:"lib/AsyncTryCatch.js",directories:{test:"test"},dependencies:{},devDependencies:{browserify:"^13.0.1","expect.js":"^0.3.1",jshint:"^2.9.2",mocha:"^2.5.3","nextgen-events":"^0.9.5","uglify-js":"^2.6.2"},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 o(i,c){if(!n[i]){if(!t[i]){var a=typeof require=="function"&&require;if(!c&&a)return a(i,!0);if(s)return s(i,!0);var p=new Error("Cannot find module '"+i+"'");throw p.code="MODULE_NOT_FOUND",p}var y=n[i]={exports:{}};t[i][0].call(y.exports,function(e){var n=t[i][1][e];return o(n?n:e)},y,y.exports,e,t,n,r)}return n[i].exports}var s=typeof require=="function"&&require;for(var i=0;i<r.length;i++)o(r[i]);return o}({1:[function(e,t,n){(function(n,r){"use strict";function o(){throw new Error("Use AsyncTryCatch.try() instead.")}t.exports=o;o.prototype.__prototypeUID__="async-try-catch/AsyncTryCatch";o.prototype.__prototypeVersion__=e("../package.json").version;if(r.AsyncTryCatch){if(r.AsyncTryCatch.prototype.__prototypeUID__==="async-try-catch/AsyncTryCatch"){var s=o.prototype.__prototypeVersion__.split(".");var i=r.AsyncTryCatch.prototype.__prototypeVersion__.split(".");if(i[0]!==s[0]||s[0]==="0"&&i[1]!==s[1]){throw new Error("Incompatible version of AsyncTryCatch already installed on global.AsyncTryCatch: "+r.AsyncTryCatch.prototype.__prototypeVersion__+", current version: "+o.prototype.__prototypeVersion__)}}else{throw new Error("Incompatible module already installed on global.AsyncTryCatch")}}else{r.AsyncTryCatch=o;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}o.try=function e(t){var n=Object.create(o.prototype,{fn:{value:t,enumerable:true},parent:{value:r.AsyncTryCatch.stack[r.AsyncTryCatch.stack.length-1]}});return n};o.prototype.catch=function e(t){Object.defineProperties(this,{catchFn:{value:t,enumerable:true}});if(!r.AsyncTryCatch.substituted){o.substitute()}try{r.AsyncTryCatch.stack.push(this);this.fn();r.AsyncTryCatch.stack.pop()}catch(e){r.AsyncTryCatch.stack.pop();this.callCatchFn(e)}};o.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)}};o.timerWrapper=function e(t,n){var n,o,s,i=Array.prototype.slice.call(arguments,1);if(typeof n!=="function"||!r.AsyncTryCatch.stack.length){return t.apply(this,i)}o=r.AsyncTryCatch.stack[r.AsyncTryCatch.stack.length-1];s=function(){try{r.AsyncTryCatch.stack.push(o);return n.apply(this,arguments);r.AsyncTryCatch.stack.pop()}catch(e){r.AsyncTryCatch.stack.pop();o.callCatchFn(e)}};i[0]=s;return t.apply(this,i)};o.addListenerWrapper=function e(t,n,o,s){var o,i,c;if(typeof o==="object"){s=o;o=s.fn;delete s.fn}if(typeof o!=="function"||!r.AsyncTryCatch.stack.length){return t.call(this,n,o,s)}i=r.AsyncTryCatch.stack[r.AsyncTryCatch.stack.length-1];if(this.__fnToWrapperMap){c=this.__fnToWrapperMap.get(o)}else{Object.defineProperty(this,"__fnToWrapperMap",{value:new WeakMap})}if(!c){c=function(){try{r.AsyncTryCatch.stack.push(i);return o.apply(this,arguments);r.AsyncTryCatch.stack.pop()}catch(e){r.AsyncTryCatch.stack.pop();i.callCatchFn(e)}};this.__fnToWrapperMap.set(o,c)}return t.call(this,n,c,s)};o.setTimeout=o.timerWrapper.bind(undefined,r.Vanilla.setTimeout);o.setImmediate=o.timerWrapper.bind(undefined,r.Vanilla.setImmediate);o.nextTick=o.timerWrapper.bind(n,r.Vanilla.nextTick);o.addListener=function e(t,n){return o.addListenerWrapper.call(this,o.NodeEvents.__addListener,t,n)};o.addListenerOnce=function e(t,n){return o.addListenerWrapper.call(this,o.NodeEvents.__addListenerOnce,t,n)};o.removeListener=function e(t,n){if(typeof n==="function"&&this.__fnToWrapperMap){n=this.__fnToWrapperMap.get(n)||n}return o.NodeEvents.__removeListener.call(this,t,n)};o.ngevAddListener=function e(t,n,r){if(!r){r={}}if(r.id===undefined){r.id=n}return o.addListenerWrapper.call(this,o.NextGenEvents[this.asyncTryCatchId].on,t,n,r)};o.ngevAddListenerOnce=function e(t,n,r){if(!r){r={}}if(r.id===undefined){r.id=n}return o.addListenerWrapper.call(this,o.NextGenEvents[this.asyncTryCatchId].once,t,n,r)};o.ngevRemoveListener=function e(t,n){return o.NextGenEvents[this.asyncTryCatchId].off.call(this,t,n)};o.substitute=function t(){r.AsyncTryCatch.substituted=true;r.setTimeout=o.setTimeout;r.setImmediate=o.setTimeout;n.nextTick=o.nextTick;try{o.NodeEvents=r.EventEmitter||e("events")}catch(e){}if(o.NodeEvents){if(!o.NodeEvents.__addListener){o.NodeEvents.__addListener=o.NodeEvents.prototype.on}if(!o.NodeEvents.__addListenerOnce){o.NodeEvents.__addListenerOnce=o.NodeEvents.prototype.once}if(!o.NodeEvents.__removeListener){o.NodeEvents.__removeListener=o.NodeEvents.prototype.removeListener}o.NodeEvents.prototype.on=o.addListener;o.NodeEvents.prototype.addListener=o.addListener;o.NodeEvents.prototype.once=o.addListenerOnce;o.NodeEvents.prototype.removeListener=o.removeListener}for(var s=0;s<o.NextGenEvents.length;s++){o.NextGenEvents[s].prototype.on=o.ngevAddListener;o.NextGenEvents[s].prototype.addListener=o.ngevAddListener;o.NextGenEvents[s].prototype.once=o.ngevAddListenerOnce;o.NextGenEvents[s].prototype.off=o.ngevRemoveListener;o.NextGenEvents[s].prototype.removeListener=o.ngevRemoveListener}};o.restore=function e(){r.AsyncTryCatch.substituted=false;r.setTimeout=r.Vanilla.setTimeout;r.setImmediate=r.Vanilla.setImmediate;n.nextTick=r.Vanilla.nextTick;if(o.NodeEvents){o.NodeEvents.prototype.on=o.NodeEvents.__addListener;o.NodeEvents.prototype.addListener=o.NodeEvents.__addListener;o.NodeEvents.prototype.once=o.NodeEvents.__addListenerOnce;o.NodeEvents.prototype.removeListener=o.NodeEvents.__removeListener}for(var t=0;t<o.NextGenEvents.length;t++){o.NextGenEvents[t].prototype.on=o.NextGenEvents[t].on;o.NextGenEvents[t].prototype.addListener=o.NextGenEvents[t].on;o.NextGenEvents[t].prototype.once=o.NextGenEvents[t].once;o.NextGenEvents[t].prototype.off=o.NextGenEvents[t].off;o.NextGenEvents[t].prototype.removeListener=o.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 o;var s;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"){o=setTimeout}else{o=i}}catch(e){o=i}try{if(typeof clearTimeout==="function"){s=clearTimeout}else{s=c}}catch(e){s=c}})();function a(e){if(o===setTimeout){return setTimeout(e,0)}if((o===i||!o)&&setTimeout){o=setTimeout;return setTimeout(e,0)}try{return o(e,0)}catch(t){try{return o.call(null,e,0)}catch(t){return o.call(this,e,0)}}}function p(e){if(s===clearTimeout){return clearTimeout(e)}if((s===c||!s)&&clearTimeout){s=clearTimeout;return clearTimeout(e)}try{return s(e)}catch(t){try{return s.call(null,e)}catch(t){return s.call(this,e)}}}var y=[];var u=false;var l;var d=-1;function f(){if(!u||!l){return}u=false;if(l.length){y=l.concat(y)}else{d=-1}if(y.length){h()}}function h(){if(u){return}var e=a(f);u=true;var t=y.length;while(t){l=y;y=[];while(++d<t){if(l){l[d].run()}}d=-1;t=y.length}l=null;u=false;p(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]}}y.push(new v(e,t));if(y.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.3",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)});

@@ -59,3 +59,2 @@ /*

}
//global.AsyncTryCatch = AsyncTryCatch ;
}

@@ -233,13 +232,9 @@ else

AsyncTryCatch.removeListenerWrapper = function removeListenerWrapper( originalMethod , eventName , fn )
/*
// Not useful anymore
AsyncTryCatch.removeListenerWrapper = function removeListenerWrapper( originalMethod , eventName , fnOrId )
{
//console.log( 'fn:' , fn ) ;
if ( typeof fn === 'function' && this.__fnToWrapperMap )
{
fn = this.__fnToWrapperMap.get( fn ) || fn ;
}
return originalMethod.call( this , eventName , fn ) ;
return originalMethod.call( this , eventName , fnOrId ) ;
} ;
*/

@@ -267,3 +262,9 @@

{
return AsyncTryCatch.removeListenerWrapper.call( this , AsyncTryCatch.NodeEvents.__removeListener , eventName , fn ) ;
if ( typeof fn === 'function' && this.__fnToWrapperMap )
{
fn = this.__fnToWrapperMap.get( fn ) || fn ;
}
//return AsyncTryCatch.removeListenerWrapper.call( this , AsyncTryCatch.NodeEvents.__removeListener , eventName , fn ) ;
return AsyncTryCatch.NodeEvents.__removeListener.call( this , eventName , fn ) ;
} ;

@@ -274,14 +275,8 @@

{
/*
console.log( 'this:' , this ) ;
console.log( 'this.asyncTryCatchId:' , this.asyncTryCatchId ) ;
console.log( 'called with:' , Array.from( arguments ) ) ;
try {*/
return AsyncTryCatch.addListenerWrapper.call( this , AsyncTryCatch.NextGenEvents[ this.asyncTryCatchId ].on , eventName , fn , options ) ;
/*}
catch ( error ) {
console.error( error ) ;
console.log( index ) ;
throw error ;
}*/
if ( ! options ) { options = {} ; }
if ( options.id === undefined ) { options.id = fn ; }
return AsyncTryCatch.addListenerWrapper.call( this ,
AsyncTryCatch.NextGenEvents[ this.asyncTryCatchId ].on ,
eventName , fn , options ) ;
} ;

@@ -292,9 +287,15 @@

{
return AsyncTryCatch.addListenerWrapper.call( this , AsyncTryCatch.NextGenEvents[ this.asyncTryCatchId ].once , eventName , fn , options ) ;
if ( ! options ) { options = {} ; }
if ( options.id === undefined ) { options.id = fn ; }
return AsyncTryCatch.addListenerWrapper.call( this ,
AsyncTryCatch.NextGenEvents[ this.asyncTryCatchId ].once ,
eventName , fn , options ) ;
} ;
// NextGen Events off()/removeListener() replacement
AsyncTryCatch.ngevRemoveListener = function ngevRemoveListener( eventName , fn )
AsyncTryCatch.ngevRemoveListener = function ngevRemoveListener( eventName , id )
{
return AsyncTryCatch.removeListenerWrapper.call( this , AsyncTryCatch.NextGenEvents[ this.asyncTryCatchId ].off , eventName , fn ) ;
//return AsyncTryCatch.removeListenerWrapper.call( this , AsyncTryCatch.NextGenEvents[ this.asyncTryCatchId ].off , eventName , id ) ;
return AsyncTryCatch.NextGenEvents[ this.asyncTryCatchId ].off.call( this , eventName , id ) ;
} ;

@@ -321,8 +322,2 @@

/*
try {
AsyncTryCatch.NextGenEvents = global.NextGenEvents || require( 'nextgen-events' ) ;
} catch ( error ) {}
*/
if ( AsyncTryCatch.NodeEvents )

@@ -360,13 +355,2 @@ {

}
/*
if ( AsyncTryCatch.NextGenEvents )
{
AsyncTryCatch.NextGenEvents.prototype.on = AsyncTryCatch.ngevAddListener ;
AsyncTryCatch.NextGenEvents.prototype.addListener = AsyncTryCatch.ngevAddListener ;
AsyncTryCatch.NextGenEvents.prototype.once = AsyncTryCatch.ngevAddListenerOnce ;
AsyncTryCatch.NextGenEvents.prototype.off = AsyncTryCatch.ngevRemoveListener ;
AsyncTryCatch.NextGenEvents.prototype.removeListener = AsyncTryCatch.ngevRemoveListener ;
}
*/
} ;

@@ -404,15 +388,4 @@

}
/*
if ( AsyncTryCatch.NextGenEvents )
{
AsyncTryCatch.NextGenEvents.prototype.on = AsyncTryCatch.NextGenEvents.on ;
AsyncTryCatch.NextGenEvents.prototype.addListener = AsyncTryCatch.NextGenEvents.on ;
AsyncTryCatch.NextGenEvents.prototype.once = AsyncTryCatch.NextGenEvents.once ;
AsyncTryCatch.NextGenEvents.prototype.off = AsyncTryCatch.NextGenEvents.off ;
AsyncTryCatch.NextGenEvents.prototype.removeListener = AsyncTryCatch.NextGenEvents.removeListener ;
}
*/
} ;
{
"name": "async-try-catch",
"version": "0.3.2",
"version": "0.3.3",
"description": "Async try catch",

@@ -11,8 +11,8 @@ "main": "lib/AsyncTryCatch.js",

"devDependencies": {
"browserify": "^13.0.1",
"browserify": "^13.1.0",
"expect.js": "^0.3.1",
"jshint": "^2.9.2",
"mocha": "^2.5.3",
"nextgen-events": "^0.9.5",
"uglify-js": "^2.6.2"
"jshint": "^2.9.3",
"mocha": "^3.0.2",
"nextgen-events": "^0.9.7",
"uglify-js": "^2.7.3"
},

@@ -19,0 +19,0 @@ "scripts": {

@@ -386,33 +386,10 @@ /*

} ) ;
it( "historical bug: interruption should works using async emitting" , function( done ) {
var bus = Object.create( NextGenEvents.prototype ) ;
bus.setInterruptible( true ) ;
var onFoo1 , onFoo2 , onFoo3 , onInterrupt1 , onInterrupt2 ;
var triggered = { foo1: 0 , foo2: 0 , foo3: 0 , interrupt1: 0 , interrupt2: 0 } ;
// 3 listeners for 'foo'
bus.on( 'foo' , onFoo1 = function() { triggered.foo1 ++ ; return { want: 'interruption' } ; } ) ;
bus.on( 'foo' , onFoo2 = function() { triggered.foo2 ++ ; } ) ;
bus.on( 'foo' , onFoo3 = function() { triggered.foo3 ++ ; } ) ;
bus.on( 'interrupt' , onInterrupt1 = function( object ) {
triggered.interrupt1 ++ ;
expect( object ).to.eql( { want: 'interruption' } ) ;
} ) ;
bus.on( 'interrupt' , onInterrupt2 = function( object ) {
triggered.interrupt2 ++ ;
//console.error( ">>> object: " , object ) ;
expect( object ).to.eql( { want: 'interruption' } ) ;
expect( triggered ).to.eql( { foo1: 1 , foo2: 0 , foo3: 0 , interrupt1: 1 , interrupt2: 1 } ) ;
done() ;
} ) ;
bus.emit( 20 , 'foo' ) ;
} ) ;
} ) ;
describe( "Full NextGen Events test suite execution" , function() {
require( 'nextgen-events/test/NextGenEvents-test.js' ) ;
} ) ;
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