Nan::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::JSON.Parse
6 | - Nan::JSON.Stringify
7 |
8 | Refer to the V8 JSON object in the [V8 documentation](https://v8docs.nodesource.com/node-7.4/da/d6f/classv8_1_1_j_s_o_n.html) for more information about these methods and their arguments.
9 |
10 |
11 |
12 | ### Nan::JSON.Parse
13 |
14 | A simple wrapper around [`v8::JSON::Parse`](https://v8docs.nodesource.com/node-7.4/da/d6f/classv8_1_1_j_s_o_n.html#a936310d2540fb630ed37d3ee3ffe4504).
15 |
16 | Definition:
17 |
18 | ```c++
19 | Nan::MaybeLocalNan::HandleScope
10 | - Nan::EscapableHandleScope
11 |
12 | Also see the V8 Embedders Guide section on [Handles and Garbage Collection](https://github.com/v8/v8/wiki/Embedder%27s%20Guide#handles-and-garbage-collection).
13 |
14 |
15 | ### Nan::HandleScope
16 |
17 | A simple wrapper around [`v8::HandleScope`](https://v8docs.nodesource.com/io.js-3.3/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.3/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.3/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
41 | , WeakCallbackType type);
42 |
43 | private:
44 | inline T *operator*() const { return *PersistentBase ::Callback callback
90 | , WeakCallbackType type) {
91 | reinterpret_cast &that) {
48 | TYPE_CHECK(T, S);
49 |
50 | this->Reset();
51 |
52 | if (!that.IsEmpty()) {
53 | this->Reset(that);
54 | M::Copy(that, this);
55 | }
56 | }
57 | };
58 |
59 | #if defined(V8_MAJOR_VERSION) && (V8_MAJOR_VERSION > 4 || \
60 | (V8_MAJOR_VERSION == 4 && defined(V8_MINOR_VERSION) && V8_MINOR_VERSION >= 3))
61 | template that) :
67 | v8::Global &that) : // NOLINT(runtime/explicit)
72 | v8::Global(v8::Isolate::GetCurrent(), that) {}
73 |
74 | inline void Reset() { v8::PersistentBase &other) {
78 | v8::PersistentBase &other) {
83 | v8::PersistentBase that) :
102 | v8::UniquePersistent &that) : // NOLINT(runtime/explicit)
107 | v8::UniquePersistent(v8::Isolate::GetCurrent(), that) {}
108 |
109 | inline void Reset() { v8::PersistentBase &other) {
113 | v8::PersistentBase