| Parent Class | Subclasses |
|---|---|---|
| | [Napi::Boolean
][], [Napi::Number
][], |
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
> const x = new Error(); | |
undefined | |
> const vm = require('vm'); | |
undefined | |
> vm.runInNewContext; | |
[Function: runInNewContext] | |
> vm.runInNewContext('x instanceof Error'); | |
Thrown: | |
evalmachine.<anonymous>:1 | |
x instanceof Error |
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
const addon = require('bindings')('addon'); | |
addon.receiveModule('fs', require('fs')); | |
addon.receiveModule('crypto', require('crypto')); | |
console.log(addon.sendModule('fs') === require('fs')); | |
console.log(addon.sendModule('crypto') === require('crypto')); |
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
host mac-node-ci | |
Hostname 207.254.58.162 | |
Port 10005 | |
User administrator | |
Cipher aes128-ctr |
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
#include <stdio.h> | |
template <int x_init, int y_init> | |
class HasStructures { | |
public: | |
struct InnerStruct { | |
InnerStruct(): x(x_init), y(y_init) {} | |
int x; | |
int y; | |
}; |
JavaScript modules | Native add-ons then | Native add-ons now | ||
---|---|---|---|---|
1. | ... need to be compiled. | No | Not if there are pre-builds | Not if there are pre-builds |
2. | ... will work on all platforms and architectures. | Yes | Yes if there are pre-builds | Yes if there are pre-builds |
3. | ... are designed to work with all current and subsequent Node.js versions once written. | Yes | No | Yes if using N-API |
4. | ... can be loaded multiple times. | Yes | No | Yes if written as a context-aware add-on |
5. | ... are thread-safe if not explicitly making use of threading infrastructure. | Yes | No | Yes if written as a context-aware add-on |
6. | ... can be unloaded. | Yes | No | Yes if written as a context-aware add-on and using [cleanup hooks](https://nodejs. |
JavaScript modules | Native add-ons | ||
---|---|---|---|
1. | ... need to be compiled. | No | Not if there are pre-builds |
2. | ... will work on all platforms and architectures. | Yes | Yes if there are pre-builds |
3. | ... are designed to work with all current and subsequent Node.js versions once written. | Yes | No |
4. | ... can be loaded multiple times. | Yes | No |
5. | ... are thread-safe if not explicitly making use of threading infrastructure. | Yes | No |
6. | ... can be unloaded. | Yes | No |
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
#include <assert.h> | |
#include <node.h> | |
#include "common.h" | |
namespace { | |
void Init(v8::Local<v8::Object> exports, | |
v8::Local<v8::Object> module, | |
v8::Local<v8::Context> context) { | |
v8::Local<v8::Name> propName = |
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
#include <napi.h> | |
#include <stdio.h> | |
namespace { | |
// Per-instance addon data. An instance of this class is passed to every binding | |
// and makes it possible to avoid setting global static variables. | |
class AddonData { | |
public: | |
AddonData(std::string config_file): config_file(config_file) {} |