## Maybe Types
The `Nan::MaybeLocal` and `Nan::Maybe` types are monads that encapsulate `v8::Local` handles that _may be empty_.
* **Maybe Types**
Nan::MaybeLocal
Nan::Maybe
Nan::Nothing
Nan::Just
* **Maybe Helpers**
Nan::Call()
Nan::ToDetailString()
Nan::ToArrayIndex()
Nan::Equals()
Nan::NewInstance()
Nan::GetFunction()
Nan::Set()
Nan::ForceSet()
Nan::Get()
Nan::GetPropertyAttributes()
Nan::Has()
Nan::Delete()
Nan::GetPropertyNames()
Nan::GetOwnPropertyNames()
Nan::SetPrototype()
Nan::ObjectProtoToString()
Nan::HasOwnProperty()
Nan::HasRealNamedProperty()
Nan::HasRealIndexedProperty()
Nan::HasRealNamedCallbackProperty()
Nan::GetRealNamedPropertyInPrototypeChain()
Nan::GetRealNamedProperty()
Nan::CallAsFunction()
Nan::CallAsConstructor()
Nan::GetSourceLine()
Nan::GetLineNumber()
Nan::GetStartColumn()
Nan::GetEndColumn()
Nan::CloneElementAt()
Nan::MakeMaybe()
A `Nan::MaybeLocal
If an API method returns a `Nan::MaybeLocal`, the API method can potentially fail either because an exception is thrown, or because an exception is pending, e.g. because a previous API call threw an exception that hasnt been caught yet, or because a `v8::TerminateExecution` exception was thrown. In that case, an empty `Nan::MaybeLocal` is returned.
Definition:
`c++
template
public:
MaybeLocal();
templatethat);
bool IsEmpty() const;
template*out);
// Will crash if the MaybeLocal<> is empty.
v8::Local
templateFromMaybe(v8::Local default_value) const;
};
`
See the documentation for [`v8::MaybeLocal`](https://v8docs.nodesource.com/io.js-3.0/d8/d7d/classv8_1_1_maybe_local.html) for further details.
A simple `Nan::Maybe` type, representing an object which may or may not have a value, see https://hackage.haskell.org/package/base/docs/Data-Maybe.html.
If an API method returns a `Nan::Maybe<>`, the API method can potentially fail either because an exception is thrown, or because an exception is pending, e.g. because a previous API call threw an exception that hasnt been caught yet, or because a `v8::TerminateExecution` exception was thrown. In that case, a Nothing value is returned.
Definition:
`c++
template
public:
bool IsNothing() const;
bool IsJust() const;
// Will crash if the Maybe<> is nothing.
T FromJust();
T FromMaybe(const T& default_value);
bool operator==(const Maybe &other);
bool operator!=(const Maybe &other);
};
`
See the documentation for [`v8::Maybe`](https://v8docs.nodesource.com/io.js-3.0/d9/d4b/classv8_1_1_maybe.html) for further details.
Construct an empty `Nan::Maybe` type representing _nothing_.
`c++
template
`
Construct a `Nan::Maybe` type representing _just_ a value.
`c++
template
`
A helper method for calling [`v8::Function#Call()`](https://v8docs.nodesource.com/io.js-3.0/d5/d54/classv8_1_1_function.html#a468a89f737af0612db10132799c827c0) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::MaybeLocal
`
A helper method for calling [`v8::Value#ToDetailString()`](https://v8docs.nodesource.com/io.js-3.0/dc/d0a/classv8_1_1_value.html#a2f9770296dc2c8d274bc8cc0dca243e5) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::MaybeLocal
`
A helper method for calling [`v8::Value#ToArrayIndex()`](https://v8docs.nodesource.com/io.js-3.0/dc/d0a/classv8_1_1_value.html#acc5bbef3c805ec458470c0fcd6f13493) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::MaybeLocal
`
A helper method for calling [`v8::Value#Equals()`](https://v8docs.nodesource.com/io.js-3.0/dc/d0a/classv8_1_1_value.html#a0d9616ab2de899d4e3047c30a10c9285) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::Maybe
`
A helper method for calling [`v8::Function#NewInstance()`](https://v8docs.nodesource.com/io.js-3.0/d5/d54/classv8_1_1_function.html#a691b13f7a553069732cbacf5ac8c62ec) and [`v8::ObjectTemplate#NewInstance()`](https://v8docs.nodesource.com/io.js-3.0/db/d5f/classv8_1_1_object_template.html#ad605a7543cfbc5dab54cdb0883d14ae4) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::MaybeLocal
Nan::MaybeLocal
Nan::MaybeLocal
`
A helper method for calling [`v8::FunctionTemplate#GetFunction()`](https://v8docs.nodesource.com/io.js-3.0/d8/d83/classv8_1_1_function_template.html#a56d904662a86eca78da37d9bb0ed3705) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::MaybeLocal
`
A helper method for calling [`v8::Object#Set()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#a67604ea3734f170c66026064ea808f20) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::Maybe
v8::Local
v8::Local
Nan::Maybe
uint32_t index,
v8::Local
`
A helper method for calling [`v8::Object#ForceSet()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#a796b7b682896fb64bf1872747734e836) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::Maybe
v8::Local
v8::Local
v8::PropertyAttribute attribs = v8::None);
`
A helper method for calling [`v8::Object#Get()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#a2565f03e736694f6b1e1cf22a0b4eac2) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::MaybeLocal
v8::Local
Nan::MaybeLocal
`
### Nan::GetPropertyAttributes()
A helper method for calling [`v8::Object#GetPropertyAttributes()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#a9b898894da3d1db2714fd9325a54fe57) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::Maybe
v8::Local
v8::Local
`
A helper method for calling [`v8::Object#Has()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#ab3c3d89ea7c2f9afd08965bd7299a41d) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::Maybe
Nan::Maybe
`
A helper method for calling [`v8::Object#Delete()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#a2fa0f5a592582434ed1ceceff7d891ef) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::Maybe
v8::Local
Nan::Maybe
`
A helper method for calling [`v8::Object#GetPropertyNames()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#aced885270cfd2c956367b5eedc7fbfe8) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::MaybeLocal
`
### Nan::GetOwnPropertyNames()
A helper method for calling [`v8::Object#GetOwnPropertyNames()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#a79a6e4d66049b9aa648ed4dfdb23e6eb) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::MaybeLocal
`
A helper method for calling [`v8::Object#SetPrototype()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#a442706b22fceda6e6d1f632122a9a9f4) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::Maybe
v8::Local
`
### Nan::ObjectProtoToString()
A helper method for calling [`v8::Object#ObjectProtoToString()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#ab7a92b4dcf822bef72f6c0ac6fea1f0b) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::MaybeLocal
`
A helper method for calling [`v8::Object#HasOwnProperty()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#ab7b7245442ca6de1e1c145ea3fd653ff) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::Maybe
v8::Local
`
### Nan::HasRealNamedProperty()
A helper method for calling [`v8::Object#HasRealNamedProperty()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#ad8b80a59c9eb3c1e6c3cd6c84571f767) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::Maybe
v8::Local
`
### Nan::HasRealIndexedProperty()
A helper method for calling [`v8::Object#HasRealIndexedProperty()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#af94fc1135a5e74a2193fb72c3a1b9855) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::Maybe
uint32_t index);
`
### Nan::HasRealNamedCallbackProperty()
A helper method for calling [`v8::Object#HasRealNamedCallbackProperty()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#af743b7ea132b89f84d34d164d0668811) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::Maybe
v8::Local
v8::Local
`
### Nan::GetRealNamedPropertyInPrototypeChain()
A helper method for calling [`v8::Object#GetRealNamedPropertyInPrototypeChain()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#a8700b1862e6b4783716964ba4d5e6172) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::MaybeLocal
v8::Local
v8::Local
`
### Nan::GetRealNamedProperty()
A helper method for calling [`v8::Object#GetRealNamedProperty()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#a84471a824576a5994fdd0ffcbf99ccc0) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::MaybeLocal
v8::Local
`
A helper method for calling [`v8::Object#CallAsFunction()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#a9ef18be634e79b4f0cdffa1667a29f58) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::MaybeLocal
v8::Local
int argc,
v8::Local
`
A helper method for calling [`v8::Object#CallAsConstructor()`](https://v8docs.nodesource.com/io.js-3.0/db/d85/classv8_1_1_object.html#a50d571de50d0b0dfb28795619d07a01b) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::MaybeLocal
int argc,
v8::Local
`
A helper method for calling [`v8::Message#GetSourceLine()`](https://v8docs.nodesource.com/io.js-3.0/d9/d28/classv8_1_1_message.html#a849f7a6c41549d83d8159825efccd23a) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::MaybeLocal
`
A helper method for calling [`v8::Message#GetLineNumber()`](https://v8docs.nodesource.com/io.js-3.0/d9/d28/classv8_1_1_message.html#adbe46c10a88a6565f2732a2d2adf99b9) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::Maybe
`
A helper method for calling [`v8::Message#GetStartColumn()`](https://v8docs.nodesource.com/io.js-3.0/d9/d28/classv8_1_1_message.html#a60ede616ba3822d712e44c7a74487ba6) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::Maybe
`
A helper method for calling [`v8::Message#GetEndColumn()`](https://v8docs.nodesource.com/io.js-3.0/d9/d28/classv8_1_1_message.html#aaa004cf19e529da980bc19fcb76d93be) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::Maybe
`
A helper method for calling [`v8::Array#CloneElementAt()`](https://v8docs.nodesource.com/io.js-3.0/d3/d32/classv8_1_1_array.html#a1d3a878d4c1c7cae974dd50a1639245e) in a way compatible across supported versions of V8.
Signature:
`c++
Nan::MaybeLocal
`
Wraps a `v8::Local<>` in a `Nan::MaybeLocal<>`. When called with a `Nan::MaybeLocal<>` it just returns its argument. This is useful in generic template code that builds on NAN.
Synopsis:
`c++
MaybeLocal
MaybeLocal
`
Signature:
`c++
template
Nan::MaybeLocal
`
Reviews
There are no reviews yet.