File tree Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Expand file tree Collapse file tree 3 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ function on(promise) {
22
22
* @param {Function } wrapped Function to be decorated
23
23
* @return {Function } Function decorated
24
24
*/
25
- on . handler = ( wrapped ) => ( ) => on ( wrapped ( ) )
25
+ on . handler = ( wrapped ) => ( ... args ) => on ( wrapped ( ... args ) )
26
26
27
27
//Promise type extension
28
28
global . Promise . prototype . handle = function ( ) {
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " await-on" ,
3
- "version" : " 0.1.2 " ,
3
+ "version" : " 0.1.3 " ,
4
4
"description" : " really simple error handling with await/async" ,
5
5
"main" : " lib/await-on.js" ,
6
6
"directories" : {
Original file line number Diff line number Diff line change @@ -3,8 +3,8 @@ const on = require('../lib/await-on')
3
3
const ANSWER = 42
4
4
const ERROR = new Error ( 'Need more time to figure that out' )
5
5
6
- let waitOne = ( ) => new Promise ( resolve => setTimeout ( ( ) => resolve ( ANSWER ) , 1000 ) )
7
- let waitOneAndThrow = ( ) => new Promise ( ( resolve , reject ) => setTimeout ( ( ) => reject ( ERROR ) , 1000 ) )
6
+ let waitOne = ( answer = ANSWER ) => new Promise ( resolve => setTimeout ( ( ) => resolve ( answer ) , 1000 ) )
7
+ let waitOneAndThrow = ( ) => waitOne ( ) . then ( res => Promise . reject ( ERROR ) )
8
8
9
9
tap . test ( "on" , async function ( t ) {
10
10
t . plan ( 2 )
@@ -26,6 +26,18 @@ tap.test("@handler", async function (t) {
26
26
t . equal ( res , ANSWER )
27
27
} )
28
28
29
+ tap . test ( "@handler (with args)" , async function ( t ) {
30
+ t . plan ( 2 )
31
+
32
+ const waitOneHandle = on . handler ( waitOne )
33
+
34
+ const [ err , res ] = await waitOneHandle ( 41 )
35
+
36
+ t . notOk ( err )
37
+ t . equal ( res , 41 )
38
+ } )
39
+
40
+
29
41
tap . test ( "Promise.prototype.handle" , async function ( t ) {
30
42
t . plan ( 2 )
31
43
You can’t perform that action at this time.
0 commit comments