Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Added Object::New() taking a list of properties.
  • Loading branch information
NickNaso committed Dec 11, 2019
commit 1fd2e2b22f47b6a9f691f356e0dc40cb65e68419
12 changes: 12 additions & 0 deletions napi-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -971,6 +971,18 @@ inline Object Object::New(napi_env env) {
return Object(env, value);
}

inline Object Object::New(napi_env env, const std::initializer_list<PropertyDescriptor> &properties) {
Object obj = Object::New(env);
obj.DefineProperties(properties);
return obj;
}

inline Object Object::New(napi_env env, const std::vector<PropertyDescriptor> &properties) {
Object obj = Object::New(env);
obj.DefineProperties(properties);
return obj;
}

inline Object::Object() : Value() {
}

Expand Down
10 changes: 10 additions & 0 deletions napi.h
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,16 @@ namespace Napi {
napi_env env ///< N-API environment
);

static Object New(
napi_env env, ///< N-API environment
const std::initializer_list<PropertyDescriptor> &properties ///< initial prperties
);

static Object New(
napi_env env, ///< N-API environment
const std::vector<PropertyDescriptor> &properties ///< initial prperties
);

Object(); ///< Creates a new _empty_ Object instance.
Object(napi_env env, napi_value value); ///< Wraps a N-API value primitive.

Expand Down