node-addon-api 3.0.1 → 3.2.1

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 (74) hide show
  1. package/CHANGELOG.md +217 -0
  2. package/README.md +104 -60
  3. package/common.gypi +1 -1
  4. package/index.js +4 -3
  5. package/napi-inl.deprecated.h +8 -8
  6. package/napi-inl.h +1206 -540
  7. package/napi.h +821 -522
  8. package/package-support.json +21 -0
  9. package/package.json +80 -4
  10. package/tools/README.md +8 -2
  11. package/tools/clang-format.js +67 -0
  12. package/tools/conversion.js +4 -4
  13. package/.editorconfig +0 -8
  14. package/.travis.yml +0 -59
  15. package/CODE_OF_CONDUCT.md +0 -4
  16. package/CONTRIBUTING.md +0 -66
  17. package/appveyor.yml +0 -48
  18. package/benchmark/README.md +0 -47
  19. package/benchmark/binding.gyp +0 -25
  20. package/benchmark/function_args.cc +0 -153
  21. package/benchmark/function_args.js +0 -52
  22. package/benchmark/index.js +0 -34
  23. package/benchmark/property_descriptor.cc +0 -60
  24. package/benchmark/property_descriptor.js +0 -29
  25. package/doc/Doxyfile +0 -2450
  26. package/doc/array_buffer.md +0 -129
  27. package/doc/async_context.md +0 -86
  28. package/doc/async_operations.md +0 -31
  29. package/doc/async_worker.md +0 -427
  30. package/doc/async_worker_variants.md +0 -456
  31. package/doc/basic_types.md +0 -423
  32. package/doc/bigint.md +0 -93
  33. package/doc/boolean.md +0 -64
  34. package/doc/buffer.md +0 -140
  35. package/doc/callback_scope.md +0 -54
  36. package/doc/callbackinfo.md +0 -97
  37. package/doc/checker-tool.md +0 -32
  38. package/doc/class_property_descriptor.md +0 -117
  39. package/doc/cmake-js.md +0 -68
  40. package/doc/conversion-tool.md +0 -28
  41. package/doc/creating_a_release.md +0 -62
  42. package/doc/dataview.md +0 -244
  43. package/doc/date.md +0 -68
  44. package/doc/env.md +0 -132
  45. package/doc/error.md +0 -115
  46. package/doc/error_handling.md +0 -186
  47. package/doc/escapable_handle_scope.md +0 -82
  48. package/doc/external.md +0 -59
  49. package/doc/function.md +0 -401
  50. package/doc/function_reference.md +0 -238
  51. package/doc/generator.md +0 -13
  52. package/doc/handle_scope.md +0 -65
  53. package/doc/memory_management.md +0 -27
  54. package/doc/node-gyp.md +0 -82
  55. package/doc/number.md +0 -163
  56. package/doc/object.md +0 -275
  57. package/doc/object_lifetime_management.md +0 -83
  58. package/doc/object_reference.md +0 -117
  59. package/doc/object_wrap.md +0 -851
  60. package/doc/prebuild_tools.md +0 -16
  61. package/doc/promises.md +0 -74
  62. package/doc/property_descriptor.md +0 -286
  63. package/doc/range_error.md +0 -59
  64. package/doc/reference.md +0 -111
  65. package/doc/setup.md +0 -81
  66. package/doc/string.md +0 -89
  67. package/doc/symbol.md +0 -44
  68. package/doc/threadsafe_function.md +0 -320
  69. package/doc/type_error.md +0 -59
  70. package/doc/typed_array.md +0 -74
  71. package/doc/typed_array_of.md +0 -133
  72. package/doc/value.md +0 -278
  73. package/doc/version_management.md +0 -43
  74. package/doc/working_with_javascript_values.md +0 -14
@@ -1,117 +0,0 @@
1
- # Object Reference
2
-
3
- `Napi::ObjectReference` is a subclass of [`Napi::Reference`](reference.md), and is equivalent to an instance of `Napi::Reference<Object>`. This means that a `Napi::ObjectReference` holds a [`Napi::Object`](object.md), and a count of the number of references to that Object. When the count is greater than 0, an ObjectReference is not eligible for garbage collection. This ensures that the Object being held as a value of the ObjectReference will remain accessible, even if the original Object no longer is. However, ObjectReference is unique from a Reference since properties can be set and get to the Object itself that can be accessed through the ObjectReference.
4
-
5
- For more general information on references, please consult [`Napi::Reference`](reference.md).
6
-
7
- ## Example
8
- ```cpp
9
- #include <napi.h>
10
-
11
- using namescape Napi;
12
-
13
- void Init(Env env) {
14
-
15
- // Create an empty ObjectReference that has an initial reference count of 2.
16
- ObjectReference obj_ref = Reference<Object>::New(Object::New(env), 2);
17
-
18
- // Set a couple of different properties on the reference.
19
- obj_ref.Set("hello", String::New(env, "world"));
20
- obj_ref.Set(42, "The Answer to Life, the Universe, and Everything");
21
-
22
- // Get the properties using the keys.
23
- Value val1 = obj_ref.Get("hello");
24
- Value val2 = obj_ref.Get(42);
25
- }
26
- ```
27
-
28
- ## Methods
29
-
30
- ### Initialization
31
-
32
- ```cpp
33
- static Napi::ObjectReference Napi::ObjectReference::New(const Napi::Object& value, uint32_t initialRefcount = 0);
34
- ```
35
-
36
- * `[in] value`: The `Napi::Object` which is to be referenced.
37
-
38
- * `[in] initialRefcount`: The initial reference count.
39
-
40
- Returns the newly created reference.
41
-
42
- ```cpp
43
- static Napi::ObjectReference Napi::Weak(const Napi::Object& value);
44
- ```
45
-
46
- Creates a "weak" reference to the value, in that the initial count of number of references is set to 0.
47
-
48
- * `[in] value`: The value which is to be referenced.
49
-
50
- Returns the newly created reference.
51
-
52
- ```cpp
53
- static Napi::ObjectReference Napi::Persistent(const Napi::Object& value);
54
- ```
55
-
56
- Creates a "persistent" reference to the value, in that the initial count of number of references is set to 1.
57
-
58
- * `[in] value`: The value which is to be referenced.
59
-
60
- Returns the newly created reference.
61
-
62
- ### Empty Constructor
63
-
64
- ```cpp
65
- Napi::ObjectReference::ObjectReference();
66
- ```
67
-
68
- Returns a new _empty_ `Napi::ObjectReference` instance.
69
-
70
- ### Constructor
71
-
72
- ```cpp
73
- Napi::ObjectReference::ObjectReference(napi_env env, napi_value value);
74
- ```
75
-
76
- * `[in] env`: The `napi_env` environment in which to construct the `Napi::ObjectReference` object.
77
-
78
- * `[in] value`: The N-API primitive value to be held by the `Napi::ObjectReference`.
79
-
80
- Returns the newly created reference.
81
-
82
- ### Set
83
- ```cpp
84
- void Napi::ObjectReference::Set(___ key, ___ value);
85
- ```
86
-
87
- * `[in] key`: The name for the property being assigned.
88
-
89
- * `[in] value`: The value being assigned to the property.
90
-
91
- The `key` can be any of the following types:
92
- - `const char*`
93
- - `const std::string`
94
- - `uint32_t`
95
-
96
- The `value` can be any of the following types:
97
- - `napi_value`
98
- - `Napi::Value`
99
- - `const char*`
100
- - `bool`
101
- - `double`
102
-
103
- ### Get
104
-
105
- ```cpp
106
- Napi::Value Napi::ObjectReference::Get(___ key);
107
- ```
108
-
109
- * `[in] key`: The name of the property to return the value for.
110
-
111
- Returns the [`Napi::Value`](value.md) associated with the key property. Returns NULL if no such key exists.
112
-
113
- The `key` can be any of the following types:
114
- - `const char*`
115
- - `const std::string`
116
- - `uint32_t`
117
-