All files utils.ts

100% Statements 5/5
100% Branches 2/2
100% Functions 2/2
100% Lines 5/5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 155x             5x 51x     5x 36x    
import Sequence from './Sequence'
 
export type Collection<T> =
  Iterable<T> |
  ArrayLike<T> |
  (() => Iterator<T>)
 
export function isIterable<T>(collection: Collection<T>): collection is Iterable<T> {
  return (<any>collection)[Symbol.iterator] !== undefined
}
 
export function asIterable<T>(collection: Collection<T>): Iterable<T> {
  return isIterable(collection) ? collection : new Sequence(<any>collection)
}