Skip to content

Commit 1989e6e

Browse files
authored
add clang-format (#112)
1 parent fbf4fdd commit 1989e6e

File tree

43 files changed

+246
-207
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+246
-207
lines changed

1_hello_world/nan/hello.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ void Method(const Nan::FunctionCallbackInfo<v8::Value>& info) {
77
void Init(v8::Local<v8::Object> exports) {
88
v8::Local<v8::Context> context = exports->CreationContext();
99
exports->Set(Nan::New("hello").ToLocalChecked(),
10-
Nan::New<v8::FunctionTemplate>(Method)->GetFunction(context).ToLocalChecked());
10+
Nan::New<v8::FunctionTemplate>(Method)
11+
->GetFunction(context)
12+
.ToLocalChecked());
1113
}
1214

1315
NODE_MODULE(hello, Init)

1_hello_world/napi/hello.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#include <node_api.h>
21
#include <assert.h>
2+
#include <node_api.h>
33

44
napi_value Method(napi_env env, napi_callback_info info) {
55
napi_status status;
@@ -9,7 +9,7 @@ napi_value Method(napi_env env, napi_callback_info info) {
99
return world;
1010
}
1111

12-
#define DECLARE_NAPI_METHOD(name, func) \
12+
#define DECLARE_NAPI_METHOD(name, func) \
1313
{ name, 0, func, 0, 0, 0, napi_default, 0 }
1414

1515
napi_value Init(napi_env env, napi_value exports) {

2_function_arguments/nan/addon.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ void Add(const Nan::FunctionCallbackInfo<v8::Value>& info) {
2323
void Init(v8::Local<v8::Object> exports) {
2424
v8::Local<v8::Context> context = exports->CreationContext();
2525
exports->Set(Nan::New("add").ToLocalChecked(),
26-
Nan::New<v8::FunctionTemplate>(Add)->GetFunction(context).ToLocalChecked());
26+
Nan::New<v8::FunctionTemplate>(Add)
27+
->GetFunction(context)
28+
.ToLocalChecked());
2729
}
2830

2931
NODE_MODULE(addon, Init)

2_function_arguments/napi/addon.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#include <node_api.h>
21
#include <assert.h>
2+
#include <node_api.h>
33
#include <stdio.h>
44
napi_value Add(napi_env env, napi_callback_info info) {
55
napi_status status;
@@ -42,7 +42,7 @@ napi_value Add(napi_env env, napi_callback_info info) {
4242
return sum;
4343
}
4444

45-
#define DECLARE_NAPI_METHOD(name, func) \
45+
#define DECLARE_NAPI_METHOD(name, func) \
4646
{ name, 0, func, 0, 0, 0, napi_default, 0 }
4747

4848
napi_value Init(napi_env env, napi_value exports) {

2_function_arguments/node-addon-api/addon.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ Napi::Value Add(const Napi::CallbackInfo& info) {
44
Napi::Env env = info.Env();
55

66
if (info.Length() < 2) {
7-
Napi::TypeError::New(env, "Wrong number of arguments").ThrowAsJavaScriptException();
7+
Napi::TypeError::New(env, "Wrong number of arguments")
8+
.ThrowAsJavaScriptException();
89
return env.Null();
910
}
1011

@@ -21,8 +22,7 @@ Napi::Value Add(const Napi::CallbackInfo& info) {
2122
}
2223

2324
Napi::Object Init(Napi::Env env, Napi::Object exports) {
24-
exports.Set(Napi::String::New(env, "add"),
25-
Napi::Function::New(env, Add));
25+
exports.Set(Napi::String::New(env, "add"), Napi::Function::New(env, Add));
2626
return exports;
2727
}
2828

3_callbacks/nan/addon.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
void RunCallback(const Nan::FunctionCallbackInfo<v8::Value>& info) {
44
v8::Local<v8::Function> cb = info[0].As<v8::Function>();
55
const unsigned argc = 1;
6-
v8::Local<v8::Value> argv[argc] = { Nan::New("hello world").ToLocalChecked() };
6+
v8::Local<v8::Value> argv[argc] = {Nan::New("hello world").ToLocalChecked()};
77
Nan::MakeCallback(Nan::GetCurrentContext()->Global(), cb, argc, argv);
88
}
99

3_callbacks/napi/addon.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#include <node_api.h>
21
#include <assert.h>
2+
#include <node_api.h>
33

44
napi_value RunCallback(napi_env env, const napi_callback_info info) {
55
napi_status status;
@@ -28,8 +28,8 @@ napi_value RunCallback(napi_env env, const napi_callback_info info) {
2828

2929
napi_value Init(napi_env env, napi_value exports) {
3030
napi_value new_exports;
31-
napi_status status =
32-
napi_create_function(env, "", NAPI_AUTO_LENGTH, RunCallback, nullptr, &new_exports);
31+
napi_status status = napi_create_function(
32+
env, "", NAPI_AUTO_LENGTH, RunCallback, nullptr, &new_exports);
3333
assert(status == napi_ok);
3434
return new_exports;
3535
}

3_callbacks/node-addon-api/addon.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
void RunCallback(const Napi::CallbackInfo& info) {
44
Napi::Env env = info.Env();
55
Napi::Function cb = info[0].As<Napi::Function>();
6-
cb.Call(env.Global(), { Napi::String::New(env, "hello world") });
6+
cb.Call(env.Global(), {Napi::String::New(env, "hello world")});
77
}
88

99
Napi::Object Init(Napi::Env env, Napi::Object exports) {

4_object_factory/nan/addon.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
void CreateObject(const Nan::FunctionCallbackInfo<v8::Value>& info) {
44
v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
55
v8::Local<v8::Object> obj = Nan::New<v8::Object>();
6-
obj->Set(Nan::New("msg").ToLocalChecked(), info[0]->ToString(context).ToLocalChecked());
6+
obj->Set(Nan::New("msg").ToLocalChecked(),
7+
info[0]->ToString(context).ToLocalChecked());
78

89
info.GetReturnValue().Set(obj);
910
}
1011

1112
void Init(v8::Local<v8::Object> exports, v8::Local<v8::Object> module) {
1213
v8::Local<v8::Context> context = exports->CreationContext();
1314
module->Set(Nan::New("exports").ToLocalChecked(),
14-
Nan::New<v8::FunctionTemplate>(CreateObject)->GetFunction(context).ToLocalChecked());
15+
Nan::New<v8::FunctionTemplate>(CreateObject)
16+
->GetFunction(context)
17+
.ToLocalChecked());
1518
}
1619

1720
NODE_MODULE(addon, Init)

4_object_factory/napi/addon.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#include <node_api.h>
21
#include <assert.h>
2+
#include <node_api.h>
33

44
napi_value CreateObject(napi_env env, const napi_callback_info info) {
55
napi_status status;
@@ -21,8 +21,8 @@ napi_value CreateObject(napi_env env, const napi_callback_info info) {
2121

2222
napi_value Init(napi_env env, napi_value exports) {
2323
napi_value new_exports;
24-
napi_status status =
25-
napi_create_function(env, "", NAPI_AUTO_LENGTH, CreateObject, nullptr, &new_exports);
24+
napi_status status = napi_create_function(
25+
env, "", NAPI_AUTO_LENGTH, CreateObject, nullptr, &new_exports);
2626
assert(status == napi_ok);
2727
return new_exports;
2828
}

0 commit comments

Comments
 (0)