File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2879,6 +2879,18 @@ inline MaybeOrValue<Promise> Promise::Catch(napi_value onRejected) const {
28792879#endif
28802880}
28812881
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+
28822894// //////////////////////////////////////////////////////////////////////////////
28832895// Buffer<T> class
28842896// //////////////////////////////////////////////////////////////////////////////
Original file line number Diff line number Diff line change @@ -1580,6 +1580,10 @@ class Promise : public Object {
15801580 MaybeOrValue<Promise> Then (napi_value onFulfilled) const ;
15811581 MaybeOrValue<Promise> Then (napi_value onFulfilled, napi_value onRejected) const ;
15821582 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 ;
15831587};
15841588
15851589template <typename T>
Original file line number Diff line number Diff line change @@ -35,4 +35,9 @@ async function test (binding) {
3535 assert . strictEqual ( thenRejected . isPromise , true ) ;
3636 const rejectedValue = await thenRejected . promise ;
3737 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!' ) ;
3843}
You can’t perform that action at this time.
0 commit comments