刚才看到有位小哥蛮搞笑的,说什么generate promise比
nodejs吧
全部回复
仅看楼主
level 5
sikele2236
楼主
async await好,generate promise我又不是没学过
可以看看这篇文章
http://www.zhihu.com/question/25413141/answer/30767780
2015年02月27日 01点02分
1
level 5
sikele2236
楼主
http://www.html5rocks.com/en/tutorials/es6/promises/#toc-parallelism-sequencing
这篇是promise的使用,他展示了如何使用promise去调用getJSON
http://jakearchibald.com/2014/es7-async-functions/
这篇就是用async await调用基于prmoise异步的getJSON方法。属于进阶过度。
2015年02月27日 01点02分
2
level 1
fengdayin
function* g1(next) {
/**/yield 'L';
/**/yield* next;
/**/yield 'B';
}
function* g2(next) {
/**/yield 'Z';
/**/yield* next;
/**/yield 'S';
}
function* g3() {
/**/yield 'D';
/**/yield 'A';
}
for (var x of g1(g2(g3()))) {
/**/process.stdout.write(x);
}
告诉我输出结果
2015年02月27日 03点02分
3
sikele2236
知道自己菜了就骂人了?
2015年02月27日 03点02分
fengdayin
@sikele2236
常识都不懂, 天天在这bb什么, 好好学习去吧
2015年02月27日 03点02分
sikele2236
@fengdayin
呵呵,generate 是最尴尬的东西,最终形态还是async await
2015年02月27日 03点02分
fengdayin
@sikele2236
白痴, generate 是python设计出的. 懂个P. 没听过函数式编程的渣子.
2015年02月27日 03点02分
level 5
sikele2236
楼主
@此ID已被我抢注
快来跪舔吧
2015年02月27日 03点02分
4
level 1
fengdayin
export function* create(ynext, next, req, res) {
/**/let keyword = validate.vkeyword(req.body.keyword);
/**/if (keyword === false) {
/******/res.writeHead(400);
/******/return res.end('FAILURE');
/**/}
/**/let [err, affected] = yield taskDB.insert(
/******/parseInt(req.session.userId),
/******/req.session.username,
/******/keyword,
/******/ynext
/**/);
/**/if (err) {
/******/res.writeHead(500);
/******/return res.end();
/**/}
/**/if (!affected) {
/******/res.writeHead(200);
/******/return res.end('FAILURE');
/**/}
/**/res.writeHead(201);
/**/res.end('OK');
/**/yield* next;
}
给你长长见识
2015年02月27日 03点02分
5
sikele2236
你都没开发过复杂并发程序,你这破玩意见识啥?等你写过一旦并发不同步就会导致数据错误的复杂程序再来吹。
2015年02月27日 04点02分
fengdayin
@sikele2236
你爹用nodejs写的复杂并发程序, 随便挑一个出来, 都赶上你从出生到现在写的代码量. Joyent云平台 Paypal Yahoo 淘宝都在用nodejs, Docker和Vagrant都是采用nodejs编写的NodeOS的首个版本进行构建. 你算个P.
2015年02月27日 05点02分
fengdayin
@sikele2236
没事滚回去买两本Unix 网络编程好好看看通信基本原理, 别TM在这#丢人.
2015年02月27日 05点02分
sikele2236
@fengdayin
没遇到过并发问题就说明你有多菜了
2015年02月27日 05点02分
level 11
wyn19890614
......
2015年03月09日 22点03分
7
level 4
thechasekevin
2015年04月11日 09点04分
9
level 8
此ID已被我抢注
逗比居然点名道姓at 我,靠
2015年05月25日 14点05分
10
sikele2236
弱者什么都不懂,就是给你科普科普
2015年05月25日 15点05分
level 6
浅时光_MIALS
这里还有人吗
2020年12月03日 04点12分
12
1