New
NAN provides a Nan::New()
helper for the creation of new JavaScript objects in a way that's compatible across the supported versions of V8.
- {gfm-extraction-974bb653635bd083638495d66146e108}
- {gfm-extraction-29f41bdf661c5a139e8b3afd0cdd2f47}
- {gfm-extraction-5c1529a59f34b9aac4182373281c12bb}
- {gfm-extraction-b6b745667f4b2695487cbba9defd8595}
- {gfm-extraction-52411ed628e3e2b8796573afab60685d}
- {gfm-extraction-a67e5507912a246bd403eb9dc37ae047}
Nan::New()
Nan::New()
should be used to instantiate new JavaScript objects.
Refer to the specific V8 type in the V8 documentation for information on the types of arguments required for instantiation.
Signatures:
Return types are mostly omitted from the signatures for simplicity. In most cases the type will be contained within a v8::Local<T>
. The following types will be contained within a Nan::MaybeLocal<T>
: v8::String
, v8::Date
, v8::RegExp
, v8::Script
, v8::UnboundScript
.
Empty objects:
Nan::New<T>();
Generic single and multiple-argument:
Nan::New<T>(A0 arg0);
Nan::New<T>(A0 arg0, A1 arg1);
Nan::New<T>(A0 arg0, A1 arg1, A2 arg2);
Nan::New<T>(A0 arg0, A1 arg1, A2 arg2, A3 arg3);
For creating v8::FunctionTemplate
and v8::Function
objects:
The definition of Nan::FunctionCallback
can be found in the Method declaration documentation.
Nan::New<T>(Nan::FunctionCallback callback,
v8::Local<v8::Value> data = v8::Local<v8::Value>());
Nan::New<T>(Nan::FunctionCallback callback,
v8::Local<v8::Value> data = v8::Local<v8::Value>(),
A2 a2 = A2());
Native number types:
v8::Local<v8::Boolean> Nan::New<T>(bool value);
v8::Local<v8::Int32> Nan::New<T>(int32_t value);
v8::Local<v8::Uint32> Nan::New<T>(uint32_t value);
v8::Local<v8::Number> Nan::New<T>(double value);
String types:
Nan::MaybeLocal<v8::String> Nan::New<T>(std::string const& value);
Nan::MaybeLocal<v8::String> Nan::New<T>(const char * value, int length);
Nan::MaybeLocal<v8::String> Nan::New<T>(const char * value);
Nan::MaybeLocal<v8::String> Nan::New<T>(const uint16_t * value);
Nan::MaybeLocal<v8::String> Nan::New<T>(const uint16_t * value, int length);
Specialized types:
v8::Local<v8::String> Nan::New<T>(v8::String::ExternalStringResource * value);
v8::Local<v8::String> Nan::New<T>(Nan::ExternalOneByteStringResource * value);
v8::Local<v8::RegExp> Nan::New<T>(v8::Local<v8::String> pattern, v8::RegExp::Flags flags);
Note that Nan::ExternalOneByteStringResource
maps to <code>v8::String::ExternalOneByteStringResource</code>, and v8::String::ExternalAsciiStringResource
in older versions of V8.
Nan::Undefined()
A helper method to reference the v8::Undefined
object in a way that is compatible across all supported versions of V8.
Signature:
v8::Local<v8::Primitive> Nan::Undefined()
Nan::Null()
A helper method to reference the v8::Null
object in a way that is compatible across all supported versions of V8.
Signature:
v8::Local<v8::Primitive> Nan::Null()
Nan::True()
A helper method to reference the v8::Boolean
object representing the true
value in a way that is compatible across all supported versions of V8.
Signature:
v8::Local<v8::Boolean> Nan::True()
Nan::False()
A helper method to reference the v8::Boolean
object representing the false
value in a way that is compatible across all supported versions of V8.
Signature:
v8::Local<v8::Boolean> Nan::False()
Nan::EmptyString()
Call <code>v8::String::Empty</code> to reference the empty string in a way that is compatible across all supported versions of V8.
Signature:
v8::Local<v8::String> Nan::EmptyString()
Nan::NewOneByteString()
An implementation of <code>v8::String::NewFromOneByte()</code> provided for consistent availability and API across supported versions of V8. Allocates a new string from Latin-1 data.
Signature:
Nan::MaybeLocal<v8::String> Nan::NewOneByteString(const uint8_t * value,
int length = -1)