import { identity } from './functions' ; const arrayPrototype = Array . prototype ; param array param callbackfn returns { T [ ] } function filter < T > ( array , callbackfn ) { return array . filter ( callbackfn ) ; } param array param callbackfn returns { T [ ] } export function forEach < T > ( array , callbackfn ) { array . forEach ( callbackfn ) ; return array ; } param array param item returns { number } export function indexOf < T > ( array , item ) { return array . indexOf ( item ) ; } param array returns { T [ ] } export function compact < T > ( array ) { return filter ( array , identity ) as T [ ] ; } param argsObject returns { any [ ] } export function argumentsArray < T > ( argsObject ) { return arrayPrototype . slice . call ( argsObject , 0 ) ; } param item returns { T [ ] } export function concat < T > ( ... item ) { return arrayPrototype . concat . apply ( [ ] , item ) ; } param array returns { T [ ] } export function flatten < T > ( array ) { return concat ( [ ] , ... array ) ; } param array returns { T [ ] } export function uniq < T > ( array ) { return filter ( array , ( item , index , array ) => indexOf ( array , item ) === index ) ; } param array param remove returns { T [ ] } export function without < T > ( array , remove ) { return filter ( array , ( item ) => ! contains ( remove , item ) ) ; } param array param item returns { boolean } export function contains < T > ( array , item ) { return indexOf ( array , item ) !== - 1 ; } param array1 param array2 returns { [ T ] } export function difference < T > ( array1 , array2 ) { return concat ( without ( array1 , array2 ) , without ( array2 , array1 ) ) ; } param item returns { boolean } export function isArray < T > ( item ) { return Array . isArray ( item ) ; }