Skip to content

Commit

Permalink
[squash] use Nan::MaybeResource, avoid ES2015 features
Browse files Browse the repository at this point in the history
  • Loading branch information
ofrobots committed Feb 7, 2018
1 parent 1b97a2b commit f510440
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions nan.h
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ class TryCatch {
#endif

inline async_context AsyncInit(
v8::MaybeLocal<v8::Object> maybe_resource
MaybeLocal<v8::Object> maybe_resource
, v8::Local<v8::String> resource_name) {
#if NODE_MODULE_VERSION < NODE_8_0_MODULE_VERSION
return async_context();
Expand All @@ -896,7 +896,7 @@ class TryCatch {
}

inline async_context AsyncInit(
v8::MaybeLocal<v8::Object> maybe_resource
MaybeLocal<v8::Object> maybe_resource
, const char* name) {
return AsyncInit(maybe_resource, New<v8::String>(name).ToLocalChecked());
}
Expand All @@ -909,7 +909,7 @@ class TryCatch {
#endif
}

inline v8::MaybeLocal<v8::Value> MakeCallback(
inline MaybeLocal<v8::Value> MakeCallback(
v8::Local<v8::Object> target
, v8::Local<v8::Function> func
, int argc
Expand All @@ -925,7 +925,7 @@ class TryCatch {
#endif
}

inline v8::MaybeLocal<v8::Value> MakeCallback(
inline MaybeLocal<v8::Value> MakeCallback(
v8::Local<v8::Object> target
, v8::Local<v8::String> symbol
, int argc
Expand All @@ -941,7 +941,7 @@ class TryCatch {
#endif
}

inline v8::MaybeLocal<v8::Value> MakeCallback(
inline MaybeLocal<v8::Value> MakeCallback(
v8::Local<v8::Object> target
, const char* method
, int argc
Expand Down
2 changes: 1 addition & 1 deletion test/cpp/makecallbackcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class DelayRequest {
: milliseconds(milliseconds_) {
callback.Reset(callback_);
request.data = this;
asyncContext = AsyncInit(v8::MaybeLocal<v8::Object>(), "test.DelayRequest");
asyncContext = AsyncInit(MaybeLocal<v8::Object>(), "test.DelayRequest");
}
~DelayRequest() {
AsyncDestroy(asyncContext);
Expand Down
12 changes: 6 additions & 6 deletions test/js/makecallbackcontext-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ test('makecallbackcontext', function (t) {
var destroyCalled = false;

var hooks = asyncHooks.createHook({
init(asyncId, type, triggerAsyncId, resource) {
init: function(asyncId, type, triggerAsyncId, resource) {
if (type === 'test.DelayRequest') {
resourceAsyncId = asyncId;
}
},
before(asyncId) {
before: function(asyncId) {
if (asyncId === resourceAsyncId) {
beforeCalled = true;
}
},
after(asyncId) {
after: function(asyncId) {
if (asyncId === resourceAsyncId) {
afterCalled = true;
}
},
destroy(asyncId) {
destroy: function(asyncId) {
if (asyncId === resourceAsyncId) {
destroyCalled = true;
}
Expand All @@ -52,14 +52,14 @@ test('makecallbackcontext', function (t) {
hooks.enable();

originalExecutionAsyncId = asyncHooks.executionAsyncId();
delay(1000, () => {
delay(1000, function() {
t.equal(asyncHooks.executionAsyncId(), resourceAsyncId,
'callback should have the correct execution context');
t.equal(asyncHooks.triggerAsyncId(), originalExecutionAsyncId,
'callback should have the correct trigger context');
t.ok(beforeCalled, 'before should have been called');
t.notOk(afterCalled, 'after should not have been called yet');
setTimeout(() => {
setTimeout(function() {
t.ok(afterCalled, 'after should have been called');
t.ok(destroyCalled, 'destroy should have been called');
t.equal(asyncHooks.triggerAsyncId(), resourceAsyncId,
Expand Down

0 comments on commit f510440

Please sign in to comment.