node-addon-api 2.0.1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/.travis.yml +1 -4
  2. package/CHANGELOG.md +172 -10
  3. package/README.md +81 -30
  4. package/appveyor.yml +3 -14
  5. package/benchmark/README.md +47 -0
  6. package/benchmark/binding.gyp +25 -0
  7. package/benchmark/function_args.cc +217 -0
  8. package/benchmark/function_args.js +60 -0
  9. package/benchmark/index.js +34 -0
  10. package/benchmark/property_descriptor.cc +91 -0
  11. package/benchmark/property_descriptor.js +37 -0
  12. package/common.gypi +21 -0
  13. package/doc/addon.md +157 -0
  14. package/doc/array.md +81 -0
  15. package/doc/array_buffer.md +4 -0
  16. package/doc/async_worker.md +33 -4
  17. package/doc/{async_progress_worker.md → async_worker_variants.md} +115 -3
  18. package/doc/bigint.md +7 -2
  19. package/doc/boolean.md +4 -0
  20. package/doc/buffer.md +4 -0
  21. package/doc/class_property_descriptor.md +3 -3
  22. package/doc/creating_a_release.md +5 -5
  23. package/doc/dataview.md +4 -0
  24. package/doc/date.md +2 -2
  25. package/doc/env.md +69 -0
  26. package/doc/error.md +5 -0
  27. package/doc/external.md +4 -0
  28. package/doc/function.md +109 -1
  29. package/doc/hierarchy.md +91 -0
  30. package/doc/instance_wrap.md +408 -0
  31. package/doc/name.md +29 -0
  32. package/doc/object.md +44 -1
  33. package/doc/object_lifetime_management.md +1 -1
  34. package/doc/object_wrap.md +219 -215
  35. package/doc/promises.md +5 -0
  36. package/doc/property_descriptor.md +64 -9
  37. package/doc/setup.md +1 -2
  38. package/doc/string.md +5 -1
  39. package/doc/symbol.md +5 -1
  40. package/doc/typed_array.md +4 -0
  41. package/doc/typed_array_of.md +4 -0
  42. package/doc/value.md +166 -104
  43. package/except.gypi +16 -0
  44. package/index.js +7 -41
  45. package/napi-inl.h +1116 -400
  46. package/napi.h +414 -142
  47. package/node_api.gyp +9 -0
  48. package/noexcept.gypi +16 -0
  49. package/{src/nothing.c → nothing.c} +0 -0
  50. package/package.json +63 -1
  51. package/tools/README.md +4 -4
  52. package/tools/conversion.js +4 -8
  53. package/doc/basic_types.md +0 -423
  54. package/doc/working_with_javascript_values.md +0 -14
  55. package/external-napi/node_api.h +0 -7
  56. package/src/node_api.cc +0 -3655
  57. package/src/node_api.gyp +0 -21
  58. package/src/node_api.h +0 -588
  59. package/src/node_api_types.h +0 -115
  60. package/src/node_internals.cc +0 -142
  61. package/src/node_internals.h +0 -157
  62. package/src/util-inl.h +0 -38
  63. package/src/util.h +0 -7
package/doc/object.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # Object
2
2
 
3
+ Class `Napi::Object` inherits from class [`Napi::Value`][].
4
+
3
5
  The `Napi::Object` class corresponds to a JavaScript object. It is extended by the following node-addon-api classes that you may use when working with more specific types:
4
6
 
5
- - [`Napi::Value`](value.md) and extends [`Napi::Array`](array.md)
7
+ - [`Napi::Array`](array.md)
6
8
  - [`Napi::ArrayBuffer`](array_buffer.md)
7
9
  - [`Napi::Buffer<T>`](buffer.md)
8
10
  - [`Napi::Function`](function.md)
@@ -101,6 +103,22 @@ While the value must be any of the following types:
101
103
  - `bool`
102
104
  - `double`
103
105
 
106
+ ### Delete()
107
+
108
+ ```cpp
109
+ bool Napi::Object::Delete(____ key);
110
+ ```
111
+ - `[in] key`: The name of the property to delete.
112
+
113
+ Deletes the property associated with the given key. Returns `true` if the property was deleted.
114
+
115
+ The `key` can be any of the following types:
116
+ - `napi_value`
117
+ - [`Napi::Value`](value.md)
118
+ - `const char *`
119
+ - `const std::string &`
120
+ - `uint32_t`
121
+
104
122
  ### Get()
105
123
 
106
124
  ```cpp
@@ -171,6 +189,29 @@ void finalizeCallback(Napi::Env env, T* data, Hint* hint);
171
189
  ```
172
190
  where `data` and `hint` are the pointers that were passed into the call to `AddFinalizer()`.
173
191
 
192
+ ### GetPropertyNames()
193
+ ```cpp
194
+ Napi::Array Napi::Object::GetPropertyNames() const;
195
+ ```
196
+
197
+ Returns the names of the enumerable properties of the object as a [`Napi::Array`](array.md) of strings.
198
+ The properties whose key is a `Symbol` will not be included.
199
+
200
+ ### HasOwnProperty()
201
+ ```cpp
202
+ bool Napi::Object::HasOwnProperty(____ key); const
203
+ ```
204
+ - `[in] key` The name of the property to check.
205
+
206
+ Returns a `bool` that is *true* if the object has an own property named `key` and *false* otherwise.
207
+
208
+ The key can be any of the following types:
209
+ - `napi_value`
210
+ - [`Napi::Value`](value.md)
211
+ - `const char*`
212
+ - `const std::string&`
213
+ - `uint32_t`
214
+
174
215
  ### DefineProperty()
175
216
 
176
217
  ```cpp
@@ -234,3 +275,5 @@ Napi::Value Napi::Object::operator[] (uint32_t index) const;
234
275
  - `[in] index`: Element index.
235
276
 
236
277
  Returns an indexed property or array element as a [`Napi::Value`](value.md).
278
+
279
+ [`Napi::Value`]: ./value.md
@@ -69,7 +69,7 @@ for (int i = 0; i < LOOP_MAX; i++) {
69
69
  Napi::HandleScope scope(info.Env());
70
70
  std::string name = std::string("inner-scope") + std::to_string(i);
71
71
  Napi::Value newValue = Napi::String::New(info.Env(), name.c_str());
72
- // do something with neValue
72
+ // do something with newValue
73
73
  };
74
74
  ```
75
75