@@ -870,15 +870,15 @@ MyPromise.prototype.then = function(onResolved, onRejected) {
870
870
let promise2;
871
871
// especificação 2.2, ambos `onResolved` e `onRejected` são argumentos opcionais
872
872
// isso deveria ser ignorado se `onResolved` ou `onRjected` não for uma função,
873
- // which implements the penetrate pass of it ' s value
873
+ // do qual implementa a penetrar a passagem desse valor
874
874
// `Promise.resolve(4).then().then((value) => console.log(value))`
875
875
onResolved = typeof onResolved === ' function ' ? onResolved : v => v;
876
876
onRejected = typeof onRejected === 'function ' ? onRejected : r => throw r;
877
877
878
878
if (self .currentState === RESOLVED ) {
879
879
return (promise2 = new MyPromise ((resolve , reject ) => {
880
- // specification 2.2.4, wrap them with `setTimeout`,
881
- // in order to insure that `onFulfilled` and `onRjected` execute asynchronously
880
+ // especificação 2.2.4, encapsula eles com `setTimeout`,
881
+ // em ordem para garantir que `onFulfilled` e `onRjected` executam assícronamente
882
882
setTimeout (() => {
883
883
try {
884
884
let x = onResolved (self .value );
@@ -892,7 +892,7 @@ MyPromise.prototype.then = function(onResolved, onRejected) {
892
892
893
893
if (self .currentState === REJECTED ) {
894
894
return (promise2 = new MyPromise ((resolve , reject ) => {
895
- // execute `onRejected` asynchronously
895
+ // execute `onRejected` assícronamente
896
896
setTimeout (() => {
897
897
try {
898
898
let x = onRejected (self .value );
@@ -907,7 +907,7 @@ MyPromise.prototype.then = function(onResolved, onRejected) {
907
907
if (self .currentState === PENDING ) {
908
908
return (promise2 = new MyPromise ((resolve , reject ) => {
909
909
self .resolvedCallbacks .push (() => {
910
- // Considering that it may throw error, wrap them with `try/catch`
910
+ // Considerando que isso deve lançar um erro, encapsule eles com `try/catch`
911
911
try {
912
912
let x = onResolved (self .value );
913
913
resolutionProcedure (promise2, x, resolve, reject);
@@ -928,22 +928,22 @@ MyPromise.prototype.then = function(onResolved, onRejected) {
928
928
}
929
929
}
930
930
931
- // specification 2.3
931
+ // especificação 2.3
932
932
function resolutionProcedure (promise2 , x , resolve , reject ) {
933
- // specification 2.3.1,`x` and `promise2` can't refer to the same object ,
934
- // avoiding the circular references
933
+ // especificação 2.3.1,`x` e `promise2` não podem ser referenciados para o mesmo objeto ,
934
+ // evitando referência circular
935
935
if (promise2 === x) {
936
936
return reject (new TypeError (' Error' ));
937
937
}
938
938
939
- // specification 2.3.2, if `x` is a Promise and the state is `pending`,
940
- // the promise must remain, If not, it should execute .
939
+ // especificação 2.3.2, se `x` é uma Promise e o estado é `pending`,
940
+ // a promisse deve permanecer, se não, ele deve ser executado .
941
941
if (x instanceof MyPromise) {
942
942
if (x .currentState === PENDING ) {
943
- // call the function `resolutionProcedure` again to
944
- // confirm the type of the argument that x resolves
945
- // If it's a primitive type, it will be resolved again to
946
- // pass the value to next `then`.
943
+ // chame a função `resolutionProcedure` novamente para
944
+ // confirmar o tipo de argumento que x resolve
945
+ // Se for um tipo primitivo, irá ser resolvido novamente
946
+ // passando o valor para o próximo `then`.
947
947
x .then ((value ) => {
948
948
resolutionProcedure (promise2, value, resolve, reject);
949
949
}, reject)
@@ -953,9 +953,9 @@ function resolutionProcedure(promise2, x, resolve, reject) {
953
953
return ;
954
954
}
955
955
956
- // specification 2.3.3.3.3
957
- // if both `reject` and `resolve` are executed, the first successful
958
- // execution takes precedence, and any further executions are ignored
956
+ // especificação 2.3.3.3.3
957
+ // se ambos `reject` e `resolve` forem executado, a primeira execução
958
+ // de sucesso tem precedência, e qualquer execução é ignorada
959
959
let called = false ;
960
960
// specification 2.3.3, determine whether `x` is an object or a function
961
961
if (x !== null && (typeof x === ' object' || typeof x === ' function' )) {
0 commit comments