Skip to content

Commit

Permalink
spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Gaggl authored and gbrail committed Jan 27, 2022
1 parent 552aaea commit aa57d5a
Showing 1 changed file with 37 additions and 29 deletions.
66 changes: 37 additions & 29 deletions src/org/mozilla/javascript/NativePromise.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ private static Object reject(Context cx, Scriptable scope, Scriptable thisObj, O
return cap.promise;
}

private static Object doAll(Context cx, Scriptable scope, Scriptable thisObj, Object[] args, boolean failFast) {
private static Object doAll(
Context cx, Scriptable scope, Scriptable thisObj, Object[] args, boolean failFast) {
Capability cap = new Capability(cx, scope, thisObj);
Object arg = (args.length > 0 ? args[0] : Undefined.instance);

Expand Down Expand Up @@ -205,7 +206,8 @@ private static Object all(Context cx, Scriptable scope, Scriptable thisObj, Obje
}

// Promise.allSettled
private static Object allSettled(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
private static Object allSettled(
Context cx, Scriptable scope, Scriptable thisObj, Object[] args) {
return doAll(cx, scope, thisObj, args, false);
}

Expand Down Expand Up @@ -704,7 +706,11 @@ private static class PromiseAllResolver {
Capability capability;
boolean failFast;

PromiseAllResolver(IteratorLikeIterable.Itr iter, Scriptable thisObj, Capability cap, boolean failFast) {
PromiseAllResolver(
IteratorLikeIterable.Itr iter,
Scriptable thisObj,
Capability cap,
boolean failFast) {
this.iterator = iter;
this.thisObj = thisObj;
this.capability = cap;
Expand Down Expand Up @@ -758,37 +764,39 @@ Object resolve(Context topCx, Scriptable topScope) {
new LambdaFunction(
topScope,
1,
(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) -> {
Object value = (args.length > 0 ? args[0] : Undefined.instance);
if (!failFast) {
Scriptable elementResult = cx.newObject(scope);
elementResult.put("status", elementResult, "fulfilled");
elementResult.put("value", elementResult, value);
value = elementResult;
}
return eltResolver.resolve(
cx,
scope,
value,
this);
(Context cx,
Scriptable scope,
Scriptable thisObj,
Object[] args) -> {
Object value = (args.length > 0 ? args[0] : Undefined.instance);
if (!failFast) {
Scriptable elementResult = cx.newObject(scope);
elementResult.put("status", elementResult, "fulfilled");
elementResult.put("value", elementResult, value);
value = elementResult;
}
return eltResolver.resolve(cx, scope, value, this);
});
resolveFunc.setStandardPropertyAttributes(DONTENUM | READONLY);

Callable rejectFunc = capability.reject;
if (!failFast) {
LambdaFunction resolveSettledRejection = new LambdaFunction(
topScope,
1,
(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) -> {
Scriptable result = cx.newObject(scope);
result.put("status", result, " rejected");
result.put("reason", result, (args.length > 0 ? args[0] : Undefined.instance));
return eltResolver.resolve(
cx,
scope,
result,
this);
});
LambdaFunction resolveSettledRejection =
new LambdaFunction(
topScope,
1,
(Context cx,
Scriptable scope,
Scriptable thisObj,
Object[] args) -> {
Scriptable result = cx.newObject(scope);
result.put("status", result, " rejected");
result.put(
"reason",
result,
(args.length > 0 ? args[0] : Undefined.instance));
return eltResolver.resolve(cx, scope, result, this);
});
resolveSettledRejection.setStandardPropertyAttributes(DONTENUM | READONLY);
rejectFunc = resolveSettledRejection;
}
Expand Down

0 comments on commit aa57d5a

Please sign in to comment.