Skip to content

Commit

Permalink
n-api: rename 'promise' parameter to 'value'
Browse files Browse the repository at this point in the history
This change makes it clear that the value doesn't need to be a
Promise, and makes the signature consistent with other napi_is_*
functions.

PR-URL: nodejs#31544
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
  • Loading branch information
tniessen authored and Trott committed Jan 31, 2020
1 parent dd4c62e commit a171314
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions doc/api/n-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4994,12 +4994,12 @@ napiVersion: 1

```C
napi_status napi_is_promise(napi_env env,
napi_value promise,
napi_value value,
bool* is_promise);
```

* `[in] env`: The environment that the API is invoked under.
* `[in] promise`: The promise to examine
* `[in] value`: The value to examine
* `[out] is_promise`: Flag indicating whether `promise` is a native promise
object (that is, a promise object created by the underlying engine).

Expand Down
2 changes: 1 addition & 1 deletion src/js_native_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ NAPI_EXTERN napi_status napi_reject_deferred(napi_env env,
napi_deferred deferred,
napi_value rejection);
NAPI_EXTERN napi_status napi_is_promise(napi_env env,
napi_value promise,
napi_value value,
bool* is_promise);

// Running a script
Expand Down
6 changes: 3 additions & 3 deletions src/js_native_api_v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2999,13 +2999,13 @@ napi_status napi_reject_deferred(napi_env env,
}

napi_status napi_is_promise(napi_env env,
napi_value promise,
napi_value value,
bool* is_promise) {
CHECK_ENV(env);
CHECK_ARG(env, promise);
CHECK_ARG(env, value);
CHECK_ARG(env, is_promise);

*is_promise = v8impl::V8LocalValueFromJsValue(promise)->IsPromise();
*is_promise = v8impl::V8LocalValueFromJsValue(value)->IsPromise();

return napi_clear_last_error(env);
}
Expand Down

0 comments on commit a171314

Please sign in to comment.