@ 260528.1

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/napi/addon.c. All files

src/1-getting-started/2_function_arguments/napi/addon.c

new file mode 100644@@ -0,0 +1,56 @@+#include <assert.h>+#include <node_api.h>+#include <stdio.h>+static napi_value Add(napi_env env, napi_callback_info info) {+  napi_status status;++  size_t argc = 2;+  napi_value args[2];+  status = napi_get_cb_info(env, info, &argc, args, NULL, NULL);+  assert(status == napi_ok);++  if (argc < 2) {+    napi_throw_type_error(env, NULL, "Wrong number of arguments");+    return NULL;+  }++  napi_valuetype valuetype0;+  status = napi_typeof(env, args[0], &valuetype0);+  assert(status == napi_ok);++  napi_valuetype valuetype1;+  status = napi_typeof(env, args[1], &valuetype1);+  assert(status == napi_ok);++  if (valuetype0 != napi_number || valuetype1 != napi_number) {+    napi_throw_type_error(env, NULL, "Wrong arguments");+    return NULL;+  }++  double value0;+  status = napi_get_value_double(env, args[0], &value0);+  assert(status == napi_ok);++  double value1;+  status = napi_get_value_double(env, args[1], &value1);+  assert(status == napi_ok);++  napi_value sum;+  status = napi_create_double(env, value0 + value1, &sum);+  assert(status == napi_ok);++  return sum;+}++#define DECLARE_NAPI_METHOD(name, func)                                        \+  { name, 0, func, 0, 0, 0, napi_default, 0 }++napi_value Init(napi_env env, napi_value exports) {+  napi_status status;+  napi_property_descriptor addDescriptor = DECLARE_NAPI_METHOD("add", Add);+  status = napi_define_properties(env, exports, 1, &addDescriptor);+  assert(status == napi_ok);+  return exports;+}++NAPI_MODULE(NODE_GYP_MODULE_NAME, Init)