Skip to content

Commit

Permalink
feat: promise; debugger launch
Browse files Browse the repository at this point in the history
  • Loading branch information
Rain120 committed Mar 5, 2020
1 parent 8ef0e62 commit cc8ad80
Show file tree
Hide file tree
Showing 13 changed files with 858 additions and 488 deletions.
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Current TS File",
"type": "node",
"request": "launch",
"program": "${workspaceRoot}/node_modules/ts-node/dist/bin.js",
"args": [
"${relativeFile}"
]
}
]
}
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# 1.0.0 (2020-03-03)
# 1.0.0 (2020-03-05)


### Bug Fixes
Expand All @@ -12,6 +12,7 @@
* husky pre-commit ([06f1144](https://github.com/Rain120/awesome-javascript-code-implementation/commit/06f1144d4c80888dbe6da76d28d5f6f0fff55358))
* math docs menu ([3958b99](https://github.com/Rain120/awesome-javascript-code-implementation/commit/3958b99b27170aa419b4b8983d7cf62cbae6b724))
* netlify deploy bug ([f1830e9](https://github.com/Rain120/awesome-javascript-code-implementation/commit/f1830e9a07d27b4d6b9c3c67e13272e9064bb322))
* plop create code and docs model(plop name bug) ([8ef0e62](https://github.com/Rain120/awesome-javascript-code-implementation/commit/8ef0e627daadc21842de8a35495c345f9ca70550))
* readme selected; package.json husky add test ([b228b61](https://github.com/Rain120/awesome-javascript-code-implementation/commit/b228b6194832f909c0b3c7a0c38843bab3b7c63d))


Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
[![ISSUES](https://img.shields.io/github/issues/rain120/awesome-javascript-code-implementation?style=flat-square)](https://github.com/Rain120/awesome-javascript-code-implementation/issues) [![GitHub closed pull requests](https://img.shields.io/github/issues-pr-closed/rain120/awesome-javascript-code-implementation?style=flat-square)](https://github.com/Rain120/awesome-javascript-code-implementation/pulls) [![COMMIT](https://img.shields.io/github/last-commit/rain120/awesome-javascript-code-implementation?style=flat-square)](https://github.com/Rain120/awesome-javascript-code-implementation/commits/master)

<!-- [![TEST](https://github.com/rain120/awesome-javascript-code-implementation/workflows/.github/workflows/test.yml/badge.svg)](https://github.com/Rain120/awesome-javascript-code-implementation/actions) -->

![LANGUAGES](https://img.shields.io/github/languages/top/rain120/awesome-javascript-code-implementation?style=flat-square)
[![VERSION](https://img.shields.io/github/package-json/v/rain120/awesome-javascript-code-implementation?style=flat-square)](https://github.com/Rain120/awesome-javascript-code-implementation/blob/master/package.json) [![LICENSE](https://img.shields.io/github/license/rain120/awesome-javascript-code-implementation?style=flat-square)](https://github.com/Rain120/awesome-javascript-code-implementation/blob/master/LICENSE)

Expand Down Expand Up @@ -49,6 +50,7 @@ Document Link:
⌨️

生成 `code` 模板

```sh
npm run template
```
Expand All @@ -60,6 +62,7 @@ npm run docs
```

同时生成 `code` `docs`模板

```
npm run template-docs
```
Expand Down Expand Up @@ -92,7 +95,7 @@ We welcome all contributions. You can submit any ideas as [pull requests](https:

- [ ] ES6

- [ ] Promise
- [x] Promise

- [ ] Proxy

Expand Down Expand Up @@ -161,7 +164,7 @@ We welcome all contributions. You can submit any ideas as [pull requests](https:
#### 📰 References

- Algorithms

[Visualising Data Structures and Algorithms Through Animation](https://visualgo.net/)

[Data Structure Visualizations](https://www.cs.usfca.edu/~galles/visualization/Algorithms.html)
Expand Down
8 changes: 6 additions & 2 deletions docs/.vuepress/utils/alias.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*
* @Author: Rainy
* @Date: 2020-01-31 11:42:43
* @LastEditors : Rainy
* @LastEditTime : 2020-02-07 12:55:08
* @LastEditors: Rainy
* @LastEditTime: 2020-03-04 22:17:41
*/

const alias = {
Expand All @@ -25,6 +25,10 @@ const alias = {
'debounce': '防抖',
'throttle': '节流',

// es6
'es6': 'ECMAScript 6(ES6)',
'promise': '手写Promise',

// Array
'array': 'Array(MDN + Function)',

Expand Down
9 changes: 9 additions & 0 deletions docs/zh/es6/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### ECMAScript6 (ES6)

::: tip
主要是对常见的 **ECMAScript 6(ES6)** 进行学习并实现
:::

### 目录

- [x] [手写Promise](./promise/README.md)
35 changes: 35 additions & 0 deletions docs/zh/es6/promise/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
## 原理

`Promise` 对象是一个代理对象(代理一个值),被代理的值在`Promise`对象创建时可能是未知的。它允许你为异步操作的成功和失败分别绑定相应的处理方法`(handlers)`。 这让异步方法可以像同步方法那样返回值,但并不是立即返回最终执行结果,而是一个能代表未来出现的结果的`promise`对象。

![promise-process.png](@images/src/promise/images/promise-process.png)

<p align="center">Promise Process</p>

<iframe src="https://promisesaplus.com/" width="100%" height="500px" frameborder="0" />
<p align="center">Promise A+</p>
<iframe src="http://liubin.org/promises-book/" width="100%" height="500px" frameborder="0" />
<p align="center">JavaScript Promise 迷你书</p>
## 实现代码
<<< @/src/promise/index.ts
## 参考
[Promises/A+规范](https://promisesaplus.com/) -> [【翻译】Promises/A+规范](https://www.ituring.com.cn/article/66566)
[Github Promise](https://github.com/then/promise) -> [Document](https://www.promisejs.org/)
[JavaScript Promise 迷你书](http://liubin.org/promises-book)
[MDN Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
[手写实现满足 Promise/A+ 规范的 Promise](https://www.jianshu.com/p/8d5c3a9e6181)
[BAT 前端经典面试问题:史上最最最详细的手写 Promise 教程](https://juejin.im/post/5b2f02cd5188252b937548ab)
[MDN Promise.finally](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally)
966 changes: 484 additions & 482 deletions plans.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified plans.xmind
Binary file not shown.
2 changes: 2 additions & 0 deletions plop-templates/docs/zh/README.md.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@

## 实现代码

<<< @/{{path}}/{{name}}/index.ts

## 参考

31 changes: 31 additions & 0 deletions src/promise/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
### 原理

`Promise` 对象是一个代理对象(代理一个值),被代理的值在`Promise`对象创建时可能是未知的。它允许你为异步操作的成功和失败分别绑定相应的处理方法`(handlers)`。 这让异步方法可以像同步方法那样返回值,但并不是立即返回最终执行结果,而是一个能代表未来出现的结果的`promise`对象。

![promise-process.png](./images/promise-process.png)

<p align="center">Promise Process</p>

<iframe src="https://promisesaplus.com/" width="100%" height="500px" frameborder="0" />
<p align="center">Promise A+</p>
<iframe src="http://liubin.org/promises-book/" width="100%" height="500px" frameborder="0" />
<p align="center">JavaScript Promise 迷你书</p>
### 参考
[Promises/A+规范](https://promisesaplus.com/) -> [【翻译】Promises/A+规范](https://www.ituring.com.cn/article/66566)
[Github Promise](https://github.com/then/promise) -> [Document](https://www.promisejs.org/)
[JavaScript Promise 迷你书](http://liubin.org/promises-book)
[MDN Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
[手写实现满足 Promise/A+ 规范的 Promise](https://www.jianshu.com/p/8d5c3a9e6181)
[BAT 前端经典面试问题:史上最最最详细的手写 Promise 教程](https://juejin.im/post/5b2f02cd5188252b937548ab)
[MDN Promise.finally](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally)
Binary file added src/promise/images/promise-process.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit cc8ad80

Please sign in to comment.