1. Generator生成器函数:
      1. function * foo () {
      2. console.log('start')
      3. try {
      4. const res = yield 'foo' // 使用yield关键字向外返回一个值 暂停generator函数的执行
      5. console.log(res)
      6. }catch (e){
      7. console.log(e)
      8. }
      9. }
      10. let generator = foo()
      11. const result = generator.next()
      12. generator.next('bar') // 作为yield这个语句的返回值
      13. generator.throw('err')
    // generator + Promise
      function ajax (url) {
        return new Promise(function (resolve, reject) {
          let xhr = new XMLHttpRequest()
          xhr.open('GET', url)
          xhr.responseType = 'json'
          xhr.onload = function () {
            if (this.status + '' === '200') {
              resolve(this.response)
              console.log(this.response)
            } else {
              reject(new Error(this.responseText))
              console.log(this.responseText)
            }
          }
          xhr.send()
        })
      }
    function * main () {
      const users = yield ajax('/ajaxTest.js')
      const post = yield ajax('/ajaxPost.js')
    }
    let g = main()
    const result = g.next()
    if (result.done) return
    result.then(data => {
      const result1 = g.next(data)
      if (resul1.done) return
      result1.value.then(res => {
        g.next(res)
      })
    })