/** @module array/append.ts */ import { untypedCurry } from '../function/untypedCurry' import { Append, ValueOf } from '../helper-types' interface IAppend { ( arr: A ): Append ( arr: A ): Array|B> } export function append( item: B, arr: A ): Append export function append( item: B, arr: A ): Array|B> export function append>( item: B ): IAppend export function append( item: string, arr: string ): string export function append( item: string ): ( arr: string ) => string /** * Append a item onto the end of an array * @param item item to append onto array * @param arr array to append values onto * @sig a[] -> a -> a[] * @example * append([1,2,3])('4') * //=> [1,2,3,'4'] : [number, number, number, string] */ export function append( ...args ) { return untypedCurry( ( item, arr ) => arr.concat( [ item ] ), )( ...args ) } export default append