问题描述
有没有企图把异步/的await 从C#5.0功能,它可以编译为JavaScript(如CoffeScript)任何语言? (因此,它可以在Web浏览器或在node.js中被使用。)
Is there any attempt to bring async/await feature from C# 5.0 to any language which can be compiled to JavaScript (such as CoffeScript)? (So it can be used either in web browser or in node.js.)
推荐答案
我不熟悉C#,但它听起来像你要找的是某种延续,这样,而不是写
I'm not familiar with C#, but it sounds like what you're looking for is some sort of continuations, so that instead of writing
fs.readFile 'foo.txt', (err, data) ->
myFunc data
您可以改为只写类似
data = &fs.readFile 'foo.txt' # not a real syntax
myFunc data
这是不是一件JavaScript或CoffeeScript的规定。然而,还有其他一些编译器,可以做这样的事情:
This isn't something that JavaScript or CoffeeScript provides. However, there are several other compilers that can do something like this:
- - 基于JavaScript的,主要只是增加了这个功能
- - 基于JavaScript,增加了大量的功能
- - 基于CoffeeScript的-
- TameJS - JavaScript-based, mainly just adds this feature
- Kaffeine - JavaScript-based, adds a bunch of features
- coco - CoffeeScript-based
另见:编译成JavaScript的名单/ A>在CoffeeScript的维基。
See also: List of languages that compile to JavaScript on the CoffeeScript wiki.
这篇关于异步/网页浏览器或Node.js的等待?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!