Skip to content

Conversation

NickNaso
Copy link
Member

@NickNaso NickNaso commented Dec 11, 2019

This PR fixes #603

  • Implementation
  • Documentation
  • Tests

@mhdawson
Copy link
Member

@NickNaso are you still working on this one?

@NickNaso
Copy link
Member Author

@mhdawson Yes I'm working on it.

@devsnek
Copy link
Member

devsnek commented Mar 19, 2020

can this also take a prototype argument?

@mhdawson mhdawson mentioned this pull request Mar 23, 2020
8 tasks
@seishun
Copy link
Contributor

seishun commented Dec 28, 2020

  • Are you still working on this?
  • Would this be a viable replacement for multiple calls to Napi::Object::Set?

@NickNaso
Copy link
Member Author

Hi @seishun ,
I'm honest I forgot of this PR. Yes this should be a replacement for multiple calls on Napi::Object::Set. Do you want to work on this ?

@seishun
Copy link
Contributor

seishun commented Dec 29, 2020

Consider this code:

auto object = Napi::Object::New(env):
object.Set("foo", foo);
object.Set("bar", bar);
return object;

If understand correctly, this PR would let one rewrite it as the following (assuming foo and bar are numeric):

return Napi::Object::New({
  Napi::PropertyDescriptor::Value("foo", Napi::Number::New(env, foo)),
  Napi::PropertyDescriptor::Value("bar", Napi::Number::New(env, bar))
});

That's hardly an improvement. Am I missing something?

@mhdawson mhdawson closed this Jan 26, 2021
@mhdawson mhdawson deleted the branch nodejs:master January 26, 2021 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add Object::New() taking a list of properties

4 participants