All files append.ts

100% Statements 12/12
100% Branches 0/0
100% Functions 2/2
100% Lines 10/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 2513x 13x                 11x 11x   11x 6x 12x   6x 12x         13x  
import { Collection, asIterable } from './utils'
import Sequence from './Sequence'
 
/**
 * Return a Sequence consisting of elements from the first collection followed by the elements from the second
 * Collection.
 * @param first A Collection to use when forming the resulting sequence.
 * @param second A Collection to use when forming the resulting sequence.
 */
function append<T, U>(first: Collection<T>, second: Collection<U>) {
  const firstIterable = asIterable(first)
  const secondIterable = asIterable(second)
 
  return new Sequence(function* (): Iterator<T | U> {
    for(const value of firstIterable) {
      yield value
    }
    for(const value of secondIterable) {
      yield value
    }
  })
}
 
export default append