Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
src: changing node_file's usage of v8::Resolver
Browse files Browse the repository at this point in the history
node_file was casting back and forth between v8::Resolver and v8::Promise
This is unnecessary; most of the time it just wants the v8::Resolver,
converting to the v8::Promise only as a return value.
  • Loading branch information
MSLaguana committed Feb 12, 2018
1 parent 354e306 commit 8dca89d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/node_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ void FSReqWrap::SetReturnValue(const FunctionCallbackInfo<Value>& args) {
void FSReqPromise::SetReturnValue(const FunctionCallbackInfo<Value>& args) {
Local<Context> context = env()->context();
args.GetReturnValue().Set(
object()->Get(context, env()->promise_string()).ToLocalChecked());
object()->Get(context, env()->promise_string()).ToLocalChecked()
.As<Promise::Resolver>()->GetPromise());
}

void NewFSReqWrap(const FunctionCallbackInfo<Value>& args) {
Expand All @@ -300,7 +301,7 @@ FSReqPromise::FSReqPromise(Environment* env)
stats_field_array_(env->isolate(), 14) {
auto resolver = Promise::Resolver::New(env->context()).ToLocalChecked();
object()->Set(env->context(), env->promise_string(),
resolver.As<Promise>()).FromJust();
resolver).FromJust();
}

FSReqPromise::~FSReqPromise() {
Expand All @@ -315,9 +316,7 @@ void FSReqPromise::Reject(Local<Value> reject) {
Local<Value> value =
object()->Get(env()->context(),
env()->promise_string()).ToLocalChecked();
CHECK(value->IsPromise());
Local<Promise> promise = value.As<Promise>();
Local<Promise::Resolver> resolver = promise.As<Promise::Resolver>();
Local<Promise::Resolver> resolver = value.As<Promise::Resolver>();
resolver->Reject(env()->context(), reject).FromJust();
}

Expand All @@ -336,7 +335,6 @@ void FSReqPromise::Resolve(Local<Value> value) {
Local<Value> val =
object()->Get(env()->context(),
env()->promise_string()).ToLocalChecked();
CHECK(val->IsPromise());
Local<Promise::Resolver> resolver = val.As<Promise::Resolver>();
resolver->Resolve(env()->context(), value).FromJust();
}
Expand Down

0 comments on commit 8dca89d

Please sign in to comment.