ES6 异步操作和Async函数(3)_汽车市场报
广告位API接口通信错误,查看德得广告获取帮助

汽车市场报移动版

汽车市场报 > 汽车百科 >

ES6 异步操作和Async函数(3)

Generatorwhileawait iterator.next() async function f () { async function * gen () { yield a ; yield b ; yield c ; } return await takeAsync(gen());}f().then( function ( result ) { console .log(result); // [a。

callback);} };}; fs.readFileThunk var readFileThunk = Thunk(fs.readFile);readFileThunk(fileA)(callback); function f ( a。

ret.value); if (value isPromise(value)) return value.then(onFulfilled, cb ) { cb(a);} let ft = Thunk(f); let log = console .log.bind( console );ft( 1 )(log) // 1 Thunkify Thunkify $ npm install thunkify var thunkify = require ( thunkify ); var fs = require ( fs ); var read = thunkify(fs.readFile);read( package.json )( function ( err, function ( err。

getBar()]); // let fooPromise = getFoo(); let barPromise = getBar(); let foo = await fooPromise; let bar = await barPromise; (责任编辑:admin)

广告位API接口通信错误,查看德得广告获取帮助