Skip to content

Commit

Permalink
some stylistic changes
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Mar 31, 2019
1 parent e3b99db commit 7c4a18f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
4 changes: 2 additions & 2 deletions packages/core-js/internals/perform.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module.exports = function (exec) {
try {
return { e: false, v: exec() };
return { error: false, value: exec() };
} catch (error) {
return { e: true, v: error };
return { error: true, value: error };
}
};
6 changes: 3 additions & 3 deletions packages/core-js/modules/es.promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ var onUnhandled = function (promise, state) {
});
// Browsers should not trigger `rejectionHandled` event if it was handled here, NodeJS - should
state.rejection = IS_NODE || isUnhandled(state) ? UNHANDLED : HANDLED;
if (result.error) throw result.value;
}
if (IS_UNHANDLED && result.e) throw result.v;
});
};

Expand Down Expand Up @@ -326,7 +326,7 @@ $export({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION }, {
});
--remaining || resolve(values);
});
if (result.e) reject(result.v);
if (result.error) reject(result.value);
return capability.promise;
},
// `Promise.race` method
Expand All @@ -340,7 +340,7 @@ $export({ target: PROMISE, stat: true, forced: INCORRECT_ITERATION }, {
C.resolve(promise).then(capability.resolve, reject);
});
});
if (result.e) reject(result.v);
if (result.error) reject(result.value);
return capability.promise;
}
});
2 changes: 1 addition & 1 deletion packages/core-js/modules/esnext.promise.all-settled.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ require('../internals/export')({ target: 'Promise', stat: true }, {
});
--remaining || resolve(values);
});
if (result.e) reject(result.v);
if (result.error) reject(result.value);
return capability.promise;
}
});
2 changes: 1 addition & 1 deletion packages/core-js/modules/esnext.promise.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ require('../internals/export')({ target: 'Promise', stat: true }, {
});
--remaining || reject(new (getBuiltIn('AggregateError'))(errors, PROMISE_ANY_ERROR));
});
if (result.e) reject(result.v);
if (result.error) reject(result.value);
return capability.promise;
}
});
14 changes: 8 additions & 6 deletions packages/core-js/modules/esnext.promise.try.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
var newPromiseCapabilityModule = require('../internals/new-promise-capability');
var perform = require('../internals/perform');

require('../internals/export')({ target: 'Promise', stat: true }, { 'try': function (callbackfn) {
var promiseCapability = newPromiseCapabilityModule.f(this);
var result = perform(callbackfn);
(result.e ? promiseCapability.reject : promiseCapability.resolve)(result.v);
return promiseCapability.promise;
} });
require('../internals/export')({ target: 'Promise', stat: true }, {
'try': function (callbackfn) {
var promiseCapability = newPromiseCapabilityModule.f(this);
var result = perform(callbackfn);
(result.error ? promiseCapability.reject : promiseCapability.resolve)(result.value);
return promiseCapability.promise;
}
});

0 comments on commit 7c4a18f

Please sign in to comment.