async-try-catch
Advanced tools
Comparing version 0.1.2 to 0.1.3
{ | ||
"name": "async-try-catch", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"description": "Async try catch", | ||
@@ -5,0 +5,0 @@ "main": "lib/AsyncTryCatch.js", |
@@ -220,2 +220,4 @@ /* | ||
} ) ; | ||
it( "should resume the event emitting" ) ; | ||
} ) ; | ||
@@ -260,4 +262,58 @@ | ||
} ) ; | ||
it( "should work using the listener object syntax" , function( done ) { | ||
var emitter = Object.create( NextGenEvents.prototype ) ; | ||
asyncTry( function() { | ||
emitter.on( 'damage' , { fn: function() { throw new Error( 'argh!' ) ; } } ) ; | ||
} ) | ||
.catch( function( error ) { | ||
expect( error.message ).to.be( 'argh!' ) ; | ||
done() ; | ||
} ) ; | ||
emitter.emit( 'damage' ) ; | ||
} ) ; | ||
it( "should work using the fn followed by an object syntax" , function( done ) { | ||
var emitter = Object.create( NextGenEvents.prototype ) ; | ||
asyncTry( function() { | ||
emitter.on( 'damage' , function() { throw new Error( 'argh!' ) ; } , {} ) ; | ||
} ) | ||
.catch( function( error ) { | ||
expect( error.message ).to.be( 'argh!' ) ; | ||
done() ; | ||
} ) ; | ||
emitter.emit( 'damage' ) ; | ||
} ) ; | ||
it( "should work with async listeners" , function( done ) { | ||
var emitter = Object.create( NextGenEvents.prototype , function() { | ||
console.log( 'Completed?' ) ; | ||
} ) ; | ||
asyncTry( function() { | ||
emitter.on( 'damage' , { | ||
async: true , | ||
fn: function() { | ||
setTimeout( function() { | ||
throw new Error( 'delayed argh!' ) ; | ||
} ) ; | ||
} | ||
} ) ; | ||
} ) | ||
.catch( function( error ) { | ||
expect( error.message ).to.be( 'delayed argh!' ) ; | ||
done() ; | ||
} ) ; | ||
emitter.emit( 'damage' ) ; | ||
} ) ; | ||
} ) ; | ||
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
24396
410