231103.1 · 7f4a9ed91bbecb84e39f4bc8030247ce5116ddf8
Reorganize examples into categorized folders (#341)
* refactor: create directory structure to organize exmaples
* test: update test_all to work with new directory structure
* fix: bug in test_all if no package.json scripts
* test: cleanup output of test_all
* fix: remove default test script that throws from thread_safe_function_with_object_wrap
* fix: remove build_with_cmake from .gitignore
* fix: swith to ' from " and remove subdir from getAllTests call
* test: add extra test cases for npm start and just running the pkgJson.main with node
* refactor: move all examples to src directory
* refactor: add numbers to categories so they are ordered in the src folder
* refactor: simplify getAllExamples in test_all.js
* docs: add directory structure to README.md
* docs: update directory structure to README.md
* docs: update directory structure to README.md
* docs: update directory structure to README.md
* docs: update directory structure example in readme
* add back build_with_cmake
---------
Co-authored-by: legendecas <legendecas@gmail.com>
reading declarations
Changes to src/1-getting-started/2_function_arguments/nan/addon.cc. All files
src/1-getting-started/2_function_arguments/nan/addon.cc
@@ -0,0 +1,33 @@+#include <nan.h>++void Add(const Nan::FunctionCallbackInfo<v8::Value>& info) {+ v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();++ if (info.Length() < 2) {+ Nan::ThrowTypeError("Wrong number of arguments");+ return;+ }++ if (!info[0]->IsNumber() || !info[1]->IsNumber()) {+ Nan::ThrowTypeError("Wrong arguments");+ return;+ }++ double arg0 = info[0]->NumberValue(context).FromJust();+ double arg1 = info[1]->NumberValue(context).FromJust();+ v8::Local<v8::Number> num = Nan::New(arg0 + arg1);++ info.GetReturnValue().Set(num);+}++void Init(v8::Local<v8::Object> exports) {+ v8::Local<v8::Context> context =+ exports->GetCreationContext().ToLocalChecked();+ exports->Set(context,+ Nan::New("add").ToLocalChecked(),+ Nan::New<v8::FunctionTemplate>(Add)+ ->GetFunction(context)+ .ToLocalChecked());+}++NODE_MODULE(addon, Init)