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/index.js CHANGED
@@ -1,45 +1,11 @@
1
- var path = require('path');
1
+ const path = require('path');
2
2
 
3
- var versionArray = process.version
4
- .substr(1)
5
- .replace(/-.*$/, '')
6
- .split('.')
7
- .map(function(item) {
8
- return +item;
9
- });
10
-
11
- // TODO: Check if the main node semantic version is within multiple ranges,
12
- // or detect presence of built-in N-API by some other mechanism TBD.
13
-
14
- // We know which version of Node.js first shipped the incarnation of the API
15
- // available in *this* package. So, if we find that the Node.js version is below
16
- // that, we indicate that the API is missing from Node.js.
17
- var isNodeApiBuiltin = (
18
- versionArray[0] > 8 ||
19
- (versionArray[0] == 8 && versionArray[1] >= 6) ||
20
- (versionArray[0] == 6 && versionArray[1] >= 15) ||
21
- (versionArray[0] == 6 && versionArray[1] >= 14 && versionArray[2] >= 2));
22
-
23
- // The flag is not needed when the Node version is not 8, nor if the API is
24
- // built-in, because we removed the flag at the same time as creating the final
25
- // incarnation of the built-in API.
26
- var needsFlag = (!isNodeApiBuiltin && versionArray[0] == 8);
27
-
28
- var include = [__dirname];
29
- var gyp = path.join(__dirname, 'src', 'node_api.gyp');
30
-
31
- if (isNodeApiBuiltin) {
32
- gyp += ':nothing';
33
- } else {
34
- gyp += ':node-api';
35
- include.unshift(path.join(__dirname, 'external-napi'));
36
- }
3
+ const include_dir = path.relative('.', __dirname);
37
4
 
38
5
  module.exports = {
39
- include: include.map(function(item) {
40
- return '"' + item + '"';
41
- }).join(' '),
42
- gyp: gyp,
43
- isNodeApiBuiltin: isNodeApiBuiltin,
44
- needsFlag: needsFlag
6
+ include: `"${__dirname}"`, // deprecated, can be removed as part of 4.0.0
7
+ include_dir,
8
+ gyp: path.join(include_dir, 'node_api.gyp:nothing'),
9
+ isNodeApiBuiltin: true,
10
+ needsFlag: false
45
11
  };