export function mapValues(object: any, mapFn: (val: any, key: string) => any): any { if (Array.isArray(object)) { throw `This map is just for objects, just use array.map for arrays` } return Object.keys(object).reduce((result: any, key: string) => { result[key] = mapFn(object[key], key) return result }, {}) } export function forEach(object: any, mapFn: (val: any, key: any) => void): void { if (Array.isArray(object)) { throw `This map is just for objects, just use array.forEach for arrays` } return Object.keys(object).forEach((key: string) => { mapFn(object[key], key) }) } export function take(arr: T[], count = 0): T[] { return arr.slice(0, count) } export function without(arr: T[], values: T[]): T[] { return arr.filter(val => values.indexOf(val) === -1) } export function pick(object: T, pick: Array): Pick { const res: Partial = {} pick.forEach((key: U) => { if (object[key] !== undefined) { res[key] = object[key] } }) return res as Pick }