Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib: refactor NativeModule #30856

Closed
wants to merge 1 commit into from
Closed

Conversation

joyeecheung
Copy link
Member

@joyeecheung joyeecheung commented Dec 8, 2019

Refactor the internal NativeModule class to a JS class and add
more documentation about its properties.

Tip: https://github.com/nodejs/node/pull/30856/files?w=1 is easier to review

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Refactor the internal NativeModule class to a JS class and add
more documentation about its properties.
@nodejs-github-bot
Copy link
Collaborator

this.canBeRequiredByUsers = !id.startsWith('internal/');

// The CJS exports object of the module.
this.exports = {};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't a public (or maybe private) field declaration be preferable?

class NativeModule {
  exports = {};
  #loaded = false;
  #loading = false;
  module = undefined;
  exportKeys = undefined;
}

I personally find it more readable than a declaration in the constructor, but that might just be me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't mind if private fields are used but i think we should keep field initialization in one spot (in this case, the constructor, since it assigns from arguments).

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@Trott Trott added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Dec 13, 2019
@Trott
Copy link
Member

Trott commented Dec 14, 2019

Landed in e4e5a83

@Trott Trott closed this Dec 14, 2019
Trott pushed a commit that referenced this pull request Dec 14, 2019
Refactor the internal NativeModule class to a JS class and add
more documentation about its properties.

PR-URL: #30856
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
MylesBorins pushed a commit that referenced this pull request Dec 17, 2019
Refactor the internal NativeModule class to a JS class and add
more documentation about its properties.

PR-URL: #30856
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Dec 17, 2019
targos pushed a commit that referenced this pull request Jan 14, 2020
Refactor the internal NativeModule class to a JS class and add
more documentation about its properties.

PR-URL: #30856
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
BethGriggs pushed a commit that referenced this pull request Feb 6, 2020
Refactor the internal NativeModule class to a JS class and add
more documentation about its properties.

PR-URL: #30856
Reviewed-By: Denys Otrishko <[email protected]>
Reviewed-By: Gus Caplan <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
@MylesBorins MylesBorins mentioned this pull request Feb 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants