This repository has been archived by the owner on Oct 23, 2018. It is now read-only.
forked from mishoo/UglifyJS
-
Notifications
You must be signed in to change notification settings - Fork 2
Asynchrony
Onoshko Dan edited this page Jan 10, 2015
·
2 revisions
(This is an experimental features! To use it with node, you should install promise
package.)
With async
modificator function returns a Promise
. In async
function available resolve
and reject
operators.
async GET(String url) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange() {
if (xhr.readyState != 4) return;
if (xhr.status == 200) resolve xhr.response;
reject false;
}
xhr.open("GET", url, true);
xhr.send();
}
await
operator can call async
functions (or functions which returns a Promise
)
Object info = await GET("info.json");
console.log(info);