diff --git a/async-work/async-iterator/node-addon-api/CMakeLists.txt b/src/async-work/async-iterator/node-addon-api/CMakeLists.txt similarity index 100% rename from async-work/async-iterator/node-addon-api/CMakeLists.txt rename to src/async-work/async-iterator/node-addon-api/CMakeLists.txt diff --git a/async-work/async-iterator/node-addon-api/example.cc b/src/async-work/async-iterator/node-addon-api/example.cc similarity index 100% rename from async-work/async-iterator/node-addon-api/example.cc rename to src/async-work/async-iterator/node-addon-api/example.cc diff --git a/async-work/async-iterator/node-addon-api/index.js b/src/async-work/async-iterator/node-addon-api/index.js similarity index 100% rename from async-work/async-iterator/node-addon-api/index.js rename to src/async-work/async-iterator/node-addon-api/index.js diff --git a/async-work/async-iterator/node-addon-api/package.json b/src/async-work/async-iterator/node-addon-api/package.json similarity index 100% rename from async-work/async-iterator/node-addon-api/package.json rename to src/async-work/async-iterator/node-addon-api/package.json diff --git a/async-work/async_pi_estimate/nan/README.md b/src/async-work/async_pi_estimate/nan/README.md similarity index 100% rename from async-work/async_pi_estimate/nan/README.md rename to src/async-work/async_pi_estimate/nan/README.md diff --git a/async-work/async_pi_estimate/nan/addon.cc b/src/async-work/async_pi_estimate/nan/addon.cc similarity index 100% rename from async-work/async_pi_estimate/nan/addon.cc rename to src/async-work/async_pi_estimate/nan/addon.cc diff --git a/async-work/async_pi_estimate/nan/addon.js b/src/async-work/async_pi_estimate/nan/addon.js similarity index 100% rename from async-work/async_pi_estimate/nan/addon.js rename to src/async-work/async_pi_estimate/nan/addon.js diff --git a/async-work/async_pi_estimate/nan/async.cc b/src/async-work/async_pi_estimate/nan/async.cc similarity index 100% rename from async-work/async_pi_estimate/nan/async.cc rename to src/async-work/async_pi_estimate/nan/async.cc diff --git a/async-work/async_pi_estimate/nan/async.h b/src/async-work/async_pi_estimate/nan/async.h similarity index 100% rename from async-work/async_pi_estimate/nan/async.h rename to src/async-work/async_pi_estimate/nan/async.h diff --git a/async-work/async_pi_estimate/nan/binding.gyp b/src/async-work/async_pi_estimate/nan/binding.gyp similarity index 100% rename from async-work/async_pi_estimate/nan/binding.gyp rename to src/async-work/async_pi_estimate/nan/binding.gyp diff --git a/async-work/async_pi_estimate/nan/package.json b/src/async-work/async_pi_estimate/nan/package.json similarity index 100% rename from async-work/async_pi_estimate/nan/package.json rename to src/async-work/async_pi_estimate/nan/package.json diff --git a/async-work/async_pi_estimate/nan/pi_est.cc b/src/async-work/async_pi_estimate/nan/pi_est.cc similarity index 100% rename from async-work/async_pi_estimate/nan/pi_est.cc rename to src/async-work/async_pi_estimate/nan/pi_est.cc diff --git a/async-work/async_pi_estimate/nan/pi_est.h b/src/async-work/async_pi_estimate/nan/pi_est.h similarity index 100% rename from async-work/async_pi_estimate/nan/pi_est.h rename to src/async-work/async_pi_estimate/nan/pi_est.h diff --git a/async-work/async_pi_estimate/nan/sync.cc b/src/async-work/async_pi_estimate/nan/sync.cc similarity index 100% rename from async-work/async_pi_estimate/nan/sync.cc rename to src/async-work/async_pi_estimate/nan/sync.cc diff --git a/async-work/async_pi_estimate/nan/sync.h b/src/async-work/async_pi_estimate/nan/sync.h similarity index 100% rename from async-work/async_pi_estimate/nan/sync.h rename to src/async-work/async_pi_estimate/nan/sync.h diff --git a/async-work/async_pi_estimate/node-addon-api/README.md b/src/async-work/async_pi_estimate/node-addon-api/README.md similarity index 100% rename from async-work/async_pi_estimate/node-addon-api/README.md rename to src/async-work/async_pi_estimate/node-addon-api/README.md diff --git a/async-work/async_pi_estimate/node-addon-api/addon.cc b/src/async-work/async_pi_estimate/node-addon-api/addon.cc similarity index 100% rename from async-work/async_pi_estimate/node-addon-api/addon.cc rename to src/async-work/async_pi_estimate/node-addon-api/addon.cc diff --git a/async-work/async_pi_estimate/node-addon-api/addon.js b/src/async-work/async_pi_estimate/node-addon-api/addon.js similarity index 100% rename from async-work/async_pi_estimate/node-addon-api/addon.js rename to src/async-work/async_pi_estimate/node-addon-api/addon.js diff --git a/async-work/async_pi_estimate/node-addon-api/async.cc b/src/async-work/async_pi_estimate/node-addon-api/async.cc similarity index 100% rename from async-work/async_pi_estimate/node-addon-api/async.cc rename to src/async-work/async_pi_estimate/node-addon-api/async.cc diff --git a/async-work/async_pi_estimate/node-addon-api/async.h b/src/async-work/async_pi_estimate/node-addon-api/async.h similarity index 100% rename from async-work/async_pi_estimate/node-addon-api/async.h rename to src/async-work/async_pi_estimate/node-addon-api/async.h diff --git a/async-work/async_pi_estimate/node-addon-api/binding.gyp b/src/async-work/async_pi_estimate/node-addon-api/binding.gyp similarity index 100% rename from async-work/async_pi_estimate/node-addon-api/binding.gyp rename to src/async-work/async_pi_estimate/node-addon-api/binding.gyp diff --git a/async-work/async_pi_estimate/node-addon-api/package.json b/src/async-work/async_pi_estimate/node-addon-api/package.json similarity index 100% rename from async-work/async_pi_estimate/node-addon-api/package.json rename to src/async-work/async_pi_estimate/node-addon-api/package.json diff --git a/async-work/async_pi_estimate/node-addon-api/pi_est.cc b/src/async-work/async_pi_estimate/node-addon-api/pi_est.cc similarity index 100% rename from async-work/async_pi_estimate/node-addon-api/pi_est.cc rename to src/async-work/async_pi_estimate/node-addon-api/pi_est.cc diff --git a/async-work/async_pi_estimate/node-addon-api/pi_est.h b/src/async-work/async_pi_estimate/node-addon-api/pi_est.h similarity index 100% rename from async-work/async_pi_estimate/node-addon-api/pi_est.h rename to src/async-work/async_pi_estimate/node-addon-api/pi_est.h diff --git a/async-work/async_pi_estimate/node-addon-api/sync.cc b/src/async-work/async_pi_estimate/node-addon-api/sync.cc similarity index 100% rename from async-work/async_pi_estimate/node-addon-api/sync.cc rename to src/async-work/async_pi_estimate/node-addon-api/sync.cc diff --git a/async-work/async_pi_estimate/node-addon-api/sync.h b/src/async-work/async_pi_estimate/node-addon-api/sync.h similarity index 100% rename from async-work/async_pi_estimate/node-addon-api/sync.h rename to src/async-work/async_pi_estimate/node-addon-api/sync.h diff --git a/async-work/async_work_promise/napi/binding.c b/src/async-work/async_work_promise/napi/binding.c similarity index 100% rename from async-work/async_work_promise/napi/binding.c rename to src/async-work/async_work_promise/napi/binding.c diff --git a/async-work/async_work_promise/napi/binding.gyp b/src/async-work/async_work_promise/napi/binding.gyp similarity index 100% rename from async-work/async_work_promise/napi/binding.gyp rename to src/async-work/async_work_promise/napi/binding.gyp diff --git a/async-work/async_work_promise/napi/index.js b/src/async-work/async_work_promise/napi/index.js similarity index 100% rename from async-work/async_work_promise/napi/index.js rename to src/async-work/async_work_promise/napi/index.js diff --git a/async-work/async_work_promise/napi/package.json b/src/async-work/async_work_promise/napi/package.json similarity index 100% rename from async-work/async_work_promise/napi/package.json rename to src/async-work/async_work_promise/napi/package.json diff --git a/async-work/async_work_promise/node-addon-api/addon.cc b/src/async-work/async_work_promise/node-addon-api/addon.cc similarity index 99% rename from async-work/async_work_promise/node-addon-api/addon.cc rename to src/async-work/async_work_promise/node-addon-api/addon.cc index 35abd245..ccd2d7a3 100644 --- a/async-work/async_work_promise/node-addon-api/addon.cc +++ b/src/async-work/async_work_promise/node-addon-api/addon.cc @@ -10,14 +10,14 @@ Napi::Value DoHeavyMath(const Napi::CallbackInfo& info) { return env.Undefined(); } uint32_t num_1 = info[0].As().Uint32Value(); - + if (!info[1].IsNumber()) { Napi::TypeError::New(env, "num2 must be a number") .ThrowAsJavaScriptException(); return env.Undefined(); } uint32_t num_2 = info[1].As().Uint32Value(); - + DoHeavyMathWorker* worker = new DoHeavyMathWorker(env, num_1, num_2); worker->Queue(); return worker->GetPromise(); diff --git a/async-work/async_work_promise/node-addon-api/binding.gyp b/src/async-work/async_work_promise/node-addon-api/binding.gyp similarity index 100% rename from async-work/async_work_promise/node-addon-api/binding.gyp rename to src/async-work/async_work_promise/node-addon-api/binding.gyp diff --git a/async-work/async_work_promise/node-addon-api/index.js b/src/async-work/async_work_promise/node-addon-api/index.js similarity index 100% rename from async-work/async_work_promise/node-addon-api/index.js rename to src/async-work/async_work_promise/node-addon-api/index.js diff --git a/async-work/async_work_promise/node-addon-api/package.json b/src/async-work/async_work_promise/node-addon-api/package.json similarity index 100% rename from async-work/async_work_promise/node-addon-api/package.json rename to src/async-work/async_work_promise/node-addon-api/package.json diff --git a/async-work/async_work_promise/node-addon-api/worker.h b/src/async-work/async_work_promise/node-addon-api/worker.h similarity index 100% rename from async-work/async_work_promise/node-addon-api/worker.h rename to src/async-work/async_work_promise/node-addon-api/worker.h diff --git a/async-work/async_work_thread_safe_function/napi/binding.c b/src/async-work/async_work_thread_safe_function/napi/binding.c similarity index 100% rename from async-work/async_work_thread_safe_function/napi/binding.c rename to src/async-work/async_work_thread_safe_function/napi/binding.c diff --git a/async-work/async_work_thread_safe_function/napi/binding.gyp b/src/async-work/async_work_thread_safe_function/napi/binding.gyp similarity index 100% rename from async-work/async_work_thread_safe_function/napi/binding.gyp rename to src/async-work/async_work_thread_safe_function/napi/binding.gyp diff --git a/async-work/async_work_thread_safe_function/napi/index.js b/src/async-work/async_work_thread_safe_function/napi/index.js similarity index 100% rename from async-work/async_work_thread_safe_function/napi/index.js rename to src/async-work/async_work_thread_safe_function/napi/index.js diff --git a/async-work/async_work_thread_safe_function/napi/package.json b/src/async-work/async_work_thread_safe_function/napi/package.json similarity index 100% rename from async-work/async_work_thread_safe_function/napi/package.json rename to src/async-work/async_work_thread_safe_function/napi/package.json diff --git a/async-work/call-js-from-async-worker-execute/node-addon-api/binding.gyp b/src/async-work/call-js-from-async-worker-execute/node-addon-api/binding.gyp similarity index 100% rename from async-work/call-js-from-async-worker-execute/node-addon-api/binding.gyp rename to src/async-work/call-js-from-async-worker-execute/node-addon-api/binding.gyp diff --git a/async-work/call-js-from-async-worker-execute/node-addon-api/index.js b/src/async-work/call-js-from-async-worker-execute/node-addon-api/index.js similarity index 100% rename from async-work/call-js-from-async-worker-execute/node-addon-api/index.js rename to src/async-work/call-js-from-async-worker-execute/node-addon-api/index.js diff --git a/async-work/call-js-from-async-worker-execute/node-addon-api/package.json b/src/async-work/call-js-from-async-worker-execute/node-addon-api/package.json similarity index 100% rename from async-work/call-js-from-async-worker-execute/node-addon-api/package.json rename to src/async-work/call-js-from-async-worker-execute/node-addon-api/package.json diff --git a/async-work/call-js-from-async-worker-execute/node-addon-api/src/binding.cc b/src/async-work/call-js-from-async-worker-execute/node-addon-api/src/binding.cc similarity index 100% rename from async-work/call-js-from-async-worker-execute/node-addon-api/src/binding.cc rename to src/async-work/call-js-from-async-worker-execute/node-addon-api/src/binding.cc diff --git a/async-work/napi-asyncworker-example/node-addon-api/README.md b/src/async-work/napi-asyncworker-example/node-addon-api/README.md similarity index 100% rename from async-work/napi-asyncworker-example/node-addon-api/README.md rename to src/async-work/napi-asyncworker-example/node-addon-api/README.md diff --git a/async-work/napi-asyncworker-example/node-addon-api/binding.gyp b/src/async-work/napi-asyncworker-example/node-addon-api/binding.gyp similarity index 100% rename from async-work/napi-asyncworker-example/node-addon-api/binding.gyp rename to src/async-work/napi-asyncworker-example/node-addon-api/binding.gyp diff --git a/async-work/napi-asyncworker-example/node-addon-api/package.json b/src/async-work/napi-asyncworker-example/node-addon-api/package.json similarity index 100% rename from async-work/napi-asyncworker-example/node-addon-api/package.json rename to src/async-work/napi-asyncworker-example/node-addon-api/package.json diff --git a/async-work/napi-asyncworker-example/node-addon-api/src/RunSimpleAsyncWorker.cc b/src/async-work/napi-asyncworker-example/node-addon-api/src/RunSimpleAsyncWorker.cc similarity index 100% rename from async-work/napi-asyncworker-example/node-addon-api/src/RunSimpleAsyncWorker.cc rename to src/async-work/napi-asyncworker-example/node-addon-api/src/RunSimpleAsyncWorker.cc diff --git a/async-work/napi-asyncworker-example/node-addon-api/src/SimpleAsyncWorker.cc b/src/async-work/napi-asyncworker-example/node-addon-api/src/SimpleAsyncWorker.cc similarity index 100% rename from async-work/napi-asyncworker-example/node-addon-api/src/SimpleAsyncWorker.cc rename to src/async-work/napi-asyncworker-example/node-addon-api/src/SimpleAsyncWorker.cc diff --git a/async-work/napi-asyncworker-example/node-addon-api/src/SimpleAsyncWorker.h b/src/async-work/napi-asyncworker-example/node-addon-api/src/SimpleAsyncWorker.h similarity index 100% rename from async-work/napi-asyncworker-example/node-addon-api/src/SimpleAsyncWorker.h rename to src/async-work/napi-asyncworker-example/node-addon-api/src/SimpleAsyncWorker.h diff --git a/async-work/napi-asyncworker-example/node-addon-api/test/Test.js b/src/async-work/napi-asyncworker-example/node-addon-api/test/Test.js similarity index 100% rename from async-work/napi-asyncworker-example/node-addon-api/test/Test.js rename to src/async-work/napi-asyncworker-example/node-addon-api/test/Test.js diff --git a/context-awareness/napi/binding.gyp b/src/context-awareness/napi/binding.gyp similarity index 100% rename from context-awareness/napi/binding.gyp rename to src/context-awareness/napi/binding.gyp diff --git a/context-awareness/napi/index.js b/src/context-awareness/napi/index.js similarity index 100% rename from context-awareness/napi/index.js rename to src/context-awareness/napi/index.js diff --git a/context-awareness/napi/multiple_load.c b/src/context-awareness/napi/multiple_load.c similarity index 100% rename from context-awareness/napi/multiple_load.c rename to src/context-awareness/napi/multiple_load.c diff --git a/context-awareness/napi/package.json b/src/context-awareness/napi/package.json similarity index 100% rename from context-awareness/napi/package.json rename to src/context-awareness/napi/package.json diff --git a/context-awareness/node_10/binding.gyp b/src/context-awareness/node_10/binding.gyp similarity index 100% rename from context-awareness/node_10/binding.gyp rename to src/context-awareness/node_10/binding.gyp diff --git a/context-awareness/node_10/index.js b/src/context-awareness/node_10/index.js similarity index 100% rename from context-awareness/node_10/index.js rename to src/context-awareness/node_10/index.js diff --git a/context-awareness/node_10/multiple_load.cc b/src/context-awareness/node_10/multiple_load.cc similarity index 100% rename from context-awareness/node_10/multiple_load.cc rename to src/context-awareness/node_10/multiple_load.cc diff --git a/context-awareness/node_10/package.json b/src/context-awareness/node_10/package.json similarity index 100% rename from context-awareness/node_10/package.json rename to src/context-awareness/node_10/package.json diff --git a/events/emit_event_from_cpp/node-addon-api/binding.gyp b/src/events/emit_event_from_cpp/node-addon-api/binding.gyp similarity index 100% rename from events/emit_event_from_cpp/node-addon-api/binding.gyp rename to src/events/emit_event_from_cpp/node-addon-api/binding.gyp diff --git a/events/emit_event_from_cpp/node-addon-api/index.js b/src/events/emit_event_from_cpp/node-addon-api/index.js similarity index 100% rename from events/emit_event_from_cpp/node-addon-api/index.js rename to src/events/emit_event_from_cpp/node-addon-api/index.js diff --git a/events/emit_event_from_cpp/node-addon-api/package.json b/src/events/emit_event_from_cpp/node-addon-api/package.json similarity index 100% rename from events/emit_event_from_cpp/node-addon-api/package.json rename to src/events/emit_event_from_cpp/node-addon-api/package.json diff --git a/events/emit_event_from_cpp/node-addon-api/src/emit-from-cpp.cc b/src/events/emit_event_from_cpp/node-addon-api/src/emit-from-cpp.cc similarity index 100% rename from events/emit_event_from_cpp/node-addon-api/src/emit-from-cpp.cc rename to src/events/emit_event_from_cpp/node-addon-api/src/emit-from-cpp.cc diff --git a/events/inherits_from_event_emitter/node-addon-api/binding.gyp b/src/events/inherits_from_event_emitter/node-addon-api/binding.gyp similarity index 100% rename from events/inherits_from_event_emitter/node-addon-api/binding.gyp rename to src/events/inherits_from_event_emitter/node-addon-api/binding.gyp diff --git a/events/inherits_from_event_emitter/node-addon-api/index.js b/src/events/inherits_from_event_emitter/node-addon-api/index.js similarity index 100% rename from events/inherits_from_event_emitter/node-addon-api/index.js rename to src/events/inherits_from_event_emitter/node-addon-api/index.js diff --git a/events/inherits_from_event_emitter/node-addon-api/package.json b/src/events/inherits_from_event_emitter/node-addon-api/package.json similarity index 100% rename from events/inherits_from_event_emitter/node-addon-api/package.json rename to src/events/inherits_from_event_emitter/node-addon-api/package.json diff --git a/events/inherits_from_event_emitter/node-addon-api/src/binding.cc b/src/events/inherits_from_event_emitter/node-addon-api/src/binding.cc similarity index 100% rename from events/inherits_from_event_emitter/node-addon-api/src/binding.cc rename to src/events/inherits_from_event_emitter/node-addon-api/src/binding.cc diff --git a/events/inherits_from_event_emitter/node-addon-api/src/native-emitter.cc b/src/events/inherits_from_event_emitter/node-addon-api/src/native-emitter.cc similarity index 100% rename from events/inherits_from_event_emitter/node-addon-api/src/native-emitter.cc rename to src/events/inherits_from_event_emitter/node-addon-api/src/native-emitter.cc diff --git a/events/inherits_from_event_emitter/node-addon-api/src/native-emitter.h b/src/events/inherits_from_event_emitter/node-addon-api/src/native-emitter.h similarity index 100% rename from events/inherits_from_event_emitter/node-addon-api/src/native-emitter.h rename to src/events/inherits_from_event_emitter/node-addon-api/src/native-emitter.h diff --git a/general/1_hello_world/README.md b/src/general/1_hello_world/README.md similarity index 100% rename from general/1_hello_world/README.md rename to src/general/1_hello_world/README.md diff --git a/general/1_hello_world/nan/binding.gyp b/src/general/1_hello_world/nan/binding.gyp similarity index 100% rename from general/1_hello_world/nan/binding.gyp rename to src/general/1_hello_world/nan/binding.gyp diff --git a/general/1_hello_world/nan/hello.cc b/src/general/1_hello_world/nan/hello.cc similarity index 100% rename from general/1_hello_world/nan/hello.cc rename to src/general/1_hello_world/nan/hello.cc diff --git a/general/1_hello_world/nan/hello.js b/src/general/1_hello_world/nan/hello.js similarity index 100% rename from general/1_hello_world/nan/hello.js rename to src/general/1_hello_world/nan/hello.js diff --git a/general/1_hello_world/nan/package.json b/src/general/1_hello_world/nan/package.json similarity index 100% rename from general/1_hello_world/nan/package.json rename to src/general/1_hello_world/nan/package.json diff --git a/general/1_hello_world/napi/binding.gyp b/src/general/1_hello_world/napi/binding.gyp similarity index 100% rename from general/1_hello_world/napi/binding.gyp rename to src/general/1_hello_world/napi/binding.gyp diff --git a/general/1_hello_world/napi/hello.c b/src/general/1_hello_world/napi/hello.c similarity index 100% rename from general/1_hello_world/napi/hello.c rename to src/general/1_hello_world/napi/hello.c diff --git a/general/1_hello_world/napi/hello.js b/src/general/1_hello_world/napi/hello.js similarity index 100% rename from general/1_hello_world/napi/hello.js rename to src/general/1_hello_world/napi/hello.js diff --git a/general/1_hello_world/napi/package.json b/src/general/1_hello_world/napi/package.json similarity index 100% rename from general/1_hello_world/napi/package.json rename to src/general/1_hello_world/napi/package.json diff --git a/general/1_hello_world/node-addon-api-addon-class/binding.gyp b/src/general/1_hello_world/node-addon-api-addon-class/binding.gyp similarity index 100% rename from general/1_hello_world/node-addon-api-addon-class/binding.gyp rename to src/general/1_hello_world/node-addon-api-addon-class/binding.gyp diff --git a/general/1_hello_world/node-addon-api-addon-class/hello.cc b/src/general/1_hello_world/node-addon-api-addon-class/hello.cc similarity index 73% rename from general/1_hello_world/node-addon-api-addon-class/hello.cc rename to src/general/1_hello_world/node-addon-api-addon-class/hello.cc index 02429a0a..549ea1ff 100644 --- a/general/1_hello_world/node-addon-api-addon-class/hello.cc +++ b/src/general/1_hello_world/node-addon-api-addon-class/hello.cc @@ -3,9 +3,8 @@ class HelloAddon : public Napi::Addon { public: HelloAddon(Napi::Env env, Napi::Object exports) { - DefineAddon(exports, { - InstanceMethod("hello", &HelloAddon::Hello, napi_enumerable) - }); + DefineAddon(exports, + {InstanceMethod("hello", &HelloAddon::Hello, napi_enumerable)}); } private: diff --git a/general/1_hello_world/node-addon-api-addon-class/hello.js b/src/general/1_hello_world/node-addon-api-addon-class/hello.js similarity index 100% rename from general/1_hello_world/node-addon-api-addon-class/hello.js rename to src/general/1_hello_world/node-addon-api-addon-class/hello.js diff --git a/general/1_hello_world/node-addon-api-addon-class/package.json b/src/general/1_hello_world/node-addon-api-addon-class/package.json similarity index 100% rename from general/1_hello_world/node-addon-api-addon-class/package.json rename to src/general/1_hello_world/node-addon-api-addon-class/package.json diff --git a/general/1_hello_world/node-addon-api/binding.gyp b/src/general/1_hello_world/node-addon-api/binding.gyp similarity index 100% rename from general/1_hello_world/node-addon-api/binding.gyp rename to src/general/1_hello_world/node-addon-api/binding.gyp diff --git a/general/1_hello_world/node-addon-api/hello.cc b/src/general/1_hello_world/node-addon-api/hello.cc similarity index 100% rename from general/1_hello_world/node-addon-api/hello.cc rename to src/general/1_hello_world/node-addon-api/hello.cc diff --git a/general/1_hello_world/node-addon-api/hello.js b/src/general/1_hello_world/node-addon-api/hello.js similarity index 100% rename from general/1_hello_world/node-addon-api/hello.js rename to src/general/1_hello_world/node-addon-api/hello.js diff --git a/general/1_hello_world/node-addon-api/package.json b/src/general/1_hello_world/node-addon-api/package.json similarity index 100% rename from general/1_hello_world/node-addon-api/package.json rename to src/general/1_hello_world/node-addon-api/package.json diff --git a/general/2_function_arguments/README.md b/src/general/2_function_arguments/README.md similarity index 100% rename from general/2_function_arguments/README.md rename to src/general/2_function_arguments/README.md diff --git a/general/2_function_arguments/nan/addon.cc b/src/general/2_function_arguments/nan/addon.cc similarity index 100% rename from general/2_function_arguments/nan/addon.cc rename to src/general/2_function_arguments/nan/addon.cc diff --git a/general/2_function_arguments/nan/addon.js b/src/general/2_function_arguments/nan/addon.js similarity index 100% rename from general/2_function_arguments/nan/addon.js rename to src/general/2_function_arguments/nan/addon.js diff --git a/general/2_function_arguments/nan/binding.gyp b/src/general/2_function_arguments/nan/binding.gyp similarity index 100% rename from general/2_function_arguments/nan/binding.gyp rename to src/general/2_function_arguments/nan/binding.gyp diff --git a/general/2_function_arguments/nan/package.json b/src/general/2_function_arguments/nan/package.json similarity index 100% rename from general/2_function_arguments/nan/package.json rename to src/general/2_function_arguments/nan/package.json diff --git a/general/2_function_arguments/napi/addon.c b/src/general/2_function_arguments/napi/addon.c similarity index 100% rename from general/2_function_arguments/napi/addon.c rename to src/general/2_function_arguments/napi/addon.c diff --git a/general/2_function_arguments/napi/addon.js b/src/general/2_function_arguments/napi/addon.js similarity index 100% rename from general/2_function_arguments/napi/addon.js rename to src/general/2_function_arguments/napi/addon.js diff --git a/general/2_function_arguments/napi/binding.gyp b/src/general/2_function_arguments/napi/binding.gyp similarity index 100% rename from general/2_function_arguments/napi/binding.gyp rename to src/general/2_function_arguments/napi/binding.gyp diff --git a/general/2_function_arguments/napi/package.json b/src/general/2_function_arguments/napi/package.json similarity index 100% rename from general/2_function_arguments/napi/package.json rename to src/general/2_function_arguments/napi/package.json diff --git a/general/2_function_arguments/node-addon-api/addon.cc b/src/general/2_function_arguments/node-addon-api/addon.cc similarity index 100% rename from general/2_function_arguments/node-addon-api/addon.cc rename to src/general/2_function_arguments/node-addon-api/addon.cc diff --git a/general/2_function_arguments/node-addon-api/addon.js b/src/general/2_function_arguments/node-addon-api/addon.js similarity index 100% rename from general/2_function_arguments/node-addon-api/addon.js rename to src/general/2_function_arguments/node-addon-api/addon.js diff --git a/general/2_function_arguments/node-addon-api/binding.gyp b/src/general/2_function_arguments/node-addon-api/binding.gyp similarity index 100% rename from general/2_function_arguments/node-addon-api/binding.gyp rename to src/general/2_function_arguments/node-addon-api/binding.gyp diff --git a/general/2_function_arguments/node-addon-api/package.json b/src/general/2_function_arguments/node-addon-api/package.json similarity index 100% rename from general/2_function_arguments/node-addon-api/package.json rename to src/general/2_function_arguments/node-addon-api/package.json diff --git a/general/3_callbacks/nan/addon.cc b/src/general/3_callbacks/nan/addon.cc similarity index 100% rename from general/3_callbacks/nan/addon.cc rename to src/general/3_callbacks/nan/addon.cc diff --git a/general/3_callbacks/nan/addon.js b/src/general/3_callbacks/nan/addon.js similarity index 100% rename from general/3_callbacks/nan/addon.js rename to src/general/3_callbacks/nan/addon.js diff --git a/general/3_callbacks/nan/binding.gyp b/src/general/3_callbacks/nan/binding.gyp similarity index 100% rename from general/3_callbacks/nan/binding.gyp rename to src/general/3_callbacks/nan/binding.gyp diff --git a/general/3_callbacks/nan/package.json b/src/general/3_callbacks/nan/package.json similarity index 100% rename from general/3_callbacks/nan/package.json rename to src/general/3_callbacks/nan/package.json diff --git a/general/3_callbacks/napi/addon.c b/src/general/3_callbacks/napi/addon.c similarity index 100% rename from general/3_callbacks/napi/addon.c rename to src/general/3_callbacks/napi/addon.c diff --git a/general/3_callbacks/napi/addon.js b/src/general/3_callbacks/napi/addon.js similarity index 100% rename from general/3_callbacks/napi/addon.js rename to src/general/3_callbacks/napi/addon.js diff --git a/general/3_callbacks/napi/binding.gyp b/src/general/3_callbacks/napi/binding.gyp similarity index 100% rename from general/3_callbacks/napi/binding.gyp rename to src/general/3_callbacks/napi/binding.gyp diff --git a/general/3_callbacks/napi/package.json b/src/general/3_callbacks/napi/package.json similarity index 100% rename from general/3_callbacks/napi/package.json rename to src/general/3_callbacks/napi/package.json diff --git a/general/3_callbacks/node-addon-api/addon.cc b/src/general/3_callbacks/node-addon-api/addon.cc similarity index 100% rename from general/3_callbacks/node-addon-api/addon.cc rename to src/general/3_callbacks/node-addon-api/addon.cc diff --git a/general/3_callbacks/node-addon-api/addon.js b/src/general/3_callbacks/node-addon-api/addon.js similarity index 100% rename from general/3_callbacks/node-addon-api/addon.js rename to src/general/3_callbacks/node-addon-api/addon.js diff --git a/general/3_callbacks/node-addon-api/binding.gyp b/src/general/3_callbacks/node-addon-api/binding.gyp similarity index 100% rename from general/3_callbacks/node-addon-api/binding.gyp rename to src/general/3_callbacks/node-addon-api/binding.gyp diff --git a/general/3_callbacks/node-addon-api/package.json b/src/general/3_callbacks/node-addon-api/package.json similarity index 100% rename from general/3_callbacks/node-addon-api/package.json rename to src/general/3_callbacks/node-addon-api/package.json diff --git a/general/4_object_factory/nan/addon.cc b/src/general/4_object_factory/nan/addon.cc similarity index 100% rename from general/4_object_factory/nan/addon.cc rename to src/general/4_object_factory/nan/addon.cc diff --git a/general/4_object_factory/nan/addon.js b/src/general/4_object_factory/nan/addon.js similarity index 100% rename from general/4_object_factory/nan/addon.js rename to src/general/4_object_factory/nan/addon.js diff --git a/general/4_object_factory/nan/binding.gyp b/src/general/4_object_factory/nan/binding.gyp similarity index 100% rename from general/4_object_factory/nan/binding.gyp rename to src/general/4_object_factory/nan/binding.gyp diff --git a/general/4_object_factory/nan/package.json b/src/general/4_object_factory/nan/package.json similarity index 100% rename from general/4_object_factory/nan/package.json rename to src/general/4_object_factory/nan/package.json diff --git a/general/4_object_factory/napi/addon.c b/src/general/4_object_factory/napi/addon.c similarity index 100% rename from general/4_object_factory/napi/addon.c rename to src/general/4_object_factory/napi/addon.c diff --git a/general/4_object_factory/napi/addon.js b/src/general/4_object_factory/napi/addon.js similarity index 100% rename from general/4_object_factory/napi/addon.js rename to src/general/4_object_factory/napi/addon.js diff --git a/general/4_object_factory/napi/binding.gyp b/src/general/4_object_factory/napi/binding.gyp similarity index 100% rename from general/4_object_factory/napi/binding.gyp rename to src/general/4_object_factory/napi/binding.gyp diff --git a/general/4_object_factory/napi/package.json b/src/general/4_object_factory/napi/package.json similarity index 100% rename from general/4_object_factory/napi/package.json rename to src/general/4_object_factory/napi/package.json diff --git a/general/4_object_factory/node-addon-api/addon.cc b/src/general/4_object_factory/node-addon-api/addon.cc similarity index 100% rename from general/4_object_factory/node-addon-api/addon.cc rename to src/general/4_object_factory/node-addon-api/addon.cc diff --git a/general/4_object_factory/node-addon-api/addon.js b/src/general/4_object_factory/node-addon-api/addon.js similarity index 100% rename from general/4_object_factory/node-addon-api/addon.js rename to src/general/4_object_factory/node-addon-api/addon.js diff --git a/general/4_object_factory/node-addon-api/binding.gyp b/src/general/4_object_factory/node-addon-api/binding.gyp similarity index 100% rename from general/4_object_factory/node-addon-api/binding.gyp rename to src/general/4_object_factory/node-addon-api/binding.gyp diff --git a/general/4_object_factory/node-addon-api/package.json b/src/general/4_object_factory/node-addon-api/package.json similarity index 100% rename from general/4_object_factory/node-addon-api/package.json rename to src/general/4_object_factory/node-addon-api/package.json diff --git a/general/5_function_factory/nan/addon.cc b/src/general/5_function_factory/nan/addon.cc similarity index 100% rename from general/5_function_factory/nan/addon.cc rename to src/general/5_function_factory/nan/addon.cc diff --git a/general/5_function_factory/nan/addon.js b/src/general/5_function_factory/nan/addon.js similarity index 100% rename from general/5_function_factory/nan/addon.js rename to src/general/5_function_factory/nan/addon.js diff --git a/general/5_function_factory/nan/binding.gyp b/src/general/5_function_factory/nan/binding.gyp similarity index 100% rename from general/5_function_factory/nan/binding.gyp rename to src/general/5_function_factory/nan/binding.gyp diff --git a/general/5_function_factory/nan/package.json b/src/general/5_function_factory/nan/package.json similarity index 100% rename from general/5_function_factory/nan/package.json rename to src/general/5_function_factory/nan/package.json diff --git a/general/5_function_factory/napi/addon.c b/src/general/5_function_factory/napi/addon.c similarity index 100% rename from general/5_function_factory/napi/addon.c rename to src/general/5_function_factory/napi/addon.c diff --git a/general/5_function_factory/napi/addon.js b/src/general/5_function_factory/napi/addon.js similarity index 100% rename from general/5_function_factory/napi/addon.js rename to src/general/5_function_factory/napi/addon.js diff --git a/general/5_function_factory/napi/binding.gyp b/src/general/5_function_factory/napi/binding.gyp similarity index 100% rename from general/5_function_factory/napi/binding.gyp rename to src/general/5_function_factory/napi/binding.gyp diff --git a/general/5_function_factory/napi/package.json b/src/general/5_function_factory/napi/package.json similarity index 100% rename from general/5_function_factory/napi/package.json rename to src/general/5_function_factory/napi/package.json diff --git a/general/5_function_factory/node-addon-api/addon.cc b/src/general/5_function_factory/node-addon-api/addon.cc similarity index 100% rename from general/5_function_factory/node-addon-api/addon.cc rename to src/general/5_function_factory/node-addon-api/addon.cc diff --git a/general/5_function_factory/node-addon-api/addon.js b/src/general/5_function_factory/node-addon-api/addon.js similarity index 100% rename from general/5_function_factory/node-addon-api/addon.js rename to src/general/5_function_factory/node-addon-api/addon.js diff --git a/general/5_function_factory/node-addon-api/binding.gyp b/src/general/5_function_factory/node-addon-api/binding.gyp similarity index 100% rename from general/5_function_factory/node-addon-api/binding.gyp rename to src/general/5_function_factory/node-addon-api/binding.gyp diff --git a/general/5_function_factory/node-addon-api/package.json b/src/general/5_function_factory/node-addon-api/package.json similarity index 100% rename from general/5_function_factory/node-addon-api/package.json rename to src/general/5_function_factory/node-addon-api/package.json diff --git a/general/6_object_wrap/nan/addon.cc b/src/general/6_object_wrap/nan/addon.cc similarity index 100% rename from general/6_object_wrap/nan/addon.cc rename to src/general/6_object_wrap/nan/addon.cc diff --git a/general/6_object_wrap/nan/addon.js b/src/general/6_object_wrap/nan/addon.js similarity index 100% rename from general/6_object_wrap/nan/addon.js rename to src/general/6_object_wrap/nan/addon.js diff --git a/general/6_object_wrap/nan/binding.gyp b/src/general/6_object_wrap/nan/binding.gyp similarity index 100% rename from general/6_object_wrap/nan/binding.gyp rename to src/general/6_object_wrap/nan/binding.gyp diff --git a/general/6_object_wrap/nan/myobject.cc b/src/general/6_object_wrap/nan/myobject.cc similarity index 100% rename from general/6_object_wrap/nan/myobject.cc rename to src/general/6_object_wrap/nan/myobject.cc diff --git a/general/6_object_wrap/nan/myobject.h b/src/general/6_object_wrap/nan/myobject.h similarity index 100% rename from general/6_object_wrap/nan/myobject.h rename to src/general/6_object_wrap/nan/myobject.h diff --git a/general/6_object_wrap/nan/package.json b/src/general/6_object_wrap/nan/package.json similarity index 100% rename from general/6_object_wrap/nan/package.json rename to src/general/6_object_wrap/nan/package.json diff --git a/general/6_object_wrap/napi/addon.cc b/src/general/6_object_wrap/napi/addon.cc similarity index 100% rename from general/6_object_wrap/napi/addon.cc rename to src/general/6_object_wrap/napi/addon.cc diff --git a/general/6_object_wrap/napi/addon.js b/src/general/6_object_wrap/napi/addon.js similarity index 100% rename from general/6_object_wrap/napi/addon.js rename to src/general/6_object_wrap/napi/addon.js diff --git a/general/6_object_wrap/napi/binding.gyp b/src/general/6_object_wrap/napi/binding.gyp similarity index 100% rename from general/6_object_wrap/napi/binding.gyp rename to src/general/6_object_wrap/napi/binding.gyp diff --git a/general/6_object_wrap/napi/myobject.cc b/src/general/6_object_wrap/napi/myobject.cc similarity index 100% rename from general/6_object_wrap/napi/myobject.cc rename to src/general/6_object_wrap/napi/myobject.cc diff --git a/general/6_object_wrap/napi/myobject.h b/src/general/6_object_wrap/napi/myobject.h similarity index 100% rename from general/6_object_wrap/napi/myobject.h rename to src/general/6_object_wrap/napi/myobject.h diff --git a/general/6_object_wrap/napi/package.json b/src/general/6_object_wrap/napi/package.json similarity index 100% rename from general/6_object_wrap/napi/package.json rename to src/general/6_object_wrap/napi/package.json diff --git a/general/6_object_wrap/node-addon-api/addon.cc b/src/general/6_object_wrap/node-addon-api/addon.cc similarity index 100% rename from general/6_object_wrap/node-addon-api/addon.cc rename to src/general/6_object_wrap/node-addon-api/addon.cc diff --git a/general/6_object_wrap/node-addon-api/addon.js b/src/general/6_object_wrap/node-addon-api/addon.js similarity index 100% rename from general/6_object_wrap/node-addon-api/addon.js rename to src/general/6_object_wrap/node-addon-api/addon.js diff --git a/general/6_object_wrap/node-addon-api/binding.gyp b/src/general/6_object_wrap/node-addon-api/binding.gyp similarity index 100% rename from general/6_object_wrap/node-addon-api/binding.gyp rename to src/general/6_object_wrap/node-addon-api/binding.gyp diff --git a/general/6_object_wrap/node-addon-api/myobject.cc b/src/general/6_object_wrap/node-addon-api/myobject.cc similarity index 100% rename from general/6_object_wrap/node-addon-api/myobject.cc rename to src/general/6_object_wrap/node-addon-api/myobject.cc diff --git a/general/6_object_wrap/node-addon-api/myobject.h b/src/general/6_object_wrap/node-addon-api/myobject.h similarity index 100% rename from general/6_object_wrap/node-addon-api/myobject.h rename to src/general/6_object_wrap/node-addon-api/myobject.h diff --git a/general/6_object_wrap/node-addon-api/package.json b/src/general/6_object_wrap/node-addon-api/package.json similarity index 100% rename from general/6_object_wrap/node-addon-api/package.json rename to src/general/6_object_wrap/node-addon-api/package.json diff --git a/general/7_factory_wrap/nan/addon.cc b/src/general/7_factory_wrap/nan/addon.cc similarity index 100% rename from general/7_factory_wrap/nan/addon.cc rename to src/general/7_factory_wrap/nan/addon.cc diff --git a/general/7_factory_wrap/nan/addon.js b/src/general/7_factory_wrap/nan/addon.js similarity index 100% rename from general/7_factory_wrap/nan/addon.js rename to src/general/7_factory_wrap/nan/addon.js diff --git a/general/7_factory_wrap/nan/binding.gyp b/src/general/7_factory_wrap/nan/binding.gyp similarity index 100% rename from general/7_factory_wrap/nan/binding.gyp rename to src/general/7_factory_wrap/nan/binding.gyp diff --git a/general/7_factory_wrap/nan/myobject.cc b/src/general/7_factory_wrap/nan/myobject.cc similarity index 100% rename from general/7_factory_wrap/nan/myobject.cc rename to src/general/7_factory_wrap/nan/myobject.cc diff --git a/general/7_factory_wrap/nan/myobject.h b/src/general/7_factory_wrap/nan/myobject.h similarity index 100% rename from general/7_factory_wrap/nan/myobject.h rename to src/general/7_factory_wrap/nan/myobject.h diff --git a/general/7_factory_wrap/nan/package.json b/src/general/7_factory_wrap/nan/package.json similarity index 100% rename from general/7_factory_wrap/nan/package.json rename to src/general/7_factory_wrap/nan/package.json diff --git a/general/7_factory_wrap/napi/addon.cc b/src/general/7_factory_wrap/napi/addon.cc similarity index 100% rename from general/7_factory_wrap/napi/addon.cc rename to src/general/7_factory_wrap/napi/addon.cc diff --git a/general/7_factory_wrap/napi/addon.js b/src/general/7_factory_wrap/napi/addon.js similarity index 100% rename from general/7_factory_wrap/napi/addon.js rename to src/general/7_factory_wrap/napi/addon.js diff --git a/general/7_factory_wrap/napi/binding.gyp b/src/general/7_factory_wrap/napi/binding.gyp similarity index 100% rename from general/7_factory_wrap/napi/binding.gyp rename to src/general/7_factory_wrap/napi/binding.gyp diff --git a/general/7_factory_wrap/napi/myobject.cc b/src/general/7_factory_wrap/napi/myobject.cc similarity index 100% rename from general/7_factory_wrap/napi/myobject.cc rename to src/general/7_factory_wrap/napi/myobject.cc diff --git a/general/7_factory_wrap/napi/myobject.h b/src/general/7_factory_wrap/napi/myobject.h similarity index 100% rename from general/7_factory_wrap/napi/myobject.h rename to src/general/7_factory_wrap/napi/myobject.h diff --git a/general/7_factory_wrap/napi/package.json b/src/general/7_factory_wrap/napi/package.json similarity index 100% rename from general/7_factory_wrap/napi/package.json rename to src/general/7_factory_wrap/napi/package.json diff --git a/general/7_factory_wrap/node-addon-api/addon.cc b/src/general/7_factory_wrap/node-addon-api/addon.cc similarity index 100% rename from general/7_factory_wrap/node-addon-api/addon.cc rename to src/general/7_factory_wrap/node-addon-api/addon.cc diff --git a/general/7_factory_wrap/node-addon-api/addon.js b/src/general/7_factory_wrap/node-addon-api/addon.js similarity index 100% rename from general/7_factory_wrap/node-addon-api/addon.js rename to src/general/7_factory_wrap/node-addon-api/addon.js diff --git a/general/7_factory_wrap/node-addon-api/binding.gyp b/src/general/7_factory_wrap/node-addon-api/binding.gyp similarity index 100% rename from general/7_factory_wrap/node-addon-api/binding.gyp rename to src/general/7_factory_wrap/node-addon-api/binding.gyp diff --git a/general/7_factory_wrap/node-addon-api/myobject.cc b/src/general/7_factory_wrap/node-addon-api/myobject.cc similarity index 100% rename from general/7_factory_wrap/node-addon-api/myobject.cc rename to src/general/7_factory_wrap/node-addon-api/myobject.cc diff --git a/general/7_factory_wrap/node-addon-api/myobject.h b/src/general/7_factory_wrap/node-addon-api/myobject.h similarity index 100% rename from general/7_factory_wrap/node-addon-api/myobject.h rename to src/general/7_factory_wrap/node-addon-api/myobject.h diff --git a/general/7_factory_wrap/node-addon-api/package.json b/src/general/7_factory_wrap/node-addon-api/package.json similarity index 100% rename from general/7_factory_wrap/node-addon-api/package.json rename to src/general/7_factory_wrap/node-addon-api/package.json diff --git a/general/a-first-project/node-addon-api/README.md b/src/general/a-first-project/node-addon-api/README.md similarity index 100% rename from general/a-first-project/node-addon-api/README.md rename to src/general/a-first-project/node-addon-api/README.md diff --git a/general/a-first-project/node-addon-api/binding.gyp b/src/general/a-first-project/node-addon-api/binding.gyp similarity index 100% rename from general/a-first-project/node-addon-api/binding.gyp rename to src/general/a-first-project/node-addon-api/binding.gyp diff --git a/general/a-first-project/node-addon-api/lib/binding.js b/src/general/a-first-project/node-addon-api/lib/binding.js similarity index 100% rename from general/a-first-project/node-addon-api/lib/binding.js rename to src/general/a-first-project/node-addon-api/lib/binding.js diff --git a/general/a-first-project/node-addon-api/package.json b/src/general/a-first-project/node-addon-api/package.json similarity index 100% rename from general/a-first-project/node-addon-api/package.json rename to src/general/a-first-project/node-addon-api/package.json diff --git a/general/a-first-project/node-addon-api/src/hello_world.cc b/src/general/a-first-project/node-addon-api/src/hello_world.cc similarity index 100% rename from general/a-first-project/node-addon-api/src/hello_world.cc rename to src/general/a-first-project/node-addon-api/src/hello_world.cc diff --git a/general/a-first-project/node-addon-api/test/test_binding.js b/src/general/a-first-project/node-addon-api/test/test_binding.js similarity index 100% rename from general/a-first-project/node-addon-api/test/test_binding.js rename to src/general/a-first-project/node-addon-api/test/test_binding.js diff --git a/js-to-native-conversion/8_passing_wrapped/nan/addon.cc b/src/js-to-native-conversion/8_passing_wrapped/nan/addon.cc similarity index 100% rename from js-to-native-conversion/8_passing_wrapped/nan/addon.cc rename to src/js-to-native-conversion/8_passing_wrapped/nan/addon.cc diff --git a/js-to-native-conversion/8_passing_wrapped/nan/addon.js b/src/js-to-native-conversion/8_passing_wrapped/nan/addon.js similarity index 100% rename from js-to-native-conversion/8_passing_wrapped/nan/addon.js rename to src/js-to-native-conversion/8_passing_wrapped/nan/addon.js diff --git a/js-to-native-conversion/8_passing_wrapped/nan/binding.gyp b/src/js-to-native-conversion/8_passing_wrapped/nan/binding.gyp similarity index 100% rename from js-to-native-conversion/8_passing_wrapped/nan/binding.gyp rename to src/js-to-native-conversion/8_passing_wrapped/nan/binding.gyp diff --git a/js-to-native-conversion/8_passing_wrapped/nan/myobject.cc b/src/js-to-native-conversion/8_passing_wrapped/nan/myobject.cc similarity index 100% rename from js-to-native-conversion/8_passing_wrapped/nan/myobject.cc rename to src/js-to-native-conversion/8_passing_wrapped/nan/myobject.cc diff --git a/js-to-native-conversion/8_passing_wrapped/nan/myobject.h b/src/js-to-native-conversion/8_passing_wrapped/nan/myobject.h similarity index 100% rename from js-to-native-conversion/8_passing_wrapped/nan/myobject.h rename to src/js-to-native-conversion/8_passing_wrapped/nan/myobject.h diff --git a/js-to-native-conversion/8_passing_wrapped/nan/package.json b/src/js-to-native-conversion/8_passing_wrapped/nan/package.json similarity index 100% rename from js-to-native-conversion/8_passing_wrapped/nan/package.json rename to src/js-to-native-conversion/8_passing_wrapped/nan/package.json diff --git a/js-to-native-conversion/8_passing_wrapped/napi/addon.cc b/src/js-to-native-conversion/8_passing_wrapped/napi/addon.cc similarity index 100% rename from js-to-native-conversion/8_passing_wrapped/napi/addon.cc rename to src/js-to-native-conversion/8_passing_wrapped/napi/addon.cc diff --git a/js-to-native-conversion/8_passing_wrapped/napi/addon.js b/src/js-to-native-conversion/8_passing_wrapped/napi/addon.js similarity index 100% rename from js-to-native-conversion/8_passing_wrapped/napi/addon.js rename to src/js-to-native-conversion/8_passing_wrapped/napi/addon.js diff --git a/js-to-native-conversion/8_passing_wrapped/napi/binding.gyp b/src/js-to-native-conversion/8_passing_wrapped/napi/binding.gyp similarity index 100% rename from js-to-native-conversion/8_passing_wrapped/napi/binding.gyp rename to src/js-to-native-conversion/8_passing_wrapped/napi/binding.gyp diff --git a/js-to-native-conversion/8_passing_wrapped/napi/myobject.cc b/src/js-to-native-conversion/8_passing_wrapped/napi/myobject.cc similarity index 100% rename from js-to-native-conversion/8_passing_wrapped/napi/myobject.cc rename to src/js-to-native-conversion/8_passing_wrapped/napi/myobject.cc diff --git a/js-to-native-conversion/8_passing_wrapped/napi/myobject.h b/src/js-to-native-conversion/8_passing_wrapped/napi/myobject.h similarity index 100% rename from js-to-native-conversion/8_passing_wrapped/napi/myobject.h rename to src/js-to-native-conversion/8_passing_wrapped/napi/myobject.h diff --git a/js-to-native-conversion/8_passing_wrapped/napi/package.json b/src/js-to-native-conversion/8_passing_wrapped/napi/package.json similarity index 100% rename from js-to-native-conversion/8_passing_wrapped/napi/package.json rename to src/js-to-native-conversion/8_passing_wrapped/napi/package.json diff --git a/js-to-native-conversion/8_passing_wrapped/node-addon-api/addon.cc b/src/js-to-native-conversion/8_passing_wrapped/node-addon-api/addon.cc similarity index 100% rename from js-to-native-conversion/8_passing_wrapped/node-addon-api/addon.cc rename to src/js-to-native-conversion/8_passing_wrapped/node-addon-api/addon.cc diff --git a/js-to-native-conversion/8_passing_wrapped/node-addon-api/addon.js b/src/js-to-native-conversion/8_passing_wrapped/node-addon-api/addon.js similarity index 100% rename from js-to-native-conversion/8_passing_wrapped/node-addon-api/addon.js rename to src/js-to-native-conversion/8_passing_wrapped/node-addon-api/addon.js diff --git a/js-to-native-conversion/8_passing_wrapped/node-addon-api/binding.gyp b/src/js-to-native-conversion/8_passing_wrapped/node-addon-api/binding.gyp similarity index 100% rename from js-to-native-conversion/8_passing_wrapped/node-addon-api/binding.gyp rename to src/js-to-native-conversion/8_passing_wrapped/node-addon-api/binding.gyp diff --git a/js-to-native-conversion/8_passing_wrapped/node-addon-api/myobject.cc b/src/js-to-native-conversion/8_passing_wrapped/node-addon-api/myobject.cc similarity index 73% rename from js-to-native-conversion/8_passing_wrapped/node-addon-api/myobject.cc rename to src/js-to-native-conversion/8_passing_wrapped/node-addon-api/myobject.cc index 02254e13..7083269c 100644 --- a/js-to-native-conversion/8_passing_wrapped/node-addon-api/myobject.cc +++ b/src/js-to-native-conversion/8_passing_wrapped/node-addon-api/myobject.cc @@ -12,8 +12,9 @@ void MyObject::Init(Napi::Env env, Napi::Object exports) { Napi::FunctionReference* constructor = new Napi::FunctionReference(); *constructor = Napi::Persistent(func); - env.SetInstanceData(constructor); //NOTE: this assumes only 1 class is exported - //for multiple exported classes, need a struct or other mechanism + env.SetInstanceData(constructor); // NOTE: this assumes only 1 class is + // exported for multiple exported classes, + // need a struct or other mechanism exports.Set("MyObject", func); } diff --git a/js-to-native-conversion/8_passing_wrapped/node-addon-api/myobject.h b/src/js-to-native-conversion/8_passing_wrapped/node-addon-api/myobject.h similarity index 100% rename from js-to-native-conversion/8_passing_wrapped/node-addon-api/myobject.h rename to src/js-to-native-conversion/8_passing_wrapped/node-addon-api/myobject.h diff --git a/js-to-native-conversion/8_passing_wrapped/node-addon-api/package.json b/src/js-to-native-conversion/8_passing_wrapped/node-addon-api/package.json similarity index 100% rename from js-to-native-conversion/8_passing_wrapped/node-addon-api/package.json rename to src/js-to-native-conversion/8_passing_wrapped/node-addon-api/package.json diff --git a/js-to-native-conversion/array_buffer_to_native/node-addon-api/array_buffer_to_native.cc b/src/js-to-native-conversion/array_buffer_to_native/node-addon-api/array_buffer_to_native.cc similarity index 100% rename from js-to-native-conversion/array_buffer_to_native/node-addon-api/array_buffer_to_native.cc rename to src/js-to-native-conversion/array_buffer_to_native/node-addon-api/array_buffer_to_native.cc diff --git a/js-to-native-conversion/array_buffer_to_native/node-addon-api/binding.gyp b/src/js-to-native-conversion/array_buffer_to_native/node-addon-api/binding.gyp similarity index 100% rename from js-to-native-conversion/array_buffer_to_native/node-addon-api/binding.gyp rename to src/js-to-native-conversion/array_buffer_to_native/node-addon-api/binding.gyp diff --git a/js-to-native-conversion/array_buffer_to_native/node-addon-api/index.js b/src/js-to-native-conversion/array_buffer_to_native/node-addon-api/index.js similarity index 100% rename from js-to-native-conversion/array_buffer_to_native/node-addon-api/index.js rename to src/js-to-native-conversion/array_buffer_to_native/node-addon-api/index.js diff --git a/js-to-native-conversion/array_buffer_to_native/node-addon-api/package.json b/src/js-to-native-conversion/array_buffer_to_native/node-addon-api/package.json similarity index 100% rename from js-to-native-conversion/array_buffer_to_native/node-addon-api/package.json rename to src/js-to-native-conversion/array_buffer_to_native/node-addon-api/package.json diff --git a/js-to-native-conversion/object-template-demo/README.md b/src/js-to-native-conversion/object-template-demo/README.md similarity index 100% rename from js-to-native-conversion/object-template-demo/README.md rename to src/js-to-native-conversion/object-template-demo/README.md diff --git a/js-to-native-conversion/object-template-demo/nan/binding.gyp b/src/js-to-native-conversion/object-template-demo/nan/binding.gyp similarity index 100% rename from js-to-native-conversion/object-template-demo/nan/binding.gyp rename to src/js-to-native-conversion/object-template-demo/nan/binding.gyp diff --git a/js-to-native-conversion/object-template-demo/nan/index.js b/src/js-to-native-conversion/object-template-demo/nan/index.js similarity index 100% rename from js-to-native-conversion/object-template-demo/nan/index.js rename to src/js-to-native-conversion/object-template-demo/nan/index.js diff --git a/js-to-native-conversion/object-template-demo/nan/object-template-demo.cc b/src/js-to-native-conversion/object-template-demo/nan/object-template-demo.cc similarity index 73% rename from js-to-native-conversion/object-template-demo/nan/object-template-demo.cc rename to src/js-to-native-conversion/object-template-demo/nan/object-template-demo.cc index 8ab5f47d..d8ee11b2 100644 --- a/js-to-native-conversion/object-template-demo/nan/object-template-demo.cc +++ b/src/js-to-native-conversion/object-template-demo/nan/object-template-demo.cc @@ -15,9 +15,9 @@ class NamedInterceptor : public ObjectWrap { char buf[256]; public: - NamedInterceptor() { std::strncpy(this->buf, "foo", sizeof (this->buf)); } + NamedInterceptor() { std::strncpy(this->buf, "foo", sizeof(this->buf)); } static NAN_MODULE_INIT(Init); - static v8::Local NewInstance (); + static v8::Local NewInstance(); static NAN_METHOD(New); static NAN_PROPERTY_GETTER(PropertyGetter); @@ -35,33 +35,32 @@ NAN_METHOD(CreateNew) { NAN_MODULE_INIT(NamedInterceptor::Init) { v8::Local tpl = - Nan::New(NamedInterceptor::New); + Nan::New(NamedInterceptor::New); namedinterceptors_constructor.Reset(tpl); tpl->SetClassName(Nan::New("NamedInterceptor").ToLocalChecked()); tpl->InstanceTemplate()->SetInternalFieldCount(1); v8::Local inst = tpl->InstanceTemplate(); - SetNamedPropertyHandler( - inst - , NamedInterceptor::PropertyGetter - , NamedInterceptor::PropertySetter - , NamedInterceptor::PropertyQuery - , NamedInterceptor::PropertyDeleter - , NamedInterceptor::PropertyEnumerator); + SetNamedPropertyHandler(inst, + NamedInterceptor::PropertyGetter, + NamedInterceptor::PropertySetter, + NamedInterceptor::PropertyQuery, + NamedInterceptor::PropertyDeleter, + NamedInterceptor::PropertyEnumerator); v8::Local createnew = - Nan::GetFunction(Nan::New(CreateNew)) - .ToLocalChecked(); + Nan::GetFunction(Nan::New(CreateNew)) + .ToLocalChecked(); Set(target, Nan::New("create").ToLocalChecked(), createnew); } -v8::Local NamedInterceptor::NewInstance () { +v8::Local NamedInterceptor::NewInstance() { EscapableHandleScope scope; v8::Local constructorHandle = Nan::New(namedinterceptors_constructor); v8::Local instance = - Nan::NewInstance(GetFunction(constructorHandle).ToLocalChecked()) - .ToLocalChecked(); + Nan::NewInstance(GetFunction(constructorHandle).ToLocalChecked()) + .ToLocalChecked(); return scope.Escape(instance); } @@ -71,10 +70,9 @@ NAN_METHOD(NamedInterceptor::New) { info.GetReturnValue().Set(info.This()); } - NAN_PROPERTY_GETTER(NamedInterceptor::PropertyGetter) { NamedInterceptor* interceptor = - ObjectWrap::Unwrap(info.Holder()); + ObjectWrap::Unwrap(info.Holder()); if (!std::strcmp(*Nan::Utf8String(property), "prop")) { info.GetReturnValue().Set(Nan::New(interceptor->buf).ToLocalChecked()); } else { @@ -84,12 +82,10 @@ NAN_PROPERTY_GETTER(NamedInterceptor::PropertyGetter) { NAN_PROPERTY_SETTER(NamedInterceptor::PropertySetter) { NamedInterceptor* interceptor = - ObjectWrap::Unwrap(info.Holder()); + ObjectWrap::Unwrap(info.Holder()); if (!std::strcmp(*Nan::Utf8String(property), "prop")) { std::strncpy( - interceptor->buf - , *Nan::Utf8String(value) - , sizeof (interceptor->buf)); + interceptor->buf, *Nan::Utf8String(value), sizeof(interceptor->buf)); info.GetReturnValue().Set(info.This()); } else { info.GetReturnValue().Set(info.This()); @@ -104,8 +100,8 @@ NAN_PROPERTY_ENUMERATOR(NamedInterceptor::PropertyEnumerator) { NAN_PROPERTY_DELETER(NamedInterceptor::PropertyDeleter) { NamedInterceptor* interceptor = - ObjectWrap::Unwrap(info.Holder()); - std::strncpy(interceptor->buf, "goober", sizeof (interceptor->buf)); + ObjectWrap::Unwrap(info.Holder()); + std::strncpy(interceptor->buf, "goober", sizeof(interceptor->buf)); info.GetReturnValue().Set(True()); } diff --git a/js-to-native-conversion/object-template-demo/nan/package.json b/src/js-to-native-conversion/object-template-demo/nan/package.json similarity index 100% rename from js-to-native-conversion/object-template-demo/nan/package.json rename to src/js-to-native-conversion/object-template-demo/nan/package.json diff --git a/js-to-native-conversion/object-template-demo/napi/binding.gyp b/src/js-to-native-conversion/object-template-demo/napi/binding.gyp similarity index 100% rename from js-to-native-conversion/object-template-demo/napi/binding.gyp rename to src/js-to-native-conversion/object-template-demo/napi/binding.gyp diff --git a/js-to-native-conversion/object-template-demo/napi/index.js b/src/js-to-native-conversion/object-template-demo/napi/index.js similarity index 100% rename from js-to-native-conversion/object-template-demo/napi/index.js rename to src/js-to-native-conversion/object-template-demo/napi/index.js diff --git a/js-to-native-conversion/object-template-demo/napi/node-api-common.h b/src/js-to-native-conversion/object-template-demo/napi/node-api-common.h similarity index 100% rename from js-to-native-conversion/object-template-demo/napi/node-api-common.h rename to src/js-to-native-conversion/object-template-demo/napi/node-api-common.h diff --git a/js-to-native-conversion/object-template-demo/napi/object-template-demo.cc b/src/js-to-native-conversion/object-template-demo/napi/object-template-demo.cc similarity index 100% rename from js-to-native-conversion/object-template-demo/napi/object-template-demo.cc rename to src/js-to-native-conversion/object-template-demo/napi/object-template-demo.cc index 6846e1fc..5b049202 100644 --- a/js-to-native-conversion/object-template-demo/napi/object-template-demo.cc +++ b/src/js-to-native-conversion/object-template-demo/napi/object-template-demo.cc @@ -1,5 +1,5 @@ -#include #include +#include #include #include "proxy-template.h" diff --git a/js-to-native-conversion/object-template-demo/napi/package.json b/src/js-to-native-conversion/object-template-demo/napi/package.json similarity index 100% rename from js-to-native-conversion/object-template-demo/napi/package.json rename to src/js-to-native-conversion/object-template-demo/napi/package.json diff --git a/js-to-native-conversion/object-template-demo/napi/proxy-template.cc b/src/js-to-native-conversion/object-template-demo/napi/proxy-template.cc similarity index 100% rename from js-to-native-conversion/object-template-demo/napi/proxy-template.cc rename to src/js-to-native-conversion/object-template-demo/napi/proxy-template.cc diff --git a/js-to-native-conversion/object-template-demo/napi/proxy-template.h b/src/js-to-native-conversion/object-template-demo/napi/proxy-template.h similarity index 100% rename from js-to-native-conversion/object-template-demo/napi/proxy-template.h rename to src/js-to-native-conversion/object-template-demo/napi/proxy-template.h diff --git a/js-to-native-conversion/object-wrap-demo/node-addon-api/README.md b/src/js-to-native-conversion/object-wrap-demo/node-addon-api/README.md similarity index 100% rename from js-to-native-conversion/object-wrap-demo/node-addon-api/README.md rename to src/js-to-native-conversion/object-wrap-demo/node-addon-api/README.md diff --git a/js-to-native-conversion/object-wrap-demo/node-addon-api/binding.gyp b/src/js-to-native-conversion/object-wrap-demo/node-addon-api/binding.gyp similarity index 100% rename from js-to-native-conversion/object-wrap-demo/node-addon-api/binding.gyp rename to src/js-to-native-conversion/object-wrap-demo/node-addon-api/binding.gyp diff --git a/js-to-native-conversion/object-wrap-demo/node-addon-api/lib/binding.js b/src/js-to-native-conversion/object-wrap-demo/node-addon-api/lib/binding.js similarity index 100% rename from js-to-native-conversion/object-wrap-demo/node-addon-api/lib/binding.js rename to src/js-to-native-conversion/object-wrap-demo/node-addon-api/lib/binding.js diff --git a/js-to-native-conversion/object-wrap-demo/node-addon-api/package.json b/src/js-to-native-conversion/object-wrap-demo/node-addon-api/package.json similarity index 100% rename from js-to-native-conversion/object-wrap-demo/node-addon-api/package.json rename to src/js-to-native-conversion/object-wrap-demo/node-addon-api/package.json diff --git a/js-to-native-conversion/object-wrap-demo/node-addon-api/src/object_wrap_demo.cc b/src/js-to-native-conversion/object-wrap-demo/node-addon-api/src/object_wrap_demo.cc similarity index 100% rename from js-to-native-conversion/object-wrap-demo/node-addon-api/src/object_wrap_demo.cc rename to src/js-to-native-conversion/object-wrap-demo/node-addon-api/src/object_wrap_demo.cc diff --git a/js-to-native-conversion/object-wrap-demo/node-addon-api/src/object_wrap_demo.h b/src/js-to-native-conversion/object-wrap-demo/node-addon-api/src/object_wrap_demo.h similarity index 100% rename from js-to-native-conversion/object-wrap-demo/node-addon-api/src/object_wrap_demo.h rename to src/js-to-native-conversion/object-wrap-demo/node-addon-api/src/object_wrap_demo.h diff --git a/js-to-native-conversion/object-wrap-demo/node-addon-api/test/test_binding.js b/src/js-to-native-conversion/object-wrap-demo/node-addon-api/test/test_binding.js similarity index 100% rename from js-to-native-conversion/object-wrap-demo/node-addon-api/test/test_binding.js rename to src/js-to-native-conversion/object-wrap-demo/node-addon-api/test/test_binding.js diff --git a/js-to-native-conversion/typed_array_to_native/node-addon-api/binding.gyp b/src/js-to-native-conversion/typed_array_to_native/node-addon-api/binding.gyp similarity index 100% rename from js-to-native-conversion/typed_array_to_native/node-addon-api/binding.gyp rename to src/js-to-native-conversion/typed_array_to_native/node-addon-api/binding.gyp diff --git a/js-to-native-conversion/typed_array_to_native/node-addon-api/index.js b/src/js-to-native-conversion/typed_array_to_native/node-addon-api/index.js similarity index 100% rename from js-to-native-conversion/typed_array_to_native/node-addon-api/index.js rename to src/js-to-native-conversion/typed_array_to_native/node-addon-api/index.js diff --git a/js-to-native-conversion/typed_array_to_native/node-addon-api/package.json b/src/js-to-native-conversion/typed_array_to_native/node-addon-api/package.json similarity index 100% rename from js-to-native-conversion/typed_array_to_native/node-addon-api/package.json rename to src/js-to-native-conversion/typed_array_to_native/node-addon-api/package.json diff --git a/js-to-native-conversion/typed_array_to_native/node-addon-api/typed_array_to_native.cc b/src/js-to-native-conversion/typed_array_to_native/node-addon-api/typed_array_to_native.cc similarity index 97% rename from js-to-native-conversion/typed_array_to_native/node-addon-api/typed_array_to_native.cc rename to src/js-to-native-conversion/typed_array_to_native/node-addon-api/typed_array_to_native.cc index d46cbf47..f82b5776 100644 --- a/js-to-native-conversion/typed_array_to_native/node-addon-api/typed_array_to_native.cc +++ b/src/js-to-native-conversion/typed_array_to_native/node-addon-api/typed_array_to_native.cc @@ -94,8 +94,9 @@ static Napi::Value CreateByteArray(const Napi::CallbackInfo& info) { // unique_ptr ownership. nativeArray.release(); - Napi::Uint8Array byteArray = Napi::Uint8Array::New(info.Env(), arrayLength, arrayBuffer, 0); - + Napi::Uint8Array byteArray = + Napi::Uint8Array::New(info.Env(), arrayLength, arrayBuffer, 0); + return byteArray; } diff --git a/references-and-handle-scope/function-reference-demo/node-addon-api/binding.gyp b/src/references-and-handle-scope/function-reference-demo/node-addon-api/binding.gyp similarity index 100% rename from references-and-handle-scope/function-reference-demo/node-addon-api/binding.gyp rename to src/references-and-handle-scope/function-reference-demo/node-addon-api/binding.gyp diff --git a/references-and-handle-scope/function-reference-demo/node-addon-api/index.js b/src/references-and-handle-scope/function-reference-demo/node-addon-api/index.js similarity index 100% rename from references-and-handle-scope/function-reference-demo/node-addon-api/index.js rename to src/references-and-handle-scope/function-reference-demo/node-addon-api/index.js diff --git a/references-and-handle-scope/function-reference-demo/node-addon-api/package.json b/src/references-and-handle-scope/function-reference-demo/node-addon-api/package.json similarity index 100% rename from references-and-handle-scope/function-reference-demo/node-addon-api/package.json rename to src/references-and-handle-scope/function-reference-demo/node-addon-api/package.json diff --git a/references-and-handle-scope/function-reference-demo/node-addon-api/src/binding.cc b/src/references-and-handle-scope/function-reference-demo/node-addon-api/src/binding.cc similarity index 100% rename from references-and-handle-scope/function-reference-demo/node-addon-api/src/binding.cc rename to src/references-and-handle-scope/function-reference-demo/node-addon-api/src/binding.cc diff --git a/references-and-handle-scope/function-reference-demo/node-addon-api/src/native-addon.cc b/src/references-and-handle-scope/function-reference-demo/node-addon-api/src/native-addon.cc similarity index 100% rename from references-and-handle-scope/function-reference-demo/node-addon-api/src/native-addon.cc rename to src/references-and-handle-scope/function-reference-demo/node-addon-api/src/native-addon.cc diff --git a/references-and-handle-scope/function-reference-demo/node-addon-api/src/native-addon.h b/src/references-and-handle-scope/function-reference-demo/node-addon-api/src/native-addon.h similarity index 100% rename from references-and-handle-scope/function-reference-demo/node-addon-api/src/native-addon.h rename to src/references-and-handle-scope/function-reference-demo/node-addon-api/src/native-addon.h diff --git a/threadsafe-function/promise-callback-demo/node-addon-api/README.md b/src/threadsafe-function/promise-callback-demo/node-addon-api/README.md similarity index 100% rename from threadsafe-function/promise-callback-demo/node-addon-api/README.md rename to src/threadsafe-function/promise-callback-demo/node-addon-api/README.md diff --git a/threadsafe-function/promise-callback-demo/node-addon-api/binding.gyp b/src/threadsafe-function/promise-callback-demo/node-addon-api/binding.gyp similarity index 100% rename from threadsafe-function/promise-callback-demo/node-addon-api/binding.gyp rename to src/threadsafe-function/promise-callback-demo/node-addon-api/binding.gyp diff --git a/threadsafe-function/promise-callback-demo/node-addon-api/package.json b/src/threadsafe-function/promise-callback-demo/node-addon-api/package.json similarity index 100% rename from threadsafe-function/promise-callback-demo/node-addon-api/package.json rename to src/threadsafe-function/promise-callback-demo/node-addon-api/package.json diff --git a/threadsafe-function/promise-callback-demo/node-addon-api/src/promise_callback_demo.cc b/src/threadsafe-function/promise-callback-demo/node-addon-api/src/promise_callback_demo.cc similarity index 100% rename from threadsafe-function/promise-callback-demo/node-addon-api/src/promise_callback_demo.cc rename to src/threadsafe-function/promise-callback-demo/node-addon-api/src/promise_callback_demo.cc diff --git a/threadsafe-function/promise-callback-demo/node-addon-api/test/index.js b/src/threadsafe-function/promise-callback-demo/node-addon-api/test/index.js similarity index 100% rename from threadsafe-function/promise-callback-demo/node-addon-api/test/index.js rename to src/threadsafe-function/promise-callback-demo/node-addon-api/test/index.js diff --git a/threadsafe-function/thread_safe_function_counting/node-addon-api/addon.cc b/src/threadsafe-function/thread_safe_function_counting/node-addon-api/addon.cc similarity index 100% rename from threadsafe-function/thread_safe_function_counting/node-addon-api/addon.cc rename to src/threadsafe-function/thread_safe_function_counting/node-addon-api/addon.cc diff --git a/threadsafe-function/thread_safe_function_counting/node-addon-api/addon.js b/src/threadsafe-function/thread_safe_function_counting/node-addon-api/addon.js similarity index 100% rename from threadsafe-function/thread_safe_function_counting/node-addon-api/addon.js rename to src/threadsafe-function/thread_safe_function_counting/node-addon-api/addon.js diff --git a/threadsafe-function/thread_safe_function_counting/node-addon-api/binding.gyp b/src/threadsafe-function/thread_safe_function_counting/node-addon-api/binding.gyp similarity index 100% rename from threadsafe-function/thread_safe_function_counting/node-addon-api/binding.gyp rename to src/threadsafe-function/thread_safe_function_counting/node-addon-api/binding.gyp diff --git a/threadsafe-function/thread_safe_function_counting/node-addon-api/package.json b/src/threadsafe-function/thread_safe_function_counting/node-addon-api/package.json similarity index 100% rename from threadsafe-function/thread_safe_function_counting/node-addon-api/package.json rename to src/threadsafe-function/thread_safe_function_counting/node-addon-api/package.json diff --git a/threadsafe-function/thread_safe_function_round_trip/napi/binding.gyp b/src/threadsafe-function/thread_safe_function_round_trip/napi/binding.gyp similarity index 100% rename from threadsafe-function/thread_safe_function_round_trip/napi/binding.gyp rename to src/threadsafe-function/thread_safe_function_round_trip/napi/binding.gyp diff --git a/threadsafe-function/thread_safe_function_round_trip/napi/index.js b/src/threadsafe-function/thread_safe_function_round_trip/napi/index.js similarity index 100% rename from threadsafe-function/thread_safe_function_round_trip/napi/index.js rename to src/threadsafe-function/thread_safe_function_round_trip/napi/index.js diff --git a/threadsafe-function/thread_safe_function_round_trip/napi/package.json b/src/threadsafe-function/thread_safe_function_round_trip/napi/package.json similarity index 100% rename from threadsafe-function/thread_safe_function_round_trip/napi/package.json rename to src/threadsafe-function/thread_safe_function_round_trip/napi/package.json diff --git a/threadsafe-function/thread_safe_function_round_trip/napi/round_trip.c b/src/threadsafe-function/thread_safe_function_round_trip/napi/round_trip.c similarity index 100% rename from threadsafe-function/thread_safe_function_round_trip/napi/round_trip.c rename to src/threadsafe-function/thread_safe_function_round_trip/napi/round_trip.c diff --git a/threadsafe-function/thread_safe_function_with_object_wrap/node-addon-api/binding.gyp b/src/threadsafe-function/thread_safe_function_with_object_wrap/node-addon-api/binding.gyp similarity index 100% rename from threadsafe-function/thread_safe_function_with_object_wrap/node-addon-api/binding.gyp rename to src/threadsafe-function/thread_safe_function_with_object_wrap/node-addon-api/binding.gyp diff --git a/threadsafe-function/thread_safe_function_with_object_wrap/node-addon-api/package.json b/src/threadsafe-function/thread_safe_function_with_object_wrap/node-addon-api/package.json similarity index 100% rename from threadsafe-function/thread_safe_function_with_object_wrap/node-addon-api/package.json rename to src/threadsafe-function/thread_safe_function_with_object_wrap/node-addon-api/package.json diff --git a/threadsafe-function/thread_safe_function_with_object_wrap/node-addon-api/tsfn_object_wrap.cc b/src/threadsafe-function/thread_safe_function_with_object_wrap/node-addon-api/tsfn_object_wrap.cc similarity index 100% rename from threadsafe-function/thread_safe_function_with_object_wrap/node-addon-api/tsfn_object_wrap.cc rename to src/threadsafe-function/thread_safe_function_with_object_wrap/node-addon-api/tsfn_object_wrap.cc diff --git a/threadsafe-function/thread_safe_function_with_object_wrap/node-addon-api/tsfn_object_wrap.js b/src/threadsafe-function/thread_safe_function_with_object_wrap/node-addon-api/tsfn_object_wrap.js similarity index 100% rename from threadsafe-function/thread_safe_function_with_object_wrap/node-addon-api/tsfn_object_wrap.js rename to src/threadsafe-function/thread_safe_function_with_object_wrap/node-addon-api/tsfn_object_wrap.js diff --git a/threadsafe-function/threadsafe-async-iterator/node-addon-api/CMakeLists.txt b/src/threadsafe-function/threadsafe-async-iterator/node-addon-api/CMakeLists.txt similarity index 100% rename from threadsafe-function/threadsafe-async-iterator/node-addon-api/CMakeLists.txt rename to src/threadsafe-function/threadsafe-async-iterator/node-addon-api/CMakeLists.txt diff --git a/threadsafe-function/threadsafe-async-iterator/node-addon-api/example.cc b/src/threadsafe-function/threadsafe-async-iterator/node-addon-api/example.cc similarity index 100% rename from threadsafe-function/threadsafe-async-iterator/node-addon-api/example.cc rename to src/threadsafe-function/threadsafe-async-iterator/node-addon-api/example.cc diff --git a/threadsafe-function/threadsafe-async-iterator/node-addon-api/index.js b/src/threadsafe-function/threadsafe-async-iterator/node-addon-api/index.js similarity index 100% rename from threadsafe-function/threadsafe-async-iterator/node-addon-api/index.js rename to src/threadsafe-function/threadsafe-async-iterator/node-addon-api/index.js diff --git a/threadsafe-function/threadsafe-async-iterator/node-addon-api/package.json b/src/threadsafe-function/threadsafe-async-iterator/node-addon-api/package.json similarity index 100% rename from threadsafe-function/threadsafe-async-iterator/node-addon-api/package.json rename to src/threadsafe-function/threadsafe-async-iterator/node-addon-api/package.json diff --git a/threadsafe-function/typed_threadsafe_function/node-addon-api/CMakeLists.txt b/src/threadsafe-function/typed_threadsafe_function/node-addon-api/CMakeLists.txt similarity index 100% rename from threadsafe-function/typed_threadsafe_function/node-addon-api/CMakeLists.txt rename to src/threadsafe-function/typed_threadsafe_function/node-addon-api/CMakeLists.txt diff --git a/threadsafe-function/typed_threadsafe_function/node-addon-api/clock.cc b/src/threadsafe-function/typed_threadsafe_function/node-addon-api/clock.cc similarity index 72% rename from threadsafe-function/typed_threadsafe_function/node-addon-api/clock.cc rename to src/threadsafe-function/typed_threadsafe_function/node-addon-api/clock.cc index f2af5ee4..2055ea7b 100644 --- a/threadsafe-function/typed_threadsafe_function/node-addon-api/clock.cc +++ b/src/threadsafe-function/typed_threadsafe_function/node-addon-api/clock.cc @@ -1,19 +1,19 @@ -#include #include +#include #include using namespace Napi; using Context = Reference; using DataType = int; -void CallJs(Napi::Env env, Function callback, Context *context, DataType *data); +void CallJs(Napi::Env env, Function callback, Context* context, DataType* data); using TSFN = TypedThreadSafeFunction; using FinalizerDataType = void; std::thread nativeThread; TSFN tsfn; -Value Start(const CallbackInfo &info) { +Value Start(const CallbackInfo& info) { Napi::Env env = info.Env(); if (info.Length() < 2) { @@ -28,18 +28,19 @@ Value Start(const CallbackInfo &info) { // Create a new context set to the the receiver (ie, `this`) of the function // call - Context *context = new Reference(Persistent(info.This())); + Context* context = new Reference(Persistent(info.This())); // Create a ThreadSafeFunction tsfn = TSFN::New( env, - info[0].As(), // JavaScript function called asynchronously - "Resource Name", // Name - 0, // Unlimited queue - 1, // Only one thread will use this initially + info[0].As(), // JavaScript function called asynchronously + "Resource Name", // Name + 0, // Unlimited queue + 1, // Only one thread will use this initially context, - [](Napi::Env, FinalizerDataType *, - Context *ctx) { // Finalizer used to clean threads up + [](Napi::Env, + FinalizerDataType*, + Context* ctx) { // Finalizer used to clean threads up nativeThread.join(); delete ctx; }); @@ -48,7 +49,7 @@ Value Start(const CallbackInfo &info) { nativeThread = std::thread([count] { for (int i = 0; i < count; i++) { // Create new data - int *value = new int(clock()); + int* value = new int(clock()); // Perform a blocking call napi_status status = tsfn.BlockingCall(value); @@ -69,13 +70,15 @@ Value Start(const CallbackInfo &info) { // Transform native data into JS data, passing it to the provided // `callback` -- the TSFN's JavaScript function. -void CallJs(Napi::Env env, Function callback, Context *context, - DataType *data) { +void CallJs(Napi::Env env, + Function callback, + Context* context, + DataType* data) { // Is the JavaScript environment still available to call into, eg. the TSFN is // not aborted if (env != nullptr) { - // On Node-API 5+, the `callback` parameter is optional; however, this example - // does ensure a callback is provided. + // On Node-API 5+, the `callback` parameter is optional; however, this + // example does ensure a callback is provided. if (callback != nullptr) { callback.Call(context->Value(), {Number::New(env, *data)}); } diff --git a/threadsafe-function/typed_threadsafe_function/node-addon-api/index.js b/src/threadsafe-function/typed_threadsafe_function/node-addon-api/index.js similarity index 100% rename from threadsafe-function/typed_threadsafe_function/node-addon-api/index.js rename to src/threadsafe-function/typed_threadsafe_function/node-addon-api/index.js diff --git a/threadsafe-function/typed_threadsafe_function/node-addon-api/package.json b/src/threadsafe-function/typed_threadsafe_function/node-addon-api/package.json similarity index 100% rename from threadsafe-function/typed_threadsafe_function/node-addon-api/package.json rename to src/threadsafe-function/typed_threadsafe_function/node-addon-api/package.json diff --git a/tooling/typescript_with_addon/node-addon-api/CMakeLists.txt b/src/tooling/typescript_with_addon/node-addon-api/CMakeLists.txt similarity index 100% rename from tooling/typescript_with_addon/node-addon-api/CMakeLists.txt rename to src/tooling/typescript_with_addon/node-addon-api/CMakeLists.txt diff --git a/tooling/typescript_with_addon/node-addon-api/README.md b/src/tooling/typescript_with_addon/node-addon-api/README.md similarity index 100% rename from tooling/typescript_with_addon/node-addon-api/README.md rename to src/tooling/typescript_with_addon/node-addon-api/README.md diff --git a/tooling/typescript_with_addon/node-addon-api/cPart.c b/src/tooling/typescript_with_addon/node-addon-api/cPart.c similarity index 100% rename from tooling/typescript_with_addon/node-addon-api/cPart.c rename to src/tooling/typescript_with_addon/node-addon-api/cPart.c diff --git a/tooling/typescript_with_addon/node-addon-api/cPart.h b/src/tooling/typescript_with_addon/node-addon-api/cPart.h similarity index 100% rename from tooling/typescript_with_addon/node-addon-api/cPart.h rename to src/tooling/typescript_with_addon/node-addon-api/cPart.h diff --git a/tooling/typescript_with_addon/node-addon-api/cppPart.cpp b/src/tooling/typescript_with_addon/node-addon-api/cppPart.cpp similarity index 100% rename from tooling/typescript_with_addon/node-addon-api/cppPart.cpp rename to src/tooling/typescript_with_addon/node-addon-api/cppPart.cpp diff --git a/tooling/typescript_with_addon/node-addon-api/index.ts b/src/tooling/typescript_with_addon/node-addon-api/index.ts similarity index 100% rename from tooling/typescript_with_addon/node-addon-api/index.ts rename to src/tooling/typescript_with_addon/node-addon-api/index.ts diff --git a/tooling/typescript_with_addon/node-addon-api/jsPart.js b/src/tooling/typescript_with_addon/node-addon-api/jsPart.js similarity index 100% rename from tooling/typescript_with_addon/node-addon-api/jsPart.js rename to src/tooling/typescript_with_addon/node-addon-api/jsPart.js diff --git a/tooling/typescript_with_addon/node-addon-api/napiPart.cpp b/src/tooling/typescript_with_addon/node-addon-api/napiPart.cpp similarity index 100% rename from tooling/typescript_with_addon/node-addon-api/napiPart.cpp rename to src/tooling/typescript_with_addon/node-addon-api/napiPart.cpp diff --git a/tooling/typescript_with_addon/node-addon-api/package.json b/src/tooling/typescript_with_addon/node-addon-api/package.json similarity index 100% rename from tooling/typescript_with_addon/node-addon-api/package.json rename to src/tooling/typescript_with_addon/node-addon-api/package.json diff --git a/tooling/typescript_with_addon/node-addon-api/tsconfig.json b/src/tooling/typescript_with_addon/node-addon-api/tsconfig.json similarity index 100% rename from tooling/typescript_with_addon/node-addon-api/tsconfig.json rename to src/tooling/typescript_with_addon/node-addon-api/tsconfig.json diff --git a/test_all.js b/test_all.js index 8145534c..81d36e0e 100644 --- a/test_all.js +++ b/test_all.js @@ -5,6 +5,7 @@ const chalk = require("chalk"); const semver = require("semver"); const excludeFolder = ["node_modules", "website"]; +const examplesFolder = path.join(__dirname, "src"); function getAllExamples(pathToCheck) { const directoriesToTest = []; @@ -28,7 +29,7 @@ const passed = []; const failedInstalls = []; const noTest = []; const failedTests = []; -for (directoryToTest of getAllExamples(path.join(__dirname))) { +for (directoryToTest of getAllExamples(examplesFolder)) { console.log(chalk.green(`testing: ${directoryToTest}`)); const pkgJson = require(path.join(directoryToTest, "package.json")); if (pkgJson.engines && pkgJson.engines.node) { diff --git a/tooling/build_with_cmake/README.md b/tooling/build_with_cmake/README.md deleted file mode 100644 index f7d5c18e..00000000 --- a/tooling/build_with_cmake/README.md +++ /dev/null @@ -1,33 +0,0 @@ -## Building Node-API Addons Using CMake.js - -### Examples - -The objective of these examples is to demonstrate how to build Node-API addons using [CMake.js](https://github.com/cmake-js/cmake-js#readme). - -These example projects assume that CMake.js has been installed globally: - -``` -npm install -g cmake-js -cmake-js --help -``` - -Then, in each of the `napi` and `node-addon-api` directories, the following commands build and test each addon: - -``` -npm install -npm test -``` - -Complete CMake.js documentation can be found on the [CMake.js GitHub repository](https://github.com/cmake-js/cmake-js#readme). - -### NAPI_VERSION - -When building Node-API addons, it's important to specify to the build system the Node-API version your code is designed to work with. With CMake.js, this information is specified in the `CMakeLists.txt` file: - -``` -add_definitions(-DNAPI_VERSION=3) -``` - -Since Node-API is ABI-stable, your Node-API addon will work, without recompilation, with the Node-API version you specify in `NAPI_VERSION` and all subsequent Node-API versions. - -In the absence of a need for features available only in a specific Node-API version, version 3 is a good choice as it is the version of Node-API that was active when Node-API left experimental status. \ No newline at end of file diff --git a/tooling/build_with_cmake/napi/CMakeLists.txt b/tooling/build_with_cmake/napi/CMakeLists.txt deleted file mode 100644 index f87b9bb1..00000000 --- a/tooling/build_with_cmake/napi/CMakeLists.txt +++ /dev/null @@ -1,13 +0,0 @@ -cmake_minimum_required(VERSION 3.9) -cmake_policy(SET CMP0042 NEW) -set (CMAKE_CXX_STANDARD 11) - -project (build-napi-with-cmake) -include_directories(${CMAKE_JS_INC}) -file(GLOB SOURCE_FILES "hello.c") -add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC}) -set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node") -target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB}) - -# Define NAPI_VERSION -add_definitions(-DNAPI_VERSION=3) diff --git a/tooling/build_with_cmake/napi/hello.c b/tooling/build_with_cmake/napi/hello.c deleted file mode 100644 index 8ae1eee9..00000000 --- a/tooling/build_with_cmake/napi/hello.c +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -static napi_value Method(napi_env env, napi_callback_info info) { - napi_status status; - napi_value world; - status = napi_create_string_utf8(env, "Hello, world!", 13, &world); - assert(status == napi_ok); - return world; -} - -#define DECLARE_NAPI_METHOD(name, func) \ - { name, 0, func, 0, 0, 0, napi_default, 0 } - -static napi_value Init(napi_env env, napi_value exports) { - napi_status status; - napi_property_descriptor desc = DECLARE_NAPI_METHOD("hello", Method); - status = napi_define_properties(env, exports, 1, &desc); - assert(status == napi_ok); - return exports; -} - -NAPI_MODULE(hello, Init) diff --git a/tooling/build_with_cmake/napi/hello.js b/tooling/build_with_cmake/napi/hello.js deleted file mode 100644 index 5940bf9e..00000000 --- a/tooling/build_with_cmake/napi/hello.js +++ /dev/null @@ -1,3 +0,0 @@ -var addon = require('bindings')('build-napi-with-cmake'); - -console.log(addon.hello()); // 'world' diff --git a/tooling/build_with_cmake/napi/package.json b/tooling/build_with_cmake/napi/package.json deleted file mode 100644 index 10f23730..00000000 --- a/tooling/build_with_cmake/napi/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "build-napi-with-cmake", - "version": "0.0.0", - "description": "Build Node-API native addon with CMake.", - "main": "hello.js", - "private": true, - "dependencies": { - "bindings": "~1.2.1" - }, - "scripts": { - "install": "cmake-js compile", - "test": "node hello.js" - } -} diff --git a/tooling/build_with_cmake/node-addon-api/CMakeLists.txt b/tooling/build_with_cmake/node-addon-api/CMakeLists.txt deleted file mode 100644 index 456d2312..00000000 --- a/tooling/build_with_cmake/node-addon-api/CMakeLists.txt +++ /dev/null @@ -1,22 +0,0 @@ -cmake_minimum_required(VERSION 3.9) -cmake_policy(SET CMP0042 NEW) -set (CMAKE_CXX_STANDARD 11) - -project (build-node-addon-api-with-cmake) -include_directories(${CMAKE_JS_INC}) -file(GLOB SOURCE_FILES "hello.cc") -add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC}) -set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node") -target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB}) - -# Include Node-API wrappers -execute_process(COMMAND node -p "require('node-addon-api').include" - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - OUTPUT_VARIABLE NODE_ADDON_API_DIR - ) -string(REGEX REPLACE "[\r\n\"]" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR}) - -target_include_directories(${PROJECT_NAME} PRIVATE ${NODE_ADDON_API_DIR}) - -# define NAPI_VERSION -add_definitions(-DNAPI_VERSION=3) diff --git a/tooling/build_with_cmake/node-addon-api/hello.cc b/tooling/build_with_cmake/node-addon-api/hello.cc deleted file mode 100644 index 1c422da3..00000000 --- a/tooling/build_with_cmake/node-addon-api/hello.cc +++ /dev/null @@ -1,23 +0,0 @@ -#include - -static Napi::String Method(const Napi::CallbackInfo& info) { - // Napi::Env is the opaque data structure containing the environment in which - // the request is being run. We will need this env when we want to create any - // new objects inside of the node.js environment - Napi::Env env = info.Env(); - - // Create a C++ level variable - std::string helloWorld = "Hello, world!"; - - // Return a new javascript string that we copy-construct inside of the node.js - // environment - return Napi::String::New(env, helloWorld); -} - -static Napi::Object Init(Napi::Env env, Napi::Object exports) { - exports.Set(Napi::String::New(env, "hello"), - Napi::Function::New(env, Method)); - return exports; -} - -NODE_API_MODULE(hello, Init) diff --git a/tooling/build_with_cmake/node-addon-api/hello.js b/tooling/build_with_cmake/node-addon-api/hello.js deleted file mode 100644 index 7edb5d3e..00000000 --- a/tooling/build_with_cmake/node-addon-api/hello.js +++ /dev/null @@ -1,3 +0,0 @@ -var addon = require('bindings')('build-node-addon-api-with-cmake'); - -console.log(addon.hello()); // 'world' diff --git a/tooling/build_with_cmake/node-addon-api/package.json b/tooling/build_with_cmake/node-addon-api/package.json deleted file mode 100644 index 6aedf0d0..00000000 --- a/tooling/build_with_cmake/node-addon-api/package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "name": "build-node-addon-api-with-cmake", - "version": "0.0.0", - "description": "Build Node-API native addon with CMake and node-addon-api C++ wrapper.", - "main": "hello.js", - "private": true, - "dependencies": { - "bindings": "~1.2.1", - "node-addon-api": "^1.0.0" - }, - "scripts": { - "install": "cmake-js compile", - "test": "node hello.js" - } -}