import { List } from '../types' ; import { Maybe } from '@typed/maybe' ; import { arrayFrom } from '../arrayFrom' ; import { curry2 } from '@typed/functions' ; import { slice } from '../slice' ; name export const splitEvery = curry2 ( function splitEvery < A > ( amount , list ) : Array < Array < A > > { if ( amount <= 0 ) return [ arrayFrom ( list ) ] ; const result = [ ] ; let i = 0 ; while ( i < list . length ) result . push ( slice ( i , Maybe . of ( ( i += amount ) ) , list ) ) ; return result ; } ) ; export type SplitEvery = { < A > ( amount , list ) : Array < Array < A > > ; < A > ( amount ) : ( list : List < A > ) => Array < Array < A > > ; } ;