normal-async

Promise 语法糖可用于不支持Promise的浏览器环境,与Promise遵循一致的语法规则。

Usage no npm install needed!

<script type="module">
  import normalAsync from 'https://cdn.skypack.dev/normal-async';
</script>

README

async

对ES6 Promise 的原生实现,可用于不支持Promise的浏览器。

install

npm install -g normal-async

github

https://github.com/rookie-mr/async.git

基本用法

var async = new Async(function (resolve, reject) {
    setTimeout(function () {
        resolve(9527)
        // reject(9527)
        console.log('async', async)
    }, 2000)
    console.log('this:', this)
})
async.then(function (data) {
    setTimeout(function () {
        console.log('data 1:', data)
    })
}, function (err) {
    console.log('then err', err)
}).then(function (data) {
    console.log('data 2:', data)
}).catch(function (err) {
    console.log('catch err', err)
}).finally(function () {
    console.log('finally')
})