code: async function flush(ch) {
    if (!ch.empty())
      // this error is never expected to be thrown
      // just a sanity check during development
      throw new Error(
        'Attempted to execute flush(Channel) on a non-empty channel!',
      )
    if (ch[IS_FLUSHING]) return
    ch[IS_FLUSHING] = true
    let take = null
    const takes = []
    while (
      (take = ch.takes.shift()) // eslint-disable-line no-cond-assign
    ) {
      takes.push(take(ACTIONS.DONE))
    }
    await Promise.all(takes)
    if (!ch[IS_CONSUMING]) finish(ch)
    ch[IS_FLUSHING] = false
  }
docs: /*
  Flushes out any remaining takes from the channel
  by sending them the value of `ACTIONS.DONE`.