function intermittent () {
  let step = 0
  const sequence = [
    { delay: 0, value: 0 },
    { delay: 400, value: 1 },
    { delay: 0, value: 2 }
  ]

  return {
    [Symbol.asyncIterator]: () => ({
      async next () {
        if (step === sequence.length) {
          return { done: true }
        } else {
          const item = sequence[step++]
          await delay(item.delay || 0)
          return { value: item.value, done: false }
        }
      }
    })
  }
}
// I had to build this because jest doesn't support es2018 natively
I had to build this because jest doesn't support es2018 natively
I had to build this because jest doesn ' t support es2018 natively
function intermittent () {
  let step = 0
  const sequence = [
    { delay: 0, value: 0 },
    { delay: 400, value: 1 },
    { delay: 0, value: 2 }
  ]
  return {
    [Symbol.asyncIterator]: () => ({
      async next () {
        if (step === sequence.length) {
          return { done: true }
        } else {
          const item = sequence[step++]
          await delay(item.delay || 0)
          return { value: item.value, done: false }
        }
      }
    })
  }
}
function intermittent ( ) { let step = 0 const sequence = [ { delay : 0 , value : 0 } , { delay : 400 , value : 1 } , { delay : 0 , value : 2 } ] return { [ Symbol . asyncIterator ] : ( ) => ( { async next ( ) { if ( step === sequence . length ) { return { done : true } } else { const item = sequence [ step ++ ] await delay ( item . delay || 0 ) return { value : item . value , done : false } } } } ) } }
I had to build this because jest doesn't support es2018 natively
I had to build this because jest doesn ' t support es2018 natively