-
Notifications
You must be signed in to change notification settings - Fork 36
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
Port to N-API #54
Port to N-API #54
Conversation
The feature is still experimental so no, not yet. |
binding.gyp
Outdated
'include_dirs': ["<!(node -e \"require('nan')\")"], | ||
'cflags!': [ '-fno-exceptions' ], | ||
'cflags_cc!': [ '-fno-exceptions' ], | ||
'xcode_settings': { 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be merged with the other xcode_settings
below.
fallback.js
Outdated
@@ -16,6 +16,11 @@ | |||
* @public | |||
*/ | |||
const isValidUTF8 = (buf) => { | |||
|
|||
if (!buf) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed, Buffer.isBuffer()
covers this.
Updated description to be more clear about creating a branch instead of merging against master. |
Yes, the branch is called |
ddda467
to
5851321
Compare
src/validation.cc
Outdated
} | ||
|
||
void init(v8::Local<v8::Object> exports, v8::Local<v8::Object> module) { | ||
Nan::SetMethod(module, "exports", isValidUTF8); | ||
Napi::Object Init(Napi::Env env, Napi::Object exports) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it static
and call it init
for consistency with bufferutil
?
- removed nan dependency - add node-addon-api dependency - port validation.cc to N-API
Git history seems to be working now. But dates are not linear. I don't know if this worries you. Applied latest review change. |
Thank you. |
add test case for no argument givenSince node 8 there is a new experimental feature called N-API which is aimed at reducing maintenance cost for node native addons. Checkout this blog/talk for more details on its benefits.
Edit:
utf-8-validate is one of the top 35 native modules by dependency count. I used this native module first as playground to get my hands on N-API. The port to N-API is now working pretty good so I like to share this code. This should not be merged into master. N-API is still a experimental feature. It would be useful to have a napi branch. The work group is asking for feedback from productive running systems. It would be nice if this branch could be published to npm registry. Here is a guide on how to do that. But its up to you if you want to support this feature in experimental state.