Skip to content

Instantly share code, notes, and snippets.

@deepal
Created May 12, 2018 11:02

Revisions

  1. Deepal Priyadarshana created this gist May 12, 2018.
    24 changes: 24 additions & 0 deletions internalmakecallback.cc
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    MaybeLocal<Value> InternalMakeCallback(Environment* env,
    Local<Object> recv,
    const Local<Function> callback,
    int argc,
    Local<Value> argv[],
    async_context asyncContext) {
    // ...redacted...

    Local<Function> domain_cb = env->domain_callback();
    MaybeLocal<Value> ret;
    if (asyncContext.async_id != 0 || domain_cb.IsEmpty() || recv.IsEmpty()) {
    ret = callback->Call(env->context(), recv, argc, argv);
    } else {
    // ...redacted...
    }

    // ...redacted ...

    scope.Close();
    if (scope.Failed()) {
    return Undefined(env->isolate());
    }
    return ret;
    }