-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
n-api: initialize a module via a special symbol
Much like regular modules, N-API modules can also benefit from having a special symbol which they can expose. Fixes: #19845 PR-URL: #20161 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
- Loading branch information
Gabriel Schulhof
committed
Apr 23, 2018
1 parent
3bcd857
commit 0f8caf2
Showing
7 changed files
with
80 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
'use strict'; | ||
const common = require('../../common'); | ||
const assert = require('assert'); | ||
const addon = require(`./build/${common.buildType}/binding`); | ||
const bindingPath = require.resolve(`./build/${common.buildType}/binding`); | ||
const binding = require(bindingPath); | ||
assert.strictEqual(binding.hello(), 'world'); | ||
console.log('binding.hello() =', binding.hello()); | ||
|
||
assert.strictEqual(addon.hello(), 'world'); | ||
// Test multiple loading of the same module. | ||
delete require.cache[bindingPath]; | ||
const rebinding = require(bindingPath); | ||
assert.strictEqual(rebinding.hello(), 'world'); | ||
assert.notStrictEqual(binding.hello, rebinding.hello); |