All files map.ts

100% Statements 9/9
100% Branches 0/0
100% Functions 2/2
100% Lines 8/8
1 2 3 4 5 6 7 8 9 10 11 12 13 14 155x 5x     5x 5x 2x 6x 12x         5x  
import { Collection, asIterable } from './utils'
import Sequence from './Sequence'
 
function map<T, U>(collection: Collection<T>, fn: (value: T, index: number) => U) {
  const iterable = asIterable(collection)
  return new Sequence(function* () {
    let index = 0
    for(const value of iterable) {
      yield fn(value, index++)
    }
  })
}
 
export default map