Nan::AsyncWorker
6 | - Nan::AsyncProgressWorker
7 | - Nan::AsyncQueueWorker
8 |
9 |
10 | ### Nan::AsyncWorker
11 |
12 | `Nan::AsyncWorker` is an _abstract_ class that you can subclass to have much of the annoying asynchronous queuing and handling taken care of for you. It can even store arbitrary V8 objects for you and have them persist while the asynchronous work is in progress.
13 |
14 | Definition:
15 |
16 | ```c++
17 | class AsyncWorker {
18 | public:
19 | explicit AsyncWorker(Callback *callback_);
20 |
21 | virtual ~AsyncWorker();
22 |
23 | virtual void WorkComplete();
24 |
25 | void SaveToPersistent(const char *key, const v8::LocalNan::NewBuffer()
6 | - Nan::CopyBuffer()
7 | - Nan::FreeCallback()
8 |
9 |
10 | ### Nan::NewBuffer()
11 |
12 | Allocate a new `node::Buffer` object with the specified size and optional data. Calls `node::Buffer::New()`.
13 |
14 | Note that when creating a `Buffer` using `Nan::NewBuffer()` and an existing `char*`, it is assumed that the ownership of the pointer is being transferred to the new `Buffer` for management.
15 | When a `node::Buffer` instance is garbage collected and a `FreeCallback` has not been specified, `data` will be disposed of via a call to `free()`.
16 | You _must not_ free the memory space manually once you have created a `Buffer` in this way.
17 |
18 | Signature:
19 |
20 | ```c++
21 | Nan::MaybeLocalNan::Callback
6 |
7 |
8 | ### Nan::Callback
9 |
10 | ```c++
11 | class Callback {
12 | public:
13 | Callback();
14 |
15 | explicit Callback(const v8::LocalNan::To()
6 |
7 |
8 | ### Nan::To()
9 |
10 | Converts a `v8::LocalNan::New()
6 | - Nan::Undefined()
7 | - Nan::Null()
8 | - Nan::True()
9 | - Nan::False()
10 | - Nan::EmptyString()
11 |
12 |
13 |
14 | ### Nan::New()
15 |
16 | `Nan::New()` should be used to instantiate new JavaScript objects.
17 |
18 | Refer to the specific V8 type in the [V8 documentation](https://v8docs.nodesource.com/io.js-3.0/d1/d83/classv8_1_1_data.html) for information on the types of arguments required for instantiation.
19 |
20 | Signatures:
21 |
22 | Return types are mostly omitted from the signatures for simplicity. In most cases the type will be contained within a `v8::LocalNan::MakeCallback()
4 | - NAN_MODULE_INIT()
5 | - Nan::Export()
6 |
7 |
8 |
9 | ### Nan::MakeCallback()
10 |
11 | Wrappers around `node::MakeCallback()` providing a consistent API across all supported versions of Node.
12 |
13 | Use `MakeCallback()` rather than using `v8::Function#Call()` directly in order to properly process internal Node functionality including domains, async hooks, the microtask queue, and other debugging functionality.
14 |
15 | Signatures:
16 |
17 | ```c++
18 | v8::LocalNan::HandleScope
10 | - Nan::EscapableHandleScope
11 |
12 | Also see the V8 Embedders Guide section on [Handles and Garbage Collection](https://developers.google.com/v8/embed#handles).
13 |
14 |
15 | ### Nan::HandleScope
16 |
17 | A simple wrapper around [`v8::HandleScope`](https://v8docs.nodesource.com/io.js-3.0/d3/d95/classv8_1_1_handle_scope.html).
18 |
19 | Definition:
20 |
21 | ```c++
22 | class Nan::HandleScope {
23 | public:
24 | Nan::HandleScope();
25 | static int NumberOfHandles();
26 | };
27 | ```
28 |
29 | Allocate a new `Nan::HandleScope` whenever you are creating new V8 JavaScript objects. Note that an implicit `HandleScope` is created for you on JavaScript-accessible methods so you do not need to insert one yourself.
30 |
31 | Example:
32 |
33 | ```c++
34 | // new object is created, it needs a new scope:
35 | void Pointless() {
36 | Nan::HandleScope scope;
37 | v8::LocalNan::CompileScript()
6 | - Nan::RunScript()
7 |
8 |
9 |
10 | ### Nan::CompileScript()
11 |
12 | A wrapper around [`v8::Script::Compile()`](https://v8docs.nodesource.com/io.js-3.0/da/da5/classv8_1_1_script_compiler.html#a93f5072a0db55d881b969e9fc98e564b).
13 |
14 | Note that `Nan::BoundScript` is an alias for `v8::Script`.
15 |
16 | Signature:
17 |
18 | ```c++
19 | Nan::MaybeLocalNan::Encoding
6 | - Nan::Encode()
7 | - Nan::DecodeBytes()
8 | - Nan::DecodeWrite()
9 |
10 |
11 |
12 | ### Nan::Encoding
13 |
14 | An enum representing the supported encoding types. A copy of `node::encoding` that is consistent across versions of Node.
15 |
16 | Definition:
17 |
18 | ```c++
19 | enum Nan::Encoding { ASCII, UTF8, BASE64, UCS2, BINARY, HEX, BUFFER }
20 | ```
21 |
22 |
23 |
24 | ### Nan::Encode()
25 |
26 | A wrapper around `node::Encode()` that provides a consistent implementation across supported versions of Node.
27 |
28 | Signature:
29 |
30 | ```c++
31 | v8::LocalNan::Utf8String
4 | - Nan::GetCurrentContext()
5 | - Nan::SetIsolateData()
6 | - Nan::GetIsolateData()
7 | - Nan::TypedArrayContents
8 |
9 |
10 |
11 | ### Nan::Utf8String
12 |
13 | Converts an object to a UTF-8-encoded character array. If conversion to a string fails (e.g. due to an exception in the toString() method of the object) then the length() method returns 0 and the * operator returns NULL. The underlying memory used for this object is managed by the object.
14 |
15 | An implementation of [`v8::String::Utf8Value`](https://v8docs.nodesource.com/io.js-3.0/d4/d1b/classv8_1_1_string_1_1_utf8_value.html) that is consistent across all supported versions of V8.
16 |
17 | Definition:
18 |
19 | ```c++
20 | class Nan::Utf8String {
21 | public:
22 | Nan::Utf8String(v8::Local::Callback callback
40 | , WeakCallbackType type);
41 |
42 | private:
43 | inline T *operator*() const { return *PersistentBase