Skip to content

Commit 32dcedc

Browse files
authored
Merge pull request #17 from Rain120/dev
feat: promise; debugger launch
2 parents d4be860 + 9bc7a68 commit 32dcedc

File tree

13 files changed

+861
-490
lines changed

13 files changed

+861
-490
lines changed

.vscode/launch.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"name": "Current TS File",
6+
"type": "node",
7+
"request": "launch",
8+
"program": "${workspaceRoot}/node_modules/ts-node/dist/bin.js",
9+
"args": [
10+
"${relativeFile}"
11+
]
12+
}
13+
]
14+
}

CHANGELOG.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 1.0.0 (2020-03-03)
1+
# 1.0.0 (2020-03-05)
22

33

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

1718

@@ -48,6 +49,7 @@
4849
* observer pattern ([77c78f7](https://github.com/Rain120/awesome-javascript-code-implementation/commit/77c78f7359161c0e64b3143e3a66fea3f5d4eb46))
4950
* plop create code and docs model ([2dece76](https://github.com/Rain120/awesome-javascript-code-implementation/commit/2dece76fbfd83514551dbabadf7c54d73674730d))
5051
* plop new code and docs template ([61a936b](https://github.com/Rain120/awesome-javascript-code-implementation/commit/61a936b58bc52a1cf984dc6156746b43f65da7f1))
52+
* promise; debugger launch ([cc8ad80](https://github.com/Rain120/awesome-javascript-code-implementation/commit/cc8ad803956e65431cedd97f1ebb333ffe78c28e))
5153
* proxy design ([e615f39](https://github.com/Rain120/awesome-javascript-code-implementation/commit/e615f39497043f4c2357c7366cb13226b57208e6))
5254
* sort -> bubbleSort(algorithm, readme, test) ([36fab7b](https://github.com/Rain120/awesome-javascript-code-implementation/commit/36fab7b029d425ac129b6c4f202b18a9a3852fef))
5355
* sort -> bucket, radix; algorithm -> binaryTree; add some types; docs: update readme; fix: tests format, ([b1d166c](https://github.com/Rain120/awesome-javascript-code-implementation/commit/b1d166c7e56e37f35ab0bc7628186eeae15a4b60))
@@ -56,10 +58,10 @@
5658
* update netlify status ([013b5ca](https://github.com/Rain120/awesome-javascript-code-implementation/commit/013b5ca5847873adabbff93a89daa41500ccf153))
5759
* update readme for plans ([b427b96](https://github.com/Rain120/awesome-javascript-code-implementation/commit/b427b9667cc97c77df75ef0af56eb84b6b4c3ba6))
5860
* update test.yml -> ci.yml and set command ([43b96b6](https://github.com/Rain120/awesome-javascript-code-implementation/commit/43b96b63fc2788a5ea37fa7567c6a6dced4b875f))
59-
* update xmind ([71317c6](https://github.com/Rain120/awesome-javascript-code-implementation/commit/71317c67376bc8196f80e25391adfdc9b2496380))
61+
* update xmind ([4256758](https://github.com/Rain120/awesome-javascript-code-implementation/commit/4256758c5fe0a036ce3ececc43f848e48964d7a0))
6062
* update xmind ([cb23933](https://github.com/Rain120/awesome-javascript-code-implementation/commit/cb23933f46152c59a7b08f84d7355b35bba25002))
63+
* update xmind ([71317c6](https://github.com/Rain120/awesome-javascript-code-implementation/commit/71317c67376bc8196f80e25391adfdc9b2496380))
6164
* update xmind ([408ca68](https://github.com/Rain120/awesome-javascript-code-implementation/commit/408ca685142dc425e90be64a284016d57d580893))
62-
* update xmind ([4256758](https://github.com/Rain120/awesome-javascript-code-implementation/commit/4256758c5fe0a036ce3ececc43f848e48964d7a0))
6365
* update: plans; fix: readme bug ([d44e559](https://github.com/Rain120/awesome-javascript-code-implementation/commit/d44e559def7834fcccbb19797a1d29bf5cc4e5b7))
6466
* vuepress docs v1.0.0 ([785caeb](https://github.com/Rain120/awesome-javascript-code-implementation/commit/785caeb41beeff7a0f53646fc952d1c89ebb61d5))
6567
* zh-cn and plans ([62b460f](https://github.com/Rain120/awesome-javascript-code-implementation/commit/62b460f200a2f76ee36cd3cae94d1660ed4ff3c2))

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
[![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)
1313

1414
<!-- [![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) -->
15+
1516
![LANGUAGES](https://img.shields.io/github/languages/top/rain120/awesome-javascript-code-implementation?style=flat-square)
1617
[![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)
1718

@@ -49,6 +50,7 @@ Document Link:
4950
⌨️
5051

5152
生成 `code` 模板
53+
5254
```sh
5355
npm run template
5456
```
@@ -60,6 +62,7 @@ npm run docs
6062
```
6163

6264
同时生成 `code` `docs`模板
65+
6366
```
6467
npm run template-docs
6568
```
@@ -92,7 +95,7 @@ We welcome all contributions. You can submit any ideas as [pull requests](https:
9295

9396
- [ ] ES6
9497

95-
- [ ] Promise
98+
- [x] Promise
9699

97100
- [ ] Proxy
98101

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

163166
- Algorithms
164-
167+
165168
[Visualising Data Structures and Algorithms Through Animation](https://visualgo.net/)
166169

167170
[Data Structure Visualizations](https://www.cs.usfca.edu/~galles/visualization/Algorithms.html)

docs/.vuepress/utils/alias.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
* @Author: Rainy
33
* @Date: 2020-01-31 11:42:43
4-
* @LastEditors : Rainy
5-
* @LastEditTime : 2020-02-07 12:55:08
4+
* @LastEditors: Rainy
5+
* @LastEditTime: 2020-03-04 22:17:41
66
*/
77

88
const alias = {
@@ -25,6 +25,10 @@ const alias = {
2525
'debounce': '防抖',
2626
'throttle': '节流',
2727

28+
// es6
29+
'es6': 'ECMAScript 6(ES6)',
30+
'promise': '手写Promise',
31+
2832
// Array
2933
'array': 'Array(MDN + Function)',
3034

docs/zh/es6/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
### ECMAScript6 (ES6)
2+
3+
::: tip
4+
主要是对常见的 **ECMAScript 6(ES6)** 进行学习并实现
5+
:::
6+
7+
### 目录
8+
9+
- [x] [手写Promise](./promise/README.md)

docs/zh/es6/promise/README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
## 原理
2+
3+
`Promise` 对象是一个代理对象(代理一个值),被代理的值在`Promise`对象创建时可能是未知的。它允许你为异步操作的成功和失败分别绑定相应的处理方法`(handlers)`。 这让异步方法可以像同步方法那样返回值,但并不是立即返回最终执行结果,而是一个能代表未来出现的结果的`promise`对象。
4+
5+
![promise-process.png](@images/src/promise/images/promise-process.png)
6+
7+
<p align="center">Promise Process</p>
8+
9+
<iframe src="https://promisesaplus.com/" width="100%" height="500px" frameborder="0" />
10+
11+
<p align="center">Promise A+</p>
12+
13+
<iframe src="//liubin.org/promises-book/" width="100%" height="500px" frameborder="0" />
14+
15+
<p align="center">JavaScript Promise 迷你书</p>
16+
17+
## 实现代码
18+
19+
<<< @/src/promise/index.ts
20+
21+
## 参考
22+
23+
[Promises/A+规范](https://promisesaplus.com/) -> [【翻译】Promises/A+规范](https://www.ituring.com.cn/article/66566)
24+
25+
[Github Promise](https://github.com/then/promise) -> [Document](https://www.promisejs.org/)
26+
27+
[JavaScript Promise 迷你书](http://liubin.org/promises-book)
28+
29+
[MDN Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
30+
31+
[手写实现满足 Promise/A+ 规范的 Promise](https://www.jianshu.com/p/8d5c3a9e6181)
32+
33+
[BAT 前端经典面试问题:史上最最最详细的手写 Promise 教程](https://juejin.im/post/5b2f02cd5188252b937548ab)
34+
35+
[MDN Promise.finally](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally)

plans.svg

Lines changed: 484 additions & 482 deletions
Loading

plans.xmind

15.4 KB
Binary file not shown.

plop-templates/docs/zh/README.md.hbs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22

33
## 实现代码
44

5+
<<< @/{{path}}/{{name}}/index.ts
6+
57
## 参考
68

src/promise/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
### 原理
2+
3+
`Promise` 对象是一个代理对象(代理一个值),被代理的值在`Promise`对象创建时可能是未知的。它允许你为异步操作的成功和失败分别绑定相应的处理方法`(handlers)`。 这让异步方法可以像同步方法那样返回值,但并不是立即返回最终执行结果,而是一个能代表未来出现的结果的`promise`对象。
4+
5+
![promise-process.png](./images/promise-process.png)
6+
7+
<p align="center">Promise Process</p>
8+
9+
<iframe src="https://promisesaplus.com/" width="100%" height="500px" frameborder="0" />
10+
11+
<p align="center">Promise A+</p>
12+
13+
<iframe src="//liubin.org/promises-book/" width="100%" height="500px" frameborder="0" />
14+
15+
<p align="center">JavaScript Promise 迷你书</p>
16+
17+
### 参考
18+
19+
[Promises/A+规范](https://promisesaplus.com/) -> [【翻译】Promises/A+规范](https://www.ituring.com.cn/article/66566)
20+
21+
[Github Promise](https://github.com/then/promise) -> [Document](https://www.promisejs.org/)
22+
23+
[JavaScript Promise 迷你书](http://liubin.org/promises-book)
24+
25+
[MDN Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)
26+
27+
[手写实现满足 Promise/A+ 规范的 Promise](https://www.jianshu.com/p/8d5c3a9e6181)
28+
29+
[BAT 前端经典面试问题:史上最最最详细的手写 Promise 教程](https://juejin.im/post/5b2f02cd5188252b937548ab)
30+
31+
[MDN Promise.finally](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise/finally)
298 KB
Loading

0 commit comments

Comments
 (0)