Generator Thunk Thunk60 var x = 1 ; function f ( m ) { return m * 2 ;}f(x + 5 ) fx + 5 call by valuex + 56f C f(x + 5 ) // f( 6 ) call by namex + 5Haskell f(x + 5 ) // (x + 5 ) * 2 function f ( a, {}]; // docs.forEach( function ( doc ) { await db.post(doc); });} awaitforEachasync async function dbFuc ( db ) { let docs = [{}, }; console .log(res);}).catch(onerror); co( function * () { var values = [n1, done: false } return asyncIterator.next();}).then(iterResult3 = { console .log(iterResult3); // { value: undefined, data ) { fs.readFile(fileB, done: false } g.next() // { value: undefined, 2 : Promise .resolve( 2 ), data ) { // ... });}); callback hell PromisePromise var readFile = require ( fs-readfile-promise );readFile(fileA).then( function ( data ) { console .log(data.toString());}).then( function () { return readFile(fileB);}).then( function ( data ) { console .log(data.toString());}).catch( function ( err ) { console .log(err);}); fs-readfile-promisePromisereadFilePromisethencatch Promise then Promise Promise then Generator coroutine A AB B A (责任编辑:admin) |