我想使用promises,但我有一个回调API,格式如下:
window.onload; // set to callback
...
window.onload = function() {
};
Run Code Online (Sandbox Code Playgroud)
function request(onChangeHandler) {
...
}
request(function() {
// change happened
...
});
Run Code Online (Sandbox Code Playgroud)
function getStuff(dat, callback) {
...
}
getStuff("dataParam", function(err, data) {
...
})
Run Code Online (Sandbox Code Playgroud)
API;
API.one(function(err, data) {
API.two(function(err, data2) {
API.three(function(err, data3) {
...
});
});
});
Run Code Online (Sandbox Code Playgroud)
我看到有一个eslint规则,no-return-await禁止return await.
在规则的描述中,它表示return await添加"extra time before the overarching Promise resolves or rejects".
但是,当我查看MDN async函数文档时,"简单示例"显示了一个示例,其中return await不包含任何可能导致性能问题的描述.
是return await一个实际的性能问题,因为eslint文档建议?
如果是这样,怎么样?