src/NoPromise.js
function () {
    if (this._lock) return
    this._lock = true
    let task = this._tasks.shift()
    let tstType = this.error ? ['catch', 'end'] : ['then', 'end']
    while (task && !~tstType.indexOf(task.type)) {
      task = this._tasks.shift()
    }
    if (task) {
      let cb = (err, res) => {
        this.error = err
        this.result = res || this.result
        this._lock = false
        this._run()
      }
      let fn = task.fn
      if (task.type === 'end') { // .end
        fn(this.error, this.result)
      } else {
        try {
          if (task.type === 'catch') { // .catch
            fn(this.error, this.result, cb)
          } else { // .then
            fn(this.result, cb)
          }
        } catch (e) {
          cb(e)
        }
      }
    } else {
      this._lock = false
    }
  }
function () {
    if (this._lock) return
    this._lock = true
    let task = this._tasks.shift()
    let tstType = this.error ? ['catch', 'end'] : ['then', 'end']
    while (task && !~tstType.indexOf(task.type)) {
      task = this._tasks.shift()
    }
    if (task) {
      let cb = (err, res) => {
        this.error = err
        this.result = res || this.result
        this._lock = false
        this._run()
      }
      let fn = task.fn
      if (task.type === 'end') { // .end
        fn(this.error, this.result)
      } else {
        try {
          if (task.type === 'catch') { // .catch
            fn(this.error, this.result, cb)
          } else { // .then
            fn(this.result, cb)
          }
        } catch (e) {
          cb(e)
        }
      }
    } else {
      this._lock = false
    }
  }
function ( ) { if ( this . _lock ) return this . _lock = true let task = this . _tasks . shift ( ) let tstType = this . error ? [ 'catch' , 'end' ] : [ 'then' , 'end' ] while ( task && ! ~ tstType . indexOf ( task . type ) ) { task = this . _tasks . shift ( ) } if ( task ) { let cb = ( err , res ) => { this . error = err this . result = res || this . result this . _lock = false this . _run ( ) } let fn = task . fn if ( task . type === 'end' ) { // .end fn ( this . error , this . result ) } else { try { if ( task . type === 'catch' ) { // .catch fn ( this . error , this . result , cb ) } else { // .then fn ( this . result , cb ) } } catch ( e ) { cb ( e ) } } } else { this . _lock = false } }
runs the next function
@private
runs the next function