Skip to content

Commit f894a43

Browse files
author
Sampson Gao
committed
Add NewTarget method to CallbackInfo and change variable name to camel case
1 parent f98a747 commit f894a43

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

napi-inl.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,9 +2015,15 @@ inline CallbackInfo::~CallbackInfo() {
20152015
}
20162016
}
20172017

2018+
inline Value CallbackInfo::NewTarget() const {
2019+
napi_value newTarget;
2020+
napi_status status = napi_get_new_target(_env, _info, &newTarget);
2021+
return Value(_env, newTarget);
2022+
}
2023+
20182024
inline bool CallbackInfo::IsConstructCall() const {
2019-
napi_value new_target;
2020-
napi_status status = napi_get_new_target(_env, _info, &new_target);
2025+
napi_value newTarget;
2026+
napi_status status = napi_get_new_target(_env, _info, &newTarget);
20212027
bool isConstructCall = (new_target != nullptr);
20222028
NAPI_THROW_IF_FAILED(_env, status, false);
20232029
return isConstructCall;

napi.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,7 @@ namespace Napi {
11241124
~CallbackInfo();
11251125

11261126
Napi::Env Env() const;
1127+
Value NewTarget() const;
11271128
bool IsConstructCall() const;
11281129
size_t Length() const;
11291130
const Value operator [](size_t index) const;

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)