Modernize package to Node-API, ES, add TypeScript bindings#19
Open
mjradwin wants to merge 6 commits into
Open
Conversation
- Replace nan dependency with node-addon-api ^8.7.0 - Update binding.gyp to use node-addon-api includes and NAPI_CPP_EXCEPTIONS - Rewrite src/node_murmurhash3.cc using napi.h: - Napi::AsyncWorker replaces Nan::AsyncWorker - Napi::Value functions replace NAN_METHOD macros - Napi::Object Init + NODE_API_MODULE replaces NAN_MODULE_INIT + NODE_MODULE - Preserve all argument validation and error messages - All 96 tests pass Agent-Logs-Url: https://github.com/mjradwin/node-murmurhash3/sessions/5d544747-c0a4-4974-9ba5-8d54470c91a4 Co-authored-by: mjradwin <3769045+mjradwin@users.noreply.github.com>
Agent-Logs-Url: https://github.com/mjradwin/node-murmurhash3/sessions/5d544747-c0a4-4974-9ba5-8d54470c91a4 Co-authored-by: mjradwin <3769045+mjradwin@users.noreply.github.com>
- Convert lib/murmurhash3.js from CommonJS to ES module (import/export) - Add "type": "module" to package.json - Replace "main" with "module" and "exports" fields - Add TypeScript declaration file lib/murmurhash3.d.ts - Add "types" field to package.json - Update test/test.js to use ES module imports - Upgrade mocha to v10 for ESM support - Bump version to 0.6.0 - Update engines to node >= 16.0.0 Agent-Logs-Url: https://github.com/mjradwin/node-murmurhash3/sessions/54d77b95-208e-4ab5-8300-44507cd831e1 Co-authored-by: mjradwin <3769045+mjradwin@users.noreply.github.com>
Migrate from NAN to Node-API, convert to ES modules, add TypeScript typings
Extend the TypeScript declarations to cover the async callback-based functions (murmur32, murmur32Hex, murmur128, murmur128Hex) and the exported `version` constant. Update the README to use ES module imports and arrow-function callbacks, and document a util.promisify pattern for async/await usage.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replaces the deprecated NAN (Native Abstractions for Node.js) with the stable ABI Node-API via
node-addon-api, converts the package to ES modules, adds TypeScript declarations, and bumps to v0.6.0.Native addon: NAN → Node-API
src/node_murmurhash3.ccagainstnapi.hNan::AsyncWorker→Napi::AsyncWorker,NAN_METHOD→Napi::Valuefunctions,NODE_MODULE→NODE_API_MODULE#ifconditionals — Node-API abstracts theseValidateArg()helperES module packaging
lib/murmurhash3.js:exports.*→ namedexport function, native addon loaded viacreateRequire(import.meta.url)package.json: added"type": "module", replaced"main"with"module"+"exports", engines bumped to>=16.0.0test/test.js:require()→import^5.2.0→^10.8.2(ESM support)TypeScript typings
lib/murmurhash3.d.tswith sync API declarations, referenced via"types"inpackage.jsonAll 96 existing tests pass unchanged.