Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5ed83a5

Browse files
committed
UPDATE
1 parent d60e5e8 commit 5ed83a5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

‎JS/JS-br.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
- [AMD](#amd)
2626
- [A diferença entre call apply bind](#a-diferença-entre-call-apply-bind)
2727
- [simulação para implementar `call` e `apply`](#simulação-para-implementar--call-e--apply)
28-
- [Implementação de Promise](#promise-implementation)
28+
- [Implementação de Promise](#implementação-de-promise)
2929
- [Implementação do Generator](#generator-implementation)
3030
- [Debouncing](#debouncing)
3131
- [Throttle](#throttle)
@@ -804,13 +804,15 @@ Function.prototype.myBind = function (context) {
804804
}
805805
```
806806
807-
# Promise implementation
807+
# Implementação de Promise
808808
809-
`Promise` is a new syntax introduced by ES6, which resolves the problem of callback hell.
809+
`Promise` é a nova sintaxe introduzida pelo ES6, que resolve os problemas de callback hell.
810810
811-
Promise can be seen as a state machine and it's initial state is `pending`. We can change the state to `resolved` or `rejected` by using the `resolve` and `reject` functions. Once the state is changed, it cannot be changed again.
811+
Promise pode ser visto como um estado de máquina e o seu estado inicial é `pending`. Nós podemos mudar o estado para `resolved` ou `rejected` usando as funções `resolve` e `reject`. Uma vez que o state mudou, ele não pode mudar novamente.
812812
813-
The function `then` returns a Promise instance, which is a new instance instead of the previous one. And that's because the Promise specification states that in addition to the `pending` state, other states cannot be changed, and multiple calls of function `then` will be meaningless if the same instance is returned.
813+
A função `then` retorna uma instância da Promise, do qual é uma nova instância ao invés do anterior. E existe por que a especificação de estado da Promise que adiciona para o estado `pending`, outro estado não pode ser mudado, e multiplas chamadas a função `then` serão insignificantes se a mesma instância for retornada.
814+
815+
Para `then`, ele pode essencialmente ser visto como flatMap`:
814816

815817
For `then`, it can essentially be seen as `flatMap`:
816818

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /