import { List } from '../types' ; import { RemoveArity3 } from './types' ; import { arrayFrom } from '../arrayFrom' ; import { curry3 } from '@typed/functions' ; import { equals } from '@typed/logic' ; const isZero = equals ( 0 ) ; name export const remove = curry3 ( function remove < A > ( index , amount , list ) : Array < A > { const length = list . length ; if ( isZero ( amount ) || isZero ( length ) || index >= length ) return arrayFrom ( list ) ; if ( isZero ( index ) && amount >= length ) return [ ] ; const newList = Array ( length - Math . abs ( index ) - 1 ) ; for ( let i = 0 ; i < index ; ++ i ) newList [ i ] = list [ i ] ; for ( let i = index + amount ; i < length ; ++ i ) newList [ i - amount ] = list [ i ] ; return newList ; } ) as RemoveArity3 ;