File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -2879,6 +2879,18 @@ inline MaybeOrValue<Promise> Promise::Catch(napi_value onRejected) const {
2879
2879
#endif
2880
2880
}
2881
2881
2882
+ inline MaybeOrValue<Promise> Promise::Then (const Function& onFulfilled) const {
2883
+ return Then (static_cast <napi_value>(onFulfilled));
2884
+ }
2885
+
2886
+ inline MaybeOrValue<Promise> Promise::Then (const Function& onFulfilled, const Function& onRejected) const {
2887
+ return Then (static_cast <napi_value>(onFulfilled), static_cast <napi_value>(onRejected));
2888
+ }
2889
+
2890
+ inline MaybeOrValue<Promise> Promise::Catch (const Function& onRejected) const {
2891
+ return Catch (static_cast <napi_value>(onRejected));
2892
+ }
2893
+
2882
2894
// //////////////////////////////////////////////////////////////////////////////
2883
2895
// Buffer<T> class
2884
2896
// //////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change @@ -1580,6 +1580,10 @@ class Promise : public Object {
1580
1580
MaybeOrValue<Promise> Then (napi_value onFulfilled) const ;
1581
1581
MaybeOrValue<Promise> Then (napi_value onFulfilled, napi_value onRejected) const ;
1582
1582
MaybeOrValue<Promise> Catch (napi_value onRejected) const ;
1583
+
1584
+ MaybeOrValue<Promise> Then (const Function& onFulfilled) const ;
1585
+ MaybeOrValue<Promise> Then (const Function& onFulfilled, const Function& onRejected) const ;
1586
+ MaybeOrValue<Promise> Catch (const Function& onRejected) const ;
1583
1587
};
1584
1588
1585
1589
template <typename T>
Original file line number Diff line number Diff line change @@ -35,4 +35,9 @@ async function test (binding) {
35
35
assert . strictEqual ( thenRejected . isPromise , true ) ;
36
36
const rejectedValue = await thenRejected . promise ;
37
37
assert . strictEqual ( rejectedValue , 'Rejected!' ) ;
38
+
39
+ const catchMethod = binding . promise . catchMethod ( onRejected ) ;
40
+ assert . strictEqual ( catchMethod . isPromise , true ) ;
41
+ const catchValue = await catchMethod . promise ;
42
+ assert . strictEqual ( catchValue , 'Rejected!' ) ;
38
43
}
You can’t perform that action at this time.
0 commit comments