# InstanceWrap This class serves as the base class for [`Napi::ObjectWrap`][] and [`Napi::Addon`][]. In the case of [`Napi::Addon`][] it provides the methods for exposing functions to JavaScript on instances of an add-on. As a base class for [`Napi::ObjectWrap`][] it provides the methods for exposing instance methods of JavaScript objects instantiated from the JavaScript class corresponding to the subclass of [`Napi::ObjectWrap`][]. ## Methods ### InstanceMethod Creates a property descriptor that represents a method exposed on JavaScript instances of this class. ```cpp template static Napi::ClassPropertyDescriptor Napi::InstanceWrap::InstanceMethod(const char* utf8name, InstanceVoidMethodCallback method, napi_property_attributes attributes = napi_default, void* data = nullptr); ``` - `[in] utf8name`: Null-terminated string that represents the name of the method provided by instances of the class. - `[in] method`: The native function that represents a method provided by the add-on. - `[in] attributes`: The attributes associated with the property. One or more of `napi_property_attributes`. - `[in] data`: User-provided data passed into the method when it is invoked. Returns a `Napi::ClassPropertyDescriptor` object that represents a method provided by instances of the class. The method must be of the form ```cpp void MethodName(const Napi::CallbackInfo& info); ``` ### InstanceMethod Creates a property descriptor that represents a method exposed on JavaScript instances of this class. ```cpp template static Napi::ClassPropertyDescriptor Napi::InstanceWrap::InstanceMethod(const char* utf8name, InstanceMethodCallback method, napi_property_attributes attributes = napi_default, void* data = nullptr); ``` - `[in] utf8name`: Null-terminated string that represents the name of the method provided by instances of the class. - `[in] method`: The native function that represents a method provided by the add-on. - `[in] attributes`: The attributes associated with the property. One or more of `napi_property_attributes`. - `[in] data`: User-provided data passed into the method when it is invoked. Returns a `Napi::ClassPropertyDescriptor` object that represents a method provided by instances of the class. The method must be of the form ```cpp Napi::Value MethodName(const Napi::CallbackInfo& info); ``` ### InstanceMethod Creates a property descriptor that represents a method exposed on JavaScript instances of this class. ```cpp template static Napi::ClassPropertyDescriptor Napi::InstanceWrap::InstanceMethod(Napi::Symbol name, InstanceVoidMethodCallback method, napi_property_attributes attributes = napi_default, void* data = nullptr); ``` - `[in] name`: JavaScript symbol that represents the name of the method provided by instances of the class. - `[in] method`: The native function that represents a method provided by the add-on. - `[in] attributes`: The attributes associated with the property. One or more of `napi_property_attributes`. - `[in] data`: User-provided data passed into the method when it is invoked. Returns a `Napi::ClassPropertyDescriptor` object that represents a method provided by instances of the class. The method must be of the form ```cpp void MethodName(const Napi::CallbackInfo& info); ``` ### InstanceMethod Creates a property descriptor that represents a method exposed on JavaScript instances of this class. ```cpp template static Napi::ClassPropertyDescriptor Napi::InstanceWrap::InstanceMethod(Napi::Symbol name, InstanceMethodCallback method, napi_property_attributes attributes = napi_default, void* data = nullptr); ``` - `[in] name`: JavaScript symbol that represents the name of the method provided by instances of the class. - `[in] method`: The native function that represents a method provided by the add-on. - `[in] attributes`: The attributes associated with the property. One or more of `napi_property_attributes`. - `[in] data`: User-provided data passed into the method when it is invoked. Returns a `Napi::ClassPropertyDescriptor` object that represents a method provided by instances of the class. The method must be of the form ```cpp Napi::Value MethodName(const Napi::CallbackInfo& info); ``` ### InstanceMethod Creates a property descriptor that represents a method exposed on JavaScript instances of this class. ```cpp