import isNil from './is-nil'; import isObject from './is-object'; const identity = (v: T): T => v; interface _Type { [key: string]: T; } export default ( object: { [key: string]: T }, func: (value: T, key: string) => any = identity, ): { [key: string]: any } => { const r: _Type = {}; if (isObject(object) && !isNil(object)) { Object.keys(object).forEach((key) => { // @ts-ignore r[key] = func(object[key], key); }); } return r; };