import * as TypeUtil from './TypeUtil' ; export function chunk < T > ( array , chunkSize ) { const chunks = [ ] ; for ( let index = 0 , length = array . length ; index < length ; index += chunkSize ) { chunks . push ( array . slice ( index , index + chunkSize ) ) ; } return chunks ; } export function getDeduplicatedUnion < T > ( array1 , array2 ) { return removeDuplicates ( array1 . concat ( array2 ) ) ; } export function getDifference < T > ( array1 , array2 ) { return array1 . filter ( value => ! array2 . includes ( value ) ) ; } export function getIntersection < T > ( array1 , array2 ) { return array1 . filter ( value => array2 . includes ( value ) ) ; } export function removeDuplicates < T > ( array ) { return Array . from ( new Set ( array ) ) ; } export const flatten = < T > ( arrays ) : T [ ] => ( [ ] as T [ ] ) . concat ( ... arrays ) ; export function filterFalsy < T > ( value ) { return Boolean ( value ) ; }