现在使用async / await是否安全? [英] Is it safe to use async/await now?
问题描述
现在在Javascript中使用async-await而不是
生成器承诺是否安全,知道语法尚未生效,而且随着ES8的发布,
将会出现?
Is it safe to use async-await in Javascript instead of generators-promises now, knowing that the syntax has not made yet and will be coming with the release of ES8?
我可以指望哪些浏览器可用,以及这种语法不可用的浏览器有多常见?安全我的意思是没有像巴贝尔这样的转发器吗?
What browsers can I count on it being available, and how common are the browsers where this syntax is not available? By Safe I mean without some transpilers like babel?
推荐答案
每当我遇到这样的问题时,我会检查两个地方:
There are two places I check whenever I have questions such as this:
我可以使用网站: http://caniuse.com/#search=await
节点绿色: http://node.green/#async-functions
通常是鼓励回答包括相关信息以避免链接腐烂。但具有讽刺意味的是,这个答案恰恰相反:在上面的链接出现之前,这个答案会腐烂(下面的信息会变得无效)。因此,请务必首先检查caniuse和node.green:
Typically an answer is encouraged to include the relevant information to avoid link rot. But ironically this answer has exactly the opposite problem: this answer will rot (the information below will become invalid) long before the links above. So always check caniuse and node.green first:
从caniuse.com到2019年4月:
From caniuse.com as of April 2019 :
- IE *:不支持(最常用的版本= 11)
- 边缘:从版本15开始使用的版本= 17)
- Firefox :从版本52(最常用的版本= 65)
- Chrome :从版本55(最常用的版本= 72)
- Safari :从版本10.1(最常用的版本= 12)
- Opera :版本42(最常用版本= 58)
- iOS Safari :从版本10.3开始(最常用的版本= 12.1)
- Opera Mini *:NOT SUPPORTED
- Android浏览器 *:从5开始(最常用的版本= 4.4)
- 适用于Android的Chrome :从版本55(最常用的版本= 71)
- IE *: NOT SUPPORTED (most used version = 11)
- Edge: From version 15 (most used version = 17)
- Firefox: From version 52 (most used version = 65)
- Chrome: From version 55 (most used version = 72)
- Safari: From version 10.1 (most used version = 12)
- Opera: From version 42 (most used version = 58)
- iOS Safari: From version 10.3 (most used version = 12.1)
- Opera Mini *: NOT SUPPORTED
- Android Browser *: From 5 (most used version = 4.4)
- Chrome for Android: From version 55 (most used version = 71)
自2019年4月起从node.green开始
From node.green as of April 2019
- Node.js:从版本8.0.0开始
因此,根据您认为可接受的内容,它是安全的还是不安全的。请注意以下几点:
So depending on what you think is acceptable it is either safe or not safe. Note the following:
- 这个问题最初是在2017年提出的,我们已经走了很长一段路,所以async / await更加安全现在使用。
- 到2019年,大多数移动设备已经支持async / await。
- 节点8于2017年5月发布,因此它应该是安全的。除非你的Node.js服务器已经过时,否则在Node.js上使用async / await。
这篇关于现在使用async / await是否安全?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!