@basemaps/lambda-tiler 6.38.0 → 6.40.0

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 (126) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/build/__tests__/config.data.d.ts.map +1 -1
  3. package/build/__tests__/config.data.js +142 -1
  4. package/build/__tests__/config.data.js.map +1 -1
  5. package/build/__tests__/wmts.capability.test.js +9 -16
  6. package/build/__tests__/wmts.capability.test.js.map +1 -1
  7. package/build/__tests__/xyz.util.d.ts.map +1 -1
  8. package/build/__tests__/xyz.util.js +6 -2
  9. package/build/__tests__/xyz.util.js.map +1 -1
  10. package/build/cli/render.tile.d.ts +2 -0
  11. package/build/cli/render.tile.d.ts.map +1 -0
  12. package/build/cli/render.tile.js +33 -0
  13. package/build/cli/render.tile.js.map +1 -0
  14. package/build/routes/__tests__/attribution.test.js +63 -3
  15. package/build/routes/__tests__/attribution.test.js.map +1 -1
  16. package/build/routes/__tests__/tile.style.json.test.js +91 -43
  17. package/build/routes/__tests__/tile.style.json.test.js.map +1 -1
  18. package/build/routes/__tests__/wmts.test.js +50 -8
  19. package/build/routes/__tests__/wmts.test.js.map +1 -1
  20. package/build/routes/attribution.d.ts +12 -0
  21. package/build/routes/attribution.d.ts.map +1 -1
  22. package/build/routes/attribution.js +29 -27
  23. package/build/routes/attribution.js.map +1 -1
  24. package/build/routes/tile.json.d.ts.map +1 -1
  25. package/build/routes/tile.json.js +2 -1
  26. package/build/routes/tile.json.js.map +1 -1
  27. package/build/routes/tile.style.json.d.ts +2 -2
  28. package/build/routes/tile.style.json.d.ts.map +1 -1
  29. package/build/routes/tile.style.json.js +7 -4
  30. package/build/routes/tile.style.json.js.map +1 -1
  31. package/build/routes/tile.wmts.d.ts.map +1 -1
  32. package/build/routes/tile.wmts.js +3 -1
  33. package/build/routes/tile.wmts.js.map +1 -1
  34. package/build/routes/tile.xyz.raster.d.ts.map +1 -1
  35. package/build/routes/tile.xyz.raster.js +9 -6
  36. package/build/routes/tile.xyz.raster.js.map +1 -1
  37. package/build/util/__test__/filter.test.d.ts +2 -0
  38. package/build/util/__test__/filter.test.d.ts.map +1 -0
  39. package/build/util/__test__/filter.test.js +64 -0
  40. package/build/util/__test__/filter.test.js.map +1 -0
  41. package/build/util/config.loader.d.ts.map +1 -1
  42. package/build/util/config.loader.js +2 -3
  43. package/build/util/config.loader.js.map +1 -1
  44. package/build/util/filter.d.ts +15 -0
  45. package/build/util/filter.d.ts.map +1 -0
  46. package/build/util/filter.js +59 -0
  47. package/build/util/filter.js.map +1 -0
  48. package/build/wmts.capability.d.ts +8 -5
  49. package/build/wmts.capability.d.ts.map +1 -1
  50. package/build/wmts.capability.js +17 -15
  51. package/build/wmts.capability.js.map +1 -1
  52. package/dist/index.js +60 -60
  53. package/dist/node_modules/.package-lock.json +14 -14
  54. package/dist/node_modules/minimist/.eslintrc +25 -50
  55. package/dist/node_modules/minimist/CHANGELOG.md +87 -1
  56. package/dist/node_modules/minimist/README.md +14 -10
  57. package/dist/node_modules/minimist/example/parse.js +2 -0
  58. package/dist/node_modules/minimist/index.js +256 -242
  59. package/dist/node_modules/minimist/package.json +73 -73
  60. package/dist/node_modules/minimist/test/all_bool.js +26 -24
  61. package/dist/node_modules/minimist/test/bool.js +146 -147
  62. package/dist/node_modules/minimist/test/dash.js +33 -21
  63. package/dist/node_modules/minimist/test/default_bool.js +26 -24
  64. package/dist/node_modules/minimist/test/dotted.js +13 -11
  65. package/dist/node_modules/minimist/test/kv_short.js +26 -10
  66. package/dist/node_modules/minimist/test/long.js +28 -26
  67. package/dist/node_modules/minimist/test/num.js +30 -28
  68. package/dist/node_modules/minimist/test/parse.js +169 -157
  69. package/dist/node_modules/minimist/test/parse_modified.js +7 -5
  70. package/dist/node_modules/minimist/test/proto.js +41 -37
  71. package/dist/node_modules/minimist/test/short.js +57 -55
  72. package/dist/node_modules/minimist/test/stop_early.js +10 -8
  73. package/dist/node_modules/minimist/test/unknown.js +83 -81
  74. package/dist/node_modules/minimist/test/whitespace.js +6 -4
  75. package/dist/node_modules/node-abi/.circleci/config.yml +7 -25
  76. package/dist/node_modules/node-abi/.github/CODEOWNERS +1 -0
  77. package/dist/node_modules/node-abi/.github/workflows/update-abi.yml +5 -4
  78. package/dist/node_modules/node-abi/CONTRIBUTING.md +1 -1
  79. package/dist/node_modules/node-abi/README.md +5 -3
  80. package/dist/node_modules/node-abi/abi_registry.json +14 -0
  81. package/dist/node_modules/node-abi/package.json +5 -6
  82. package/dist/node_modules/node-addon-api/README.md +36 -12
  83. package/dist/node_modules/node-addon-api/index.js +3 -3
  84. package/dist/node_modules/node-addon-api/napi-inl.deprecated.h +121 -127
  85. package/dist/node_modules/node-addon-api/napi-inl.h +1166 -1122
  86. package/dist/node_modules/node-addon-api/napi.h +2786 -2675
  87. package/dist/node_modules/node-addon-api/package.json +42 -1
  88. package/dist/node_modules/node-addon-api/tools/check-napi.js +13 -14
  89. package/dist/node_modules/node-addon-api/tools/conversion.js +161 -169
  90. package/dist/node_modules/node-addon-api/tools/eslint-format.js +9 -1
  91. package/dist/node_modules/readable-stream/README.md +1 -1
  92. package/dist/node_modules/readable-stream/lib/_stream_duplex.js +12 -25
  93. package/dist/node_modules/readable-stream/lib/_stream_passthrough.js +2 -4
  94. package/dist/node_modules/readable-stream/lib/_stream_readable.js +176 -273
  95. package/dist/node_modules/readable-stream/lib/_stream_transform.js +26 -37
  96. package/dist/node_modules/readable-stream/lib/_stream_writable.js +118 -174
  97. package/dist/node_modules/readable-stream/lib/internal/streams/async_iterator.js +10 -37
  98. package/dist/node_modules/readable-stream/lib/internal/streams/buffer_list.js +20 -47
  99. package/dist/node_modules/readable-stream/lib/internal/streams/destroy.js +8 -17
  100. package/dist/node_modules/readable-stream/lib/internal/streams/end-of-stream.js +1 -19
  101. package/dist/node_modules/readable-stream/lib/internal/streams/from.js +12 -24
  102. package/dist/node_modules/readable-stream/lib/internal/streams/pipeline.js +5 -16
  103. package/dist/node_modules/readable-stream/lib/internal/streams/state.js +2 -7
  104. package/dist/node_modules/readable-stream/package.json +1 -1
  105. package/dist/package-lock.json +15 -346
  106. package/dist/package.json +1 -1
  107. package/package.json +8 -8
  108. package/src/__tests__/config.data.ts +142 -1
  109. package/src/__tests__/wmts.capability.test.ts +9 -16
  110. package/src/__tests__/xyz.util.ts +6 -2
  111. package/src/cli/render.tile.ts +38 -0
  112. package/src/routes/__tests__/attribution.test.ts +65 -3
  113. package/src/routes/__tests__/tile.style.json.test.ts +100 -44
  114. package/src/routes/__tests__/wmts.test.ts +70 -9
  115. package/src/routes/attribution.ts +24 -28
  116. package/src/routes/tile.json.ts +2 -1
  117. package/src/routes/tile.style.json.ts +13 -5
  118. package/src/routes/tile.wmts.ts +3 -1
  119. package/src/routes/tile.xyz.raster.ts +10 -7
  120. package/src/util/__test__/filter.test.ts +80 -0
  121. package/src/util/config.loader.ts +1 -2
  122. package/src/util/filter.ts +60 -0
  123. package/src/wmts.capability.ts +19 -14
  124. package/tsconfig.tsbuildinfo +1 -1
  125. package/test-dump.js +0 -6
  126. package/test-imagery.js +0 -3
@@ -1,6 +1,6 @@
1
1
  #! /usr/bin/env node
2
2
 
3
- 'use strict'
3
+ 'use strict';
4
4
 
5
5
  const fs = require('fs');
6
6
  const path = require('path');
@@ -15,255 +15,247 @@ if (!dir) {
15
15
  const NodeApiVersion = require('../package.json').version;
16
16
 
17
17
  const disable = args[1];
18
- if (disable != "--disable" && dir != "--disable") {
19
- var ConfigFileOperations = {
18
+ let ConfigFileOperations;
19
+ if (disable !== '--disable' && dir !== '--disable') {
20
+ ConfigFileOperations = {
20
21
  'package.json': [
21
- [ /([ ]*)"dependencies": {/g, '$1"dependencies": {\n$1 "node-addon-api": "' + NodeApiVersion + '",'],
22
- [ /[ ]*"nan": *"[^"]+"(,|)[\n\r]/g, '' ]
22
+ [/([ ]*)"dependencies": {/g, '$1"dependencies": {\n$1 "node-addon-api": "' + NodeApiVersion + '",'],
23
+ [/[ ]*"nan": *"[^"]+"(,|)[\n\r]/g, '']
23
24
  ],
24
25
  'binding.gyp': [
25
- [ /([ ]*)'include_dirs': \[/g, '$1\'include_dirs\': [\n$1 \'<!(node -p "require(\\\'node-addon-api\\\').include_dir")\',' ],
26
- [ /([ ]*)"include_dirs": \[/g, '$1"include_dirs": [\n$1 "<!(node -p \\"require(\'node-addon-api\').include_dir\\")",' ],
27
- [ /[ ]*("|')<!\(node -e ("|'|\\"|\\')require\(("|'|\\"|\\')nan("|'|\\"|\\')\)("|'|\\"|\\')\)("|')(,|)[\r\n]/g, '' ],
28
- [ /([ ]*)("|')target_name("|'): ("|')(.+?)("|'),/g, '$1$2target_name$2: $4$5$6,\n $2cflags!$2: [ $2-fno-exceptions$2 ],\n $2cflags_cc!$2: [ $2-fno-exceptions$2 ],\n $2xcode_settings$2: { $2GCC_ENABLE_CPP_EXCEPTIONS$2: $2YES$2,\n $2CLANG_CXX_LIBRARY$2: $2libc++$2,\n $2MACOSX_DEPLOYMENT_TARGET$2: $210.7$2,\n },\n $2msvs_settings$2: {\n $2VCCLCompilerTool$2: { $2ExceptionHandling$2: 1 },\n },' ],
26
+ [/([ ]*)'include_dirs': \[/g, '$1\'include_dirs\': [\n$1 \'<!(node -p "require(\\\'node-addon-api\\\').include_dir")\','],
27
+ [/([ ]*)"include_dirs": \[/g, '$1"include_dirs": [\n$1 "<!(node -p \\"require(\'node-addon-api\').include_dir\\")",'],
28
+ [/[ ]*("|')<!\(node -e ("|'|\\"|\\')require\(("|'|\\"|\\')nan("|'|\\"|\\')\)("|'|\\"|\\')\)("|')(,|)[\r\n]/g, ''],
29
+ [/([ ]*)("|')target_name("|'): ("|')(.+?)("|'),/g, '$1$2target_name$2: $4$5$6,\n $2cflags!$2: [ $2-fno-exceptions$2 ],\n $2cflags_cc!$2: [ $2-fno-exceptions$2 ],\n $2xcode_settings$2: { $2GCC_ENABLE_CPP_EXCEPTIONS$2: $2YES$2,\n $2CLANG_CXX_LIBRARY$2: $2libc++$2,\n $2MACOSX_DEPLOYMENT_TARGET$2: $210.7$2,\n },\n $2msvs_settings$2: {\n $2VCCLCompilerTool$2: { $2ExceptionHandling$2: 1 },\n },']
29
30
  ]
30
31
  };
31
32
  } else {
32
- var ConfigFileOperations = {
33
+ ConfigFileOperations = {
33
34
  'package.json': [
34
- [ /([ ]*)"dependencies": {/g, '$1"dependencies": {\n$1 "node-addon-api": "' + NodeApiVersion + '",'],
35
- [ /[ ]*"nan": *"[^"]+"(,|)[\n\r]/g, '' ]
35
+ [/([ ]*)"dependencies": {/g, '$1"dependencies": {\n$1 "node-addon-api": "' + NodeApiVersion + '",'],
36
+ [/[ ]*"nan": *"[^"]+"(,|)[\n\r]/g, '']
36
37
  ],
37
38
  'binding.gyp': [
38
- [ /([ ]*)'include_dirs': \[/g, '$1\'include_dirs\': [\n$1 \'<!(node -p "require(\\\'node-addon-api\\\').include_dir")\',' ],
39
- [ /([ ]*)"include_dirs": \[/g, '$1"include_dirs": [\n$1 "<!(node -p \'require(\\\"node-addon-api\\\").include_dir\')",' ],
40
- [ /[ ]*("|')<!\(node -e ("|'|\\"|\\')require\(("|'|\\"|\\')nan("|'|\\"|\\')\)("|'|\\"|\\')\)("|')(,|)[\r\n]/g, '' ],
41
- [ /([ ]*)("|')target_name("|'): ("|')(.+?)("|'),/g, '$1$2target_name$2: $4$5$6,\n $2cflags!$2: [ $2-fno-exceptions$2 ],\n $2cflags_cc!$2: [ $2-fno-exceptions$2 ],\n $2defines$2: [ $2NAPI_DISABLE_CPP_EXCEPTIONS$2 ],\n $2conditions$2: [\n [\'OS==\"win\"\', { $2defines$2: [ $2_HAS_EXCEPTIONS=1$2 ] }]\n ]' ],
39
+ [/([ ]*)'include_dirs': \[/g, '$1\'include_dirs\': [\n$1 \'<!(node -p "require(\\\'node-addon-api\\\').include_dir")\','],
40
+ [/([ ]*)"include_dirs": \[/g, '$1"include_dirs": [\n$1 "<!(node -p \'require(\\"node-addon-api\\").include_dir\')",'],
41
+ [/[ ]*("|')<!\(node -e ("|'|\\"|\\')require\(("|'|\\"|\\')nan("|'|\\"|\\')\)("|'|\\"|\\')\)("|')(,|)[\r\n]/g, ''],
42
+ [/([ ]*)("|')target_name("|'): ("|')(.+?)("|'),/g, '$1$2target_name$2: $4$5$6,\n $2cflags!$2: [ $2-fno-exceptions$2 ],\n $2cflags_cc!$2: [ $2-fno-exceptions$2 ],\n $2defines$2: [ $2NAPI_DISABLE_CPP_EXCEPTIONS$2 ],\n $2conditions$2: [\n [\'OS=="win"\', { $2defines$2: [ $2_HAS_EXCEPTIONS=1$2 ] }]\n ]']
42
43
  ]
43
44
  };
44
45
  }
45
46
 
46
- var SourceFileOperations = [
47
- [ /Nan::SetMethod\(target,[\s]*\"(.*)\"[\s]*,[\s]*([^)]+)\)/g, 'exports.Set(Napi::String::New(env, \"$1\"), Napi::Function::New(env, $2))' ],
47
+ const SourceFileOperations = [
48
+ [/Nan::SetMethod\(target,[\s]*"(.*)"[\s]*,[\s]*([^)]+)\)/g, 'exports.Set(Napi::String::New(env, "$1"), Napi::Function::New(env, $2))'],
48
49
 
49
- [ /v8::Local<v8::FunctionTemplate>\s+(\w+)\s*=\s*Nan::New<FunctionTemplate>\([\w\d:]+\);(?:\w+->Reset\(\1\))?\s+\1->SetClassName\(Nan::String::New\("(\w+)"\)\);/g, 'Napi::Function $1 = DefineClass(env, "$2", {' ],
50
- [ /Local<FunctionTemplate>\s+(\w+)\s*=\s*Nan::New<FunctionTemplate>\([\w\d:]+\);\s+(\w+)\.Reset\((\1)\);\s+\1->SetClassName\((Nan::String::New|Nan::New<(v8::)*String>)\("(.+?)"\)\);/g, 'Napi::Function $1 = DefineClass(env, "$6", {'],
51
- [ /Local<FunctionTemplate>\s+(\w+)\s*=\s*Nan::New<FunctionTemplate>\([\w\d:]+\);(?:\w+->Reset\(\1\))?\s+\1->SetClassName\(Nan::String::New\("(\w+)"\)\);/g, 'Napi::Function $1 = DefineClass(env, "$2", {' ],
52
- [ /Nan::New<v8::FunctionTemplate>\(([\w\d:]+)\)->GetFunction\(\)/g, 'Napi::Function::New(env, $1)' ],
53
- [ /Nan::New<FunctionTemplate>\(([\w\d:]+)\)->GetFunction()/g, 'Napi::Function::New(env, $1);' ],
54
- [ /Nan::New<v8::FunctionTemplate>\(([\w\d:]+)\)/g, 'Napi::Function::New(env, $1)' ],
55
- [ /Nan::New<FunctionTemplate>\(([\w\d:]+)\)/g, 'Napi::Function::New(env, $1)' ],
50
+ [/v8::Local<v8::FunctionTemplate>\s+(\w+)\s*=\s*Nan::New<FunctionTemplate>\([\w\d:]+\);(?:\w+->Reset\(\1\))?\s+\1->SetClassName\(Nan::String::New\("(\w+)"\)\);/g, 'Napi::Function $1 = DefineClass(env, "$2", {'],
51
+ [/Local<FunctionTemplate>\s+(\w+)\s*=\s*Nan::New<FunctionTemplate>\([\w\d:]+\);\s+(\w+)\.Reset\((\1)\);\s+\1->SetClassName\((Nan::String::New|Nan::New<(v8::)*String>)\("(.+?)"\)\);/g, 'Napi::Function $1 = DefineClass(env, "$6", {'],
52
+ [/Local<FunctionTemplate>\s+(\w+)\s*=\s*Nan::New<FunctionTemplate>\([\w\d:]+\);(?:\w+->Reset\(\1\))?\s+\1->SetClassName\(Nan::String::New\("(\w+)"\)\);/g, 'Napi::Function $1 = DefineClass(env, "$2", {'],
53
+ [/Nan::New<v8::FunctionTemplate>\(([\w\d:]+)\)->GetFunction\(\)/g, 'Napi::Function::New(env, $1)'],
54
+ [/Nan::New<FunctionTemplate>\(([\w\d:]+)\)->GetFunction()/g, 'Napi::Function::New(env, $1);'],
55
+ [/Nan::New<v8::FunctionTemplate>\(([\w\d:]+)\)/g, 'Napi::Function::New(env, $1)'],
56
+ [/Nan::New<FunctionTemplate>\(([\w\d:]+)\)/g, 'Napi::Function::New(env, $1)'],
56
57
 
57
58
  // FunctionTemplate to FunctionReference
58
- [ /Nan::Persistent<(v8::)*FunctionTemplate>/g, 'Napi::FunctionReference' ],
59
- [ /Nan::Persistent<(v8::)*Function>/g, 'Napi::FunctionReference' ],
60
- [ /v8::Local<v8::FunctionTemplate>/g, 'Napi::FunctionReference' ],
61
- [ /Local<FunctionTemplate>/g, 'Napi::FunctionReference' ],
62
- [ /v8::FunctionTemplate/g, 'Napi::FunctionReference' ],
63
- [ /FunctionTemplate/g, 'Napi::FunctionReference' ],
64
-
65
-
66
- [ /([ ]*)Nan::SetPrototypeMethod\(\w+, "(\w+)", (\w+)\);/g, '$1InstanceMethod("$2", &$3),' ],
67
- [ /([ ]*)(?:\w+\.Reset\(\w+\);\s+)?\(target\)\.Set\("(\w+)",\s*Nan::GetFunction\((\w+)\)\);/gm,
59
+ [/Nan::Persistent<(v8::)*FunctionTemplate>/g, 'Napi::FunctionReference'],
60
+ [/Nan::Persistent<(v8::)*Function>/g, 'Napi::FunctionReference'],
61
+ [/v8::Local<v8::FunctionTemplate>/g, 'Napi::FunctionReference'],
62
+ [/Local<FunctionTemplate>/g, 'Napi::FunctionReference'],
63
+ [/v8::FunctionTemplate/g, 'Napi::FunctionReference'],
64
+ [/FunctionTemplate/g, 'Napi::FunctionReference'],
65
+
66
+ [/([ ]*)Nan::SetPrototypeMethod\(\w+, "(\w+)", (\w+)\);/g, '$1InstanceMethod("$2", &$3),'],
67
+ [/([ ]*)(?:\w+\.Reset\(\w+\);\s+)?\(target\)\.Set\("(\w+)",\s*Nan::GetFunction\((\w+)\)\);/gm,
68
68
  '});\n\n' +
69
69
  '$1constructor = Napi::Persistent($3);\n' +
70
70
  '$1constructor.SuppressDestruct();\n' +
71
- '$1target.Set("$2", $3);' ],
72
-
71
+ '$1target.Set("$2", $3);'],
73
72
 
74
73
  // TODO: Other attribute combinations
75
- [ /static_cast<PropertyAttribute>\(ReadOnly\s*\|\s*DontDelete\)/gm,
76
- 'static_cast<napi_property_attributes>(napi_enumerable | napi_configurable)' ],
74
+ [/static_cast<PropertyAttribute>\(ReadOnly\s*\|\s*DontDelete\)/gm,
75
+ 'static_cast<napi_property_attributes>(napi_enumerable | napi_configurable)'],
77
76
 
78
- [ /([\w\d:<>]+?)::Cast\((.+?)\)/g, '$2.As<$1>()' ],
77
+ [/([\w\d:<>]+?)::Cast\((.+?)\)/g, '$2.As<$1>()'],
79
78
 
80
- [ /\*Nan::Utf8String\(([^)]+)\)/g, '$1->As<Napi::String>().Utf8Value().c_str()' ],
81
- [ /Nan::Utf8String +(\w+)\(([^)]+)\)/g, 'std::string $1 = $2.As<Napi::String>()' ],
82
- [ /Nan::Utf8String/g, 'std::string' ],
79
+ [/\*Nan::Utf8String\(([^)]+)\)/g, '$1->As<Napi::String>().Utf8Value().c_str()'],
80
+ [/Nan::Utf8String +(\w+)\(([^)]+)\)/g, 'std::string $1 = $2.As<Napi::String>()'],
81
+ [/Nan::Utf8String/g, 'std::string'],
83
82
 
84
- [ /v8::String::Utf8Value (.+?)\((.+?)\)/g, 'Napi::String $1(env, $2)' ],
85
- [ /String::Utf8Value (.+?)\((.+?)\)/g, 'Napi::String $1(env, $2)' ],
86
- [ /\.length\(\)/g, '.Length()' ],
83
+ [/v8::String::Utf8Value (.+?)\((.+?)\)/g, 'Napi::String $1(env, $2)'],
84
+ [/String::Utf8Value (.+?)\((.+?)\)/g, 'Napi::String $1(env, $2)'],
85
+ [/\.length\(\)/g, '.Length()'],
87
86
 
88
- [ /Nan::MakeCallback\(([^,]+),[\s\\]+([^,]+),/gm, '$2.MakeCallback($1,' ],
87
+ [/Nan::MakeCallback\(([^,]+),[\s\\]+([^,]+),/gm, '$2.MakeCallback($1,'],
89
88
 
90
- [ /class\s+(\w+)\s*:\s*public\s+Nan::ObjectWrap/g, 'class $1 : public Napi::ObjectWrap<$1>' ],
91
- [ /(\w+)\(([^\)]*)\)\s*:\s*Nan::ObjectWrap\(\)\s*(,)?/gm, '$1($2) : Napi::ObjectWrap<$1>()$3' ],
89
+ [/class\s+(\w+)\s*:\s*public\s+Nan::ObjectWrap/g, 'class $1 : public Napi::ObjectWrap<$1>'],
90
+ [/(\w+)\(([^)]*)\)\s*:\s*Nan::ObjectWrap\(\)\s*(,)?/gm, '$1($2) : Napi::ObjectWrap<$1>()$3'],
92
91
 
93
92
  // HandleOKCallback to OnOK
94
- [ /HandleOKCallback/g, 'OnOK' ],
93
+ [/HandleOKCallback/g, 'OnOK'],
95
94
  // HandleErrorCallback to OnError
96
- [ /HandleErrorCallback/g, 'OnError' ],
95
+ [/HandleErrorCallback/g, 'OnError'],
97
96
 
98
97
  // ex. .As<Function>() to .As<Napi::Object>()
99
- [ /\.As<v8::(Value|Boolean|String|Number|Object|Array|Symbol|External|Function)>\(\)/g, '.As<Napi::$1>()' ],
100
- [ /\.As<(Value|Boolean|String|Number|Object|Array|Symbol|External|Function)>\(\)/g, '.As<Napi::$1>()' ],
98
+ [/\.As<v8::(Value|Boolean|String|Number|Object|Array|Symbol|External|Function)>\(\)/g, '.As<Napi::$1>()'],
99
+ [/\.As<(Value|Boolean|String|Number|Object|Array|Symbol|External|Function)>\(\)/g, '.As<Napi::$1>()'],
101
100
 
102
101
  // ex. Nan::New<Number>(info[0]) to Napi::Number::New(info[0])
103
- [ /Nan::New<(v8::)*Integer>\((.+?)\)/g, 'Napi::Number::New(env, $2)' ],
104
- [ /Nan::New\(([0-9\.]+)\)/g, 'Napi::Number::New(env, $1)' ],
105
- [ /Nan::New<(v8::)*String>\("(.+?)"\)/g, 'Napi::String::New(env, "$2")' ],
106
- [ /Nan::New\("(.+?)"\)/g, 'Napi::String::New(env, "$1")' ],
107
- [ /Nan::New<(v8::)*(.+?)>\(\)/g, 'Napi::$2::New(env)' ],
108
- [ /Nan::New<(.+?)>\(\)/g, 'Napi::$1::New(env)' ],
109
- [ /Nan::New<(v8::)*(.+?)>\(/g, 'Napi::$2::New(env, ' ],
110
- [ /Nan::New<(.+?)>\(/g, 'Napi::$1::New(env, ' ],
111
- [ /Nan::NewBuffer\(/g, 'Napi::Buffer<char>::New(env, ' ],
102
+ [/Nan::New<(v8::)*Integer>\((.+?)\)/g, 'Napi::Number::New(env, $2)'],
103
+ [/Nan::New\(([0-9.]+)\)/g, 'Napi::Number::New(env, $1)'],
104
+ [/Nan::New<(v8::)*String>\("(.+?)"\)/g, 'Napi::String::New(env, "$2")'],
105
+ [/Nan::New\("(.+?)"\)/g, 'Napi::String::New(env, "$1")'],
106
+ [/Nan::New<(v8::)*(.+?)>\(\)/g, 'Napi::$2::New(env)'],
107
+ [/Nan::New<(.+?)>\(\)/g, 'Napi::$1::New(env)'],
108
+ [/Nan::New<(v8::)*(.+?)>\(/g, 'Napi::$2::New(env, '],
109
+ [/Nan::New<(.+?)>\(/g, 'Napi::$1::New(env, '],
110
+ [/Nan::NewBuffer\(/g, 'Napi::Buffer<char>::New(env, '],
112
111
  // TODO: Properly handle this
113
- [ /Nan::New\(/g, 'Napi::New(env, ' ],
112
+ [/Nan::New\(/g, 'Napi::New(env, '],
114
113
 
115
- [ /\.IsInt32\(\)/g, '.IsNumber()' ],
116
- [ /->IsInt32\(\)/g, '.IsNumber()' ],
114
+ [/\.IsInt32\(\)/g, '.IsNumber()'],
115
+ [/->IsInt32\(\)/g, '.IsNumber()'],
117
116
 
118
-
119
- [ /(.+?)->BooleanValue\(\)/g, '$1.As<Napi::Boolean>().Value()' ],
120
- [ /(.+?)->Int32Value\(\)/g, '$1.As<Napi::Number>().Int32Value()' ],
121
- [ /(.+?)->Uint32Value\(\)/g, '$1.As<Napi::Number>().Uint32Value()' ],
122
- [ /(.+?)->IntegerValue\(\)/g, '$1.As<Napi::Number>().Int64Value()' ],
123
- [ /(.+?)->NumberValue\(\)/g, '$1.As<Napi::Number>().DoubleValue()' ],
117
+ [/(.+?)->BooleanValue\(\)/g, '$1.As<Napi::Boolean>().Value()'],
118
+ [/(.+?)->Int32Value\(\)/g, '$1.As<Napi::Number>().Int32Value()'],
119
+ [/(.+?)->Uint32Value\(\)/g, '$1.As<Napi::Number>().Uint32Value()'],
120
+ [/(.+?)->IntegerValue\(\)/g, '$1.As<Napi::Number>().Int64Value()'],
121
+ [/(.+?)->NumberValue\(\)/g, '$1.As<Napi::Number>().DoubleValue()'],
124
122
 
125
123
  // ex. Nan::To<bool>(info[0]) to info[0].Value()
126
- [ /Nan::To<v8::(Boolean|String|Number|Object|Array|Symbol|Function)>\((.+?)\)/g, '$2.To<Napi::$1>()' ],
127
- [ /Nan::To<(Boolean|String|Number|Object|Array|Symbol|Function)>\((.+?)\)/g, '$2.To<Napi::$1>()' ],
124
+ [/Nan::To<v8::(Boolean|String|Number|Object|Array|Symbol|Function)>\((.+?)\)/g, '$2.To<Napi::$1>()'],
125
+ [/Nan::To<(Boolean|String|Number|Object|Array|Symbol|Function)>\((.+?)\)/g, '$2.To<Napi::$1>()'],
128
126
  // ex. Nan::To<bool>(info[0]) to info[0].As<Napi::Boolean>().Value()
129
- [ /Nan::To<bool>\((.+?)\)/g, '$1.As<Napi::Boolean>().Value()' ],
127
+ [/Nan::To<bool>\((.+?)\)/g, '$1.As<Napi::Boolean>().Value()'],
130
128
  // ex. Nan::To<int>(info[0]) to info[0].As<Napi::Number>().Int32Value()
131
- [ /Nan::To<int>\((.+?)\)/g, '$1.As<Napi::Number>().Int32Value()' ],
129
+ [/Nan::To<int>\((.+?)\)/g, '$1.As<Napi::Number>().Int32Value()'],
132
130
  // ex. Nan::To<int32_t>(info[0]) to info[0].As<Napi::Number>().Int32Value()
133
- [ /Nan::To<int32_t>\((.+?)\)/g, '$1.As<Napi::Number>().Int32Value()' ],
131
+ [/Nan::To<int32_t>\((.+?)\)/g, '$1.As<Napi::Number>().Int32Value()'],
134
132
  // ex. Nan::To<uint32_t>(info[0]) to info[0].As<Napi::Number>().Uint32Value()
135
- [ /Nan::To<uint32_t>\((.+?)\)/g, '$1.As<Napi::Number>().Uint32Value()' ],
133
+ [/Nan::To<uint32_t>\((.+?)\)/g, '$1.As<Napi::Number>().Uint32Value()'],
136
134
  // ex. Nan::To<int64_t>(info[0]) to info[0].As<Napi::Number>().Int64Value()
137
- [ /Nan::To<int64_t>\((.+?)\)/g, '$1.As<Napi::Number>().Int64Value()' ],
135
+ [/Nan::To<int64_t>\((.+?)\)/g, '$1.As<Napi::Number>().Int64Value()'],
138
136
  // ex. Nan::To<float>(info[0]) to info[0].As<Napi::Number>().FloatValue()
139
- [ /Nan::To<float>\((.+?)\)/g, '$1.As<Napi::Number>().FloatValue()' ],
137
+ [/Nan::To<float>\((.+?)\)/g, '$1.As<Napi::Number>().FloatValue()'],
140
138
  // ex. Nan::To<double>(info[0]) to info[0].As<Napi::Number>().DoubleValue()
141
- [ /Nan::To<double>\((.+?)\)/g, '$1.As<Napi::Number>().DoubleValue()' ],
142
-
143
- [ /Nan::New\((\w+)\)->HasInstance\((\w+)\)/g, '$2.InstanceOf($1.Value())' ],
139
+ [/Nan::To<double>\((.+?)\)/g, '$1.As<Napi::Number>().DoubleValue()'],
144
140
 
145
- [ /Nan::Has\(([^,]+),\s*/gm, '($1).Has(' ],
146
- [ /\.Has\([\s|\\]*Nan::New<(v8::)*String>\(([^)]+)\)\)/gm, '.Has($1)' ],
147
- [ /\.Has\([\s|\\]*Nan::New\(([^)]+)\)\)/gm, '.Has($1)' ],
141
+ [/Nan::New\((\w+)\)->HasInstance\((\w+)\)/g, '$2.InstanceOf($1.Value())'],
148
142
 
149
- [ /Nan::Get\(([^,]+),\s*/gm, '($1).Get(' ],
150
- [ /\.Get\([\s|\\]*Nan::New<(v8::)*String>\(([^)]+)\)\)/gm, '.Get($1)' ],
151
- [ /\.Get\([\s|\\]*Nan::New\(([^)]+)\)\)/gm, '.Get($1)' ],
143
+ [/Nan::Has\(([^,]+),\s*/gm, '($1).Has('],
144
+ [/\.Has\([\s|\\]*Nan::New<(v8::)*String>\(([^)]+)\)\)/gm, '.Has($1)'],
145
+ [/\.Has\([\s|\\]*Nan::New\(([^)]+)\)\)/gm, '.Has($1)'],
152
146
 
153
- [ /Nan::Set\(([^,]+),\s*/gm, '($1).Set(' ],
154
- [ /\.Set\([\s|\\]*Nan::New<(v8::)*String>\(([^)]+)\)\s*,/gm, '.Set($1,' ],
155
- [ /\.Set\([\s|\\]*Nan::New\(([^)]+)\)\s*,/gm, '.Set($1,' ],
147
+ [/Nan::Get\(([^,]+),\s*/gm, '($1).Get('],
148
+ [/\.Get\([\s|\\]*Nan::New<(v8::)*String>\(([^)]+)\)\)/gm, '.Get($1)'],
149
+ [/\.Get\([\s|\\]*Nan::New\(([^)]+)\)\)/gm, '.Get($1)'],
156
150
 
151
+ [/Nan::Set\(([^,]+),\s*/gm, '($1).Set('],
152
+ [/\.Set\([\s|\\]*Nan::New<(v8::)*String>\(([^)]+)\)\s*,/gm, '.Set($1,'],
153
+ [/\.Set\([\s|\\]*Nan::New\(([^)]+)\)\s*,/gm, '.Set($1,'],
157
154
 
158
155
  // ex. node::Buffer::HasInstance(info[0]) to info[0].IsBuffer()
159
- [ /node::Buffer::HasInstance\((.+?)\)/g, '$1.IsBuffer()' ],
156
+ [/node::Buffer::HasInstance\((.+?)\)/g, '$1.IsBuffer()'],
160
157
  // ex. node::Buffer::Length(info[0]) to info[0].Length()
161
- [ /node::Buffer::Length\((.+?)\)/g, '$1.As<Napi::Buffer<char>>().Length()' ],
158
+ [/node::Buffer::Length\((.+?)\)/g, '$1.As<Napi::Buffer<char>>().Length()'],
162
159
  // ex. node::Buffer::Data(info[0]) to info[0].Data()
163
- [ /node::Buffer::Data\((.+?)\)/g, '$1.As<Napi::Buffer<char>>().Data()' ],
164
- [ /Nan::CopyBuffer\(/g, 'Napi::Buffer::Copy(env, ' ],
160
+ [/node::Buffer::Data\((.+?)\)/g, '$1.As<Napi::Buffer<char>>().Data()'],
161
+ [/Nan::CopyBuffer\(/g, 'Napi::Buffer::Copy(env, '],
165
162
 
166
163
  // Nan::AsyncQueueWorker(worker)
167
- [ /Nan::AsyncQueueWorker\((.+)\);/g, '$1.Queue();' ],
168
- [ /Nan::(Undefined|Null|True|False)\(\)/g, 'env.$1()' ],
164
+ [/Nan::AsyncQueueWorker\((.+)\);/g, '$1.Queue();'],
165
+ [/Nan::(Undefined|Null|True|False)\(\)/g, 'env.$1()'],
169
166
 
170
167
  // Nan::ThrowError(error) to Napi::Error::New(env, error).ThrowAsJavaScriptException()
171
- [ /([ ]*)return Nan::Throw(\w*?)Error\((.+?)\);/g, '$1Napi::$2Error::New(env, $3).ThrowAsJavaScriptException();\n$1return env.Null();' ],
172
- [ /Nan::Throw(\w*?)Error\((.+?)\);\n(\s*)return;/g, 'Napi::$1Error::New(env, $2).ThrowAsJavaScriptException();\n$3return env.Null();' ],
173
- [ /Nan::Throw(\w*?)Error\((.+?)\);/g, 'Napi::$1Error::New(env, $2).ThrowAsJavaScriptException();\n' ],
168
+ [/([ ]*)return Nan::Throw(\w*?)Error\((.+?)\);/g, '$1Napi::$2Error::New(env, $3).ThrowAsJavaScriptException();\n$1return env.Null();'],
169
+ [/Nan::Throw(\w*?)Error\((.+?)\);\n(\s*)return;/g, 'Napi::$1Error::New(env, $2).ThrowAsJavaScriptException();\n$3return env.Null();'],
170
+ [/Nan::Throw(\w*?)Error\((.+?)\);/g, 'Napi::$1Error::New(env, $2).ThrowAsJavaScriptException();\n'],
174
171
  // Nan::RangeError(error) to Napi::RangeError::New(env, error)
175
- [ /Nan::(\w*?)Error\((.+)\)/g, 'Napi::$1Error::New(env, $2)' ],
172
+ [/Nan::(\w*?)Error\((.+)\)/g, 'Napi::$1Error::New(env, $2)'],
176
173
 
177
- [ /Nan::Set\((.+?),\n* *(.+?),\n* *(.+?),\n* *(.+?)\)/g, '$1.Set($2, $3, $4)' ],
174
+ [/Nan::Set\((.+?),\n* *(.+?),\n* *(.+?),\n* *(.+?)\)/g, '$1.Set($2, $3, $4)'],
178
175
 
179
- [ /Nan::(Escapable)?HandleScope\s+(\w+)\s*;/g, 'Napi::$1HandleScope $2(env);' ],
180
- [ /Nan::(Escapable)?HandleScope/g, 'Napi::$1HandleScope' ],
181
- [ /Nan::ForceSet\(([^,]+), ?/g, '$1->DefineProperty(' ],
182
- [ /\.ForceSet\(Napi::String::New\(env, "(\w+)"\),\s*?/g, '.DefineProperty("$1", ' ],
176
+ [/Nan::(Escapable)?HandleScope\s+(\w+)\s*;/g, 'Napi::$1HandleScope $2(env);'],
177
+ [/Nan::(Escapable)?HandleScope/g, 'Napi::$1HandleScope'],
178
+ [/Nan::ForceSet\(([^,]+), ?/g, '$1->DefineProperty('],
179
+ [/\.ForceSet\(Napi::String::New\(env, "(\w+)"\),\s*?/g, '.DefineProperty("$1", '],
183
180
  // [ /Nan::GetPropertyNames\(([^,]+)\)/, '$1->GetPropertyNames()' ],
184
- [ /Nan::Equals\(([^,]+),/g, '$1.StrictEquals(' ],
185
-
186
-
187
- [ /(.+)->Set\(/g, '$1.Set\(' ],
188
-
189
-
190
- [ /Nan::Callback/g, 'Napi::FunctionReference' ],
191
-
181
+ [/Nan::Equals\(([^,]+),/g, '$1.StrictEquals('],
192
182
 
193
- [ /Nan::Persistent<Object>/g, 'Napi::ObjectReference' ],
194
- [ /Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target/g, 'Napi::Env& env, Napi::Object& target' ],
183
+ [/(.+)->Set\(/g, '$1.Set('],
195
184
 
196
- [ /(\w+)\*\s+(\w+)\s*=\s*Nan::ObjectWrap::Unwrap<\w+>\(info\.This\(\)\);/g, '$1* $2 = this;' ],
197
- [ /Nan::ObjectWrap::Unwrap<(\w+)>\((.*)\);/g, '$2.Unwrap<$1>();' ],
185
+ [/Nan::Callback/g, 'Napi::FunctionReference'],
198
186
 
199
- [ /Nan::NAN_METHOD_RETURN_TYPE/g, 'void' ],
200
- [ /NAN_INLINE/g, 'inline' ],
187
+ [/Nan::Persistent<Object>/g, 'Napi::ObjectReference'],
188
+ [/Nan::ADDON_REGISTER_FUNCTION_ARGS_TYPE target/g, 'Napi::Env& env, Napi::Object& target'],
201
189
 
202
- [ /Nan::NAN_METHOD_ARGS_TYPE/g, 'const Napi::CallbackInfo&' ],
203
- [ /NAN_METHOD\(([\w\d:]+?)\)/g, 'Napi::Value $1(const Napi::CallbackInfo& info)'],
204
- [ /static\s*NAN_GETTER\(([\w\d:]+?)\)/g, 'Napi::Value $1(const Napi::CallbackInfo& info)' ],
205
- [ /NAN_GETTER\(([\w\d:]+?)\)/g, 'Napi::Value $1(const Napi::CallbackInfo& info)' ],
206
- [ /static\s*NAN_SETTER\(([\w\d:]+?)\)/g, 'void $1(const Napi::CallbackInfo& info, const Napi::Value& value)' ],
207
- [ /NAN_SETTER\(([\w\d:]+?)\)/g, 'void $1(const Napi::CallbackInfo& info, const Napi::Value& value)' ],
208
- [ /void Init\((v8::)*Local<(v8::)*Object> exports\)/g, 'Napi::Object Init(Napi::Env env, Napi::Object exports)' ],
209
- [ /NAN_MODULE_INIT\(([\w\d:]+?)\);/g, 'Napi::Object $1(Napi::Env env, Napi::Object exports);' ],
210
- [ /NAN_MODULE_INIT\(([\w\d:]+?)\)/g, 'Napi::Object $1(Napi::Env env, Napi::Object exports)' ],
190
+ [/(\w+)\*\s+(\w+)\s*=\s*Nan::ObjectWrap::Unwrap<\w+>\(info\.This\(\)\);/g, '$1* $2 = this;'],
191
+ [/Nan::ObjectWrap::Unwrap<(\w+)>\((.*)\);/g, '$2.Unwrap<$1>();'],
211
192
 
193
+ [/Nan::NAN_METHOD_RETURN_TYPE/g, 'void'],
194
+ [/NAN_INLINE/g, 'inline'],
212
195
 
213
- [ /::(Init(?:ialize)?)\(target\)/g, '::$1(env, target, module)' ],
214
- [ /constructor_template/g, 'constructor' ],
196
+ [/Nan::NAN_METHOD_ARGS_TYPE/g, 'const Napi::CallbackInfo&'],
197
+ [/NAN_METHOD\(([\w\d:]+?)\)/g, 'Napi::Value $1(const Napi::CallbackInfo& info)'],
198
+ [/static\s*NAN_GETTER\(([\w\d:]+?)\)/g, 'Napi::Value $1(const Napi::CallbackInfo& info)'],
199
+ [/NAN_GETTER\(([\w\d:]+?)\)/g, 'Napi::Value $1(const Napi::CallbackInfo& info)'],
200
+ [/static\s*NAN_SETTER\(([\w\d:]+?)\)/g, 'void $1(const Napi::CallbackInfo& info, const Napi::Value& value)'],
201
+ [/NAN_SETTER\(([\w\d:]+?)\)/g, 'void $1(const Napi::CallbackInfo& info, const Napi::Value& value)'],
202
+ [/void Init\((v8::)*Local<(v8::)*Object> exports\)/g, 'Napi::Object Init(Napi::Env env, Napi::Object exports)'],
203
+ [/NAN_MODULE_INIT\(([\w\d:]+?)\);/g, 'Napi::Object $1(Napi::Env env, Napi::Object exports);'],
204
+ [/NAN_MODULE_INIT\(([\w\d:]+?)\)/g, 'Napi::Object $1(Napi::Env env, Napi::Object exports)'],
215
205
 
216
- [ /Nan::FunctionCallbackInfo<(v8::)?Value>[ ]*& [ ]*info\)[ ]*{\n*([ ]*)/gm, 'Napi::CallbackInfo& info) {\n$2Napi::Env env = info.Env();\n$2' ],
217
- [ /Nan::FunctionCallbackInfo<(v8::)*Value>\s*&\s*info\);/g, 'Napi::CallbackInfo& info);' ],
218
- [ /Nan::FunctionCallbackInfo<(v8::)*Value>\s*&/g, 'Napi::CallbackInfo&' ],
206
+ [/::(Init(?:ialize)?)\(target\)/g, '::$1(env, target, module)'],
207
+ [/constructor_template/g, 'constructor'],
219
208
 
220
- [ /Buffer::HasInstance\(([^)]+)\)/g, '$1.IsBuffer()' ],
209
+ [/Nan::FunctionCallbackInfo<(v8::)?Value>[ ]*& [ ]*info\)[ ]*{\n*([ ]*)/gm, 'Napi::CallbackInfo& info) {\n$2Napi::Env env = info.Env();\n$2'],
210
+ [/Nan::FunctionCallbackInfo<(v8::)*Value>\s*&\s*info\);/g, 'Napi::CallbackInfo& info);'],
211
+ [/Nan::FunctionCallbackInfo<(v8::)*Value>\s*&/g, 'Napi::CallbackInfo&'],
221
212
 
222
- [ /info\[(\d+)\]->/g, 'info[$1].' ],
223
- [ /info\[([\w\d]+)\]->/g, 'info[$1].' ],
224
- [ /info\.This\(\)->/g, 'info.This().' ],
225
- [ /->Is(Object|String|Int32|Number)\(\)/g, '.Is$1()' ],
226
- [ /info.GetReturnValue\(\).SetUndefined\(\)/g, 'return env.Undefined()' ],
227
- [ /info\.GetReturnValue\(\)\.Set\(((\n|.)+?)\);/g, 'return $1;' ],
213
+ [/Buffer::HasInstance\(([^)]+)\)/g, '$1.IsBuffer()'],
228
214
 
215
+ [/info\[(\d+)\]->/g, 'info[$1].'],
216
+ [/info\[([\w\d]+)\]->/g, 'info[$1].'],
217
+ [/info\.This\(\)->/g, 'info.This().'],
218
+ [/->Is(Object|String|Int32|Number)\(\)/g, '.Is$1()'],
219
+ [/info.GetReturnValue\(\).SetUndefined\(\)/g, 'return env.Undefined()'],
220
+ [/info\.GetReturnValue\(\)\.Set\(((\n|.)+?)\);/g, 'return $1;'],
229
221
 
230
222
  // ex. Local<Value> to Napi::Value
231
- [ /v8::Local<v8::(Value|Boolean|String|Number|Object|Array|Symbol|External|Function)>/g, 'Napi::$1' ],
232
- [ /Local<(Value|Boolean|String|Number|Object|Array|Symbol|External|Function)>/g, 'Napi::$1' ],
223
+ [/v8::Local<v8::(Value|Boolean|String|Number|Object|Array|Symbol|External|Function)>/g, 'Napi::$1'],
224
+ [/Local<(Value|Boolean|String|Number|Object|Array|Symbol|External|Function)>/g, 'Napi::$1'],
233
225
 
234
226
  // Declare an env in helper functions that take a Napi::Value
235
- [ /(\w+)\(Napi::Value (\w+)(,\s*[^\()]+)?\)\s*{\n*([ ]*)/gm, '$1(Napi::Value $2$3) {\n$4Napi::Env env = $2.Env();\n$4' ],
227
+ [/(\w+)\(Napi::Value (\w+)(,\s*[^()]+)?\)\s*{\n*([ ]*)/gm, '$1(Napi::Value $2$3) {\n$4Napi::Env env = $2.Env();\n$4'],
236
228
 
237
229
  // delete #include <node.h> and/or <v8.h>
238
- [ /#include +(<|")(?:node|nan).h("|>)/g, "#include $1napi.h$2\n#include $1uv.h$2" ],
230
+ [/#include +(<|")(?:node|nan).h("|>)/g, '#include $1napi.h$2\n#include $1uv.h$2'],
239
231
  // NODE_MODULE to NODE_API_MODULE
240
- [ /NODE_MODULE/g, 'NODE_API_MODULE' ],
241
- [ /Nan::/g, 'Napi::' ],
242
- [ /nan.h/g, 'napi.h' ],
232
+ [/NODE_MODULE/g, 'NODE_API_MODULE'],
233
+ [/Nan::/g, 'Napi::'],
234
+ [/nan.h/g, 'napi.h'],
243
235
 
244
236
  // delete .FromJust()
245
- [ /\.FromJust\(\)/g, '' ],
237
+ [/\.FromJust\(\)/g, ''],
246
238
  // delete .ToLocalCheck()
247
- [ /\.ToLocalChecked\(\)/g, '' ],
248
- [ /^.*->SetInternalFieldCount\(.*$/gm, '' ],
239
+ [/\.ToLocalChecked\(\)/g, ''],
240
+ [/^.*->SetInternalFieldCount\(.*$/gm, ''],
249
241
 
250
242
  // replace using node; and/or using v8; to using Napi;
251
- [ /using (node|v8);/g, 'using Napi;' ],
252
- [ /using namespace (node|Nan|v8);/g, 'using namespace Napi;' ],
243
+ [/using (node|v8);/g, 'using Napi;'],
244
+ [/using namespace (node|Nan|v8);/g, 'using namespace Napi;'],
253
245
  // delete using v8::Local;
254
- [ /using v8::Local;\n/g, '' ],
246
+ [/using v8::Local;\n/g, ''],
255
247
  // replace using v8::XXX; with using Napi::XXX
256
- [ /using v8::([A-Za-z]+);/g, 'using Napi::$1;' ],
248
+ [/using v8::([A-Za-z]+);/g, 'using Napi::$1;']
257
249
 
258
250
  ];
259
251
 
260
- var paths = listFiles(dir);
261
- paths.forEach(function(dirEntry) {
262
- var filename = dirEntry.split('\\').pop().split('/').pop();
252
+ const paths = listFiles(dir);
253
+ paths.forEach(function (dirEntry) {
254
+ const filename = dirEntry.split('\\').pop().split('/').pop();
263
255
 
264
256
  // Check whether the file is a source file or a config file
265
257
  // then execute function accordingly
266
- var sourcePattern = /.+\.h|.+\.cc|.+\.cpp/;
258
+ const sourcePattern = /.+\.h|.+\.cc|.+\.cpp/;
267
259
  if (sourcePattern.test(filename)) {
268
260
  convertFile(dirEntry, SourceFileOperations);
269
261
  } else if (ConfigFileOperations[filename] != null) {
@@ -271,12 +263,12 @@ paths.forEach(function(dirEntry) {
271
263
  }
272
264
  });
273
265
 
274
- function listFiles(dir, filelist) {
275
- var files = fs.readdirSync(dir);
266
+ function listFiles (dir, filelist) {
267
+ const files = fs.readdirSync(dir);
276
268
  filelist = filelist || [];
277
- files.forEach(function(file) {
269
+ files.forEach(function (file) {
278
270
  if (file === 'node_modules') {
279
- return
271
+ return;
280
272
  }
281
273
 
282
274
  if (fs.statSync(path.join(dir, file)).isDirectory()) {
@@ -288,21 +280,21 @@ function listFiles(dir, filelist) {
288
280
  return filelist;
289
281
  }
290
282
 
291
- function convert(content, operations) {
292
- for (let i = 0; i < operations.length; i ++) {
293
- let operation = operations[i];
283
+ function convert (content, operations) {
284
+ for (let i = 0; i < operations.length; i++) {
285
+ const operation = operations[i];
294
286
  content = content.replace(operation[0], operation[1]);
295
287
  }
296
288
  return content;
297
289
  }
298
290
 
299
- function convertFile(fileName, operations) {
300
- fs.readFile(fileName, "utf-8", function (err, file) {
291
+ function convertFile (fileName, operations) {
292
+ fs.readFile(fileName, 'utf-8', function (err, file) {
301
293
  if (err) throw err;
302
294
 
303
295
  file = convert(file, operations);
304
296
 
305
- fs.writeFile(fileName, file, function(err){
297
+ fs.writeFile(fileName, file, function (err) {
306
298
  if (err) throw err;
307
299
  });
308
300
  });
@@ -4,6 +4,8 @@ const spawn = require('child_process').spawnSync;
4
4
 
5
5
  const filesToCheck = '*.js';
6
6
  const FORMAT_START = process.env.FORMAT_START || 'main';
7
+ const IS_WIN = process.platform === 'win32';
8
+ const ESLINT_PATH = IS_WIN ? 'node_modules\\.bin\\eslint.cmd' : 'node_modules/.bin/eslint';
7
9
 
8
10
  function main (args) {
9
11
  let fix = false;
@@ -44,10 +46,16 @@ function main (args) {
44
46
  if (fix) {
45
47
  options.push('--fix');
46
48
  }
47
- const result = spawn('node_modules/.bin/eslint', [...options], {
49
+
50
+ const result = spawn(ESLINT_PATH, [...options], {
48
51
  encoding: 'utf-8'
49
52
  });
50
53
 
54
+ if (result.error && result.error.errno === 'ENOENT') {
55
+ console.error('Eslint not found! Eslint is supposed to be found at ', ESLINT_PATH);
56
+ return 2;
57
+ }
58
+
51
59
  if (result.status === 1) {
52
60
  console.error('Eslint error:', result.stdout);
53
61
  const fixCmd = 'npm run lint:fix';
@@ -15,7 +15,7 @@ npm install --save readable-stream
15
15
 
16
16
  This package is a mirror of the streams implementations in Node.js.
17
17
 
18
- Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v10.19.0/docs/api/stream.html).
18
+ Full documentation may be found on the [Node.js website](https://nodejs.org/dist/v10.18.1/docs/api/stream.html).
19
19
 
20
20
  If you want to guarantee a stable streams base, regardless of what version of
21
21
  Node you, or the users of your libraries are using, use **readable-stream** *only* and avoid the *"stream"* module in Node-core, for background see [this blogpost](http://r.va.gg/2014/06/why-i-dont-use-nodes-core-stream-module.html).
@@ -18,60 +18,48 @@
18
18
  // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19
19
  // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20
20
  // USE OR OTHER DEALINGS IN THE SOFTWARE.
21
+
21
22
  // a duplex stream is just a stream that is both readable and writable.
22
23
  // Since JS doesn't have multiple prototypal inheritance, this class
23
24
  // prototypally inherits from Readable, and then parasitically from
24
25
  // Writable.
26
+
25
27
  'use strict';
26
- /*<replacement>*/
27
28
 
29
+ /*<replacement>*/
28
30
  var objectKeys = Object.keys || function (obj) {
29
31
  var keys = [];
30
-
31
- for (var key in obj) {
32
- keys.push(key);
33
- }
34
-
32
+ for (var key in obj) keys.push(key);
35
33
  return keys;
36
34
  };
37
35
  /*</replacement>*/
38
36
 
39
-
40
37
  module.exports = Duplex;
41
-
42
38
  var Readable = require('./_stream_readable');
43
-
44
39
  var Writable = require('./_stream_writable');
45
-
46
40
  require('inherits')(Duplex, Readable);
47
-
48
41
  {
49
42
  // Allow the keys array to be GC'ed.
50
43
  var keys = objectKeys(Writable.prototype);
51
-
52
44
  for (var v = 0; v < keys.length; v++) {
53
45
  var method = keys[v];
54
46
  if (!Duplex.prototype[method]) Duplex.prototype[method] = Writable.prototype[method];
55
47
  }
56
48
  }
57
-
58
49
  function Duplex(options) {
59
50
  if (!(this instanceof Duplex)) return new Duplex(options);
60
51
  Readable.call(this, options);
61
52
  Writable.call(this, options);
62
53
  this.allowHalfOpen = true;
63
-
64
54
  if (options) {
65
55
  if (options.readable === false) this.readable = false;
66
56
  if (options.writable === false) this.writable = false;
67
-
68
57
  if (options.allowHalfOpen === false) {
69
58
  this.allowHalfOpen = false;
70
59
  this.once('end', onend);
71
60
  }
72
61
  }
73
62
  }
74
-
75
63
  Object.defineProperty(Duplex.prototype, 'writableHighWaterMark', {
76
64
  // making it explicit this property is not enumerable
77
65
  // because otherwise some prototype manipulation in
@@ -98,20 +86,20 @@ Object.defineProperty(Duplex.prototype, 'writableLength', {
98
86
  get: function get() {
99
87
  return this._writableState.length;
100
88
  }
101
- }); // the no-half-open enforcer
89
+ });
102
90
 
91
+ // the no-half-open enforcer
103
92
  function onend() {
104
93
  // If the writable side ended, then we're ok.
105
- if (this._writableState.ended) return; // no more data can be written.
106
- // But allow more writes to happen in this tick.
94
+ if (this._writableState.ended) return;
107
95
 
96
+ // no more data can be written.
97
+ // But allow more writes to happen in this tick.
108
98
  process.nextTick(onEndNT, this);
109
99
  }
110
-
111
100
  function onEndNT(self) {
112
101
  self.end();
113
102
  }
114
-
115
103
  Object.defineProperty(Duplex.prototype, 'destroyed', {
116
104
  // making it explicit this property is not enumerable
117
105
  // because otherwise some prototype manipulation in
@@ -121,7 +109,6 @@ Object.defineProperty(Duplex.prototype, 'destroyed', {
121
109
  if (this._readableState === undefined || this._writableState === undefined) {
122
110
  return false;
123
111
  }
124
-
125
112
  return this._readableState.destroyed && this._writableState.destroyed;
126
113
  },
127
114
  set: function set(value) {
@@ -129,10 +116,10 @@ Object.defineProperty(Duplex.prototype, 'destroyed', {
129
116
  // has not been initialized yet
130
117
  if (this._readableState === undefined || this._writableState === undefined) {
131
118
  return;
132
- } // backward compatibility, the user is explicitly
133
- // managing destroyed
134
-
119
+ }
135
120
 
121
+ // backward compatibility, the user is explicitly
122
+ // managing destroyed
136
123
  this._readableState.destroyed = value;
137
124
  this._writableState.destroyed = value;
138
125
  }