| 1665 | }; |
| 1666 | |
| 1667 | class Promise : public Object { |
| 1668 | public: |
| 1669 | class Deferred { |
| 1670 | public: |
| 1671 | static Deferred New(napi_env env); |
| 1672 | Deferred(napi_env env); |
| 1673 | |
| 1674 | Napi::Promise Promise() const; |
| 1675 | Napi::Env Env() const; |
| 1676 | |
| 1677 | void Resolve(napi_value value) const; |
| 1678 | void Reject(napi_value value) const; |
| 1679 | |
| 1680 | private: |
| 1681 | napi_env _env; |
| 1682 | napi_deferred _deferred; |
| 1683 | napi_value _promise; |
| 1684 | }; |
| 1685 | |
| 1686 | static void CheckCast(napi_env env, napi_value value); |
| 1687 | |
| 1688 | Promise(); |
| 1689 | Promise(napi_env env, napi_value value); |
| 1690 | |
| 1691 | MaybeOrValue<Promise> Then(napi_value onFulfilled) const; |
| 1692 | MaybeOrValue<Promise> Then(napi_value onFulfilled, |
| 1693 | napi_value onRejected) const; |
| 1694 | MaybeOrValue<Promise> Catch(napi_value onRejected) const; |
| 1695 | |
| 1696 | MaybeOrValue<Promise> Then(const Function& onFulfilled) const; |
| 1697 | MaybeOrValue<Promise> Then(const Function& onFulfilled, |
| 1698 | const Function& onRejected) const; |
| 1699 | MaybeOrValue<Promise> Catch(const Function& onRejected) const; |
| 1700 | }; |
| 1701 | |
| 1702 | template <typename T> |
| 1703 | class Buffer : public Uint8Array { |