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.1.1 to 0.1.2

2

package.json
{
"name": "async-try-catch",
"version": "0.1.1",
"version": "0.1.2",
"description": "Async try catch",

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

@@ -81,3 +81,3 @@ /*

it( "Async: setTimeout" , function( done ) {
it( "setTimeout()" , function( done ) {

@@ -95,5 +95,31 @@ asyncTry( function() {

it( "Async: nested setTimeout" , function( done ) {
it( "setImmediate()" , function( done ) {
asyncTry( function() {
setImmediate( function() {
throw new Error( 'setImmediate error' ) ;
} , 0 ) ;
} )
.catch( function( error ) {
expect( error.message ).to.be( 'setImmediate error' ) ;
done() ;
} ) ;
} ) ;
it( "process.nextTick()" , function( done ) {
asyncTry( function() {
process.nextTick( function() {
throw new Error( 'nextTick error' ) ;
} , 0 ) ;
} )
.catch( function( error ) {
expect( error.message ).to.be( 'nextTick error' ) ;
done() ;
} ) ;
} ) ;
it( "nested setTimeout" , function( done ) {
asyncTry( function() {
setTimeout( function() {

@@ -111,3 +137,3 @@ setTimeout( function() {

it( "Async: five nested setTimeout" , function( done ) {
it( "five nested setTimeout" , function( done ) {

@@ -133,3 +159,3 @@ asyncTry( function() {

it( "Async: nested setTimeout and async try catch, it should throw from the inner try, re-throw from the inner catch, bubble up to the outer catch" , function( done ) {
it( "nested setTimeout and async try catch, it should throw from the inner try, re-throw from the inner catch, bubble up to the outer catch" , function( done ) {

@@ -165,3 +191,3 @@ asyncTry( function outerTry() {

it( "an exception thrown from a listener within an async-try closure should be catched" , function( done ) {
it( "an exception thrown synchronously from a listener within an async-try closure should be catched" , function( done ) {

@@ -181,16 +207,19 @@ var emitter = Object.create( Events.prototype ) ;

it( "an exception thrown from a listener, whose emit is within an async-try closure should be catched if everything is synchronous" , function( done ) {
// works because emit is sync here
it( "an exception thrown asynchronously from a listener within an async-try closure should be catched" , function( done ) {
var emitter = Object.create( Events.prototype ) ;
emitter.on( 'damage' , function() { throw new Error( 'argh!' ) ; } ) ;
asyncTry( function() {
emitter.emit( 'damage' ) ;
emitter.on( 'damage' , function() {
setTimeout( function() {
throw new Error( 'delayed argh!' ) ;
} , 0 ) ;
} ) ;
} )
.catch( function( error ) {
expect( error.message ).to.be( 'argh!' ) ;
expect( error.message ).to.be( 'delayed argh!' ) ;
done() ;
} ) ;
emitter.emit( 'damage' ) ;
} ) ;

@@ -203,3 +232,3 @@ } ) ;

it( "an exception thrown from a listener within an async-try closure should be catched" , function( done ) {
it( "an exception thrown synchronously from a listener within an async-try closure should be catched" , function( done ) {

@@ -219,4 +248,22 @@ var emitter = Object.create( NextGenEvents.prototype ) ;

it( "an exception thrown asynchronously from a listener within an async-try closure should be catched" , function( done ) {
var emitter = Object.create( NextGenEvents.prototype ) ;
asyncTry( function() {
emitter.on( 'damage' , function() {
setTimeout( function() {
throw new Error( 'delayed argh!' ) ;
} , 0 ) ;
} ) ;
} )
.catch( function( error ) {
expect( error.message ).to.be( 'delayed argh!' ) ;
done() ;
} ) ;
emitter.emit( 'damage' ) ;
} ) ;
} ) ;
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