import { IterableValue, Primitive, MapKey, MapValue, ValidPropertyKey } from './src/types' /** * @description * Ensure an object is returned, by converting `value` if possible * or by returning an empty object otherwise. If `value` is already * an object it is simply returned. `null` & `undefined` will produce * an empty object. * * Works just like [`toObject`](#toObject), but receives a function * that allows for transforming the values of the resulting object. * * @parameters * | name | type | description | * | :--: | :--: | ----------- | * | value | `any` | Value to convert | * | fn | `Function` | Function accepting incoming elements and returning values of the output object | * * @returns `object` * * @example * toObjectWith(['one', 'two', 'three'], value => value) * // -> { one: 'one', two: 'two', three: 'three' } * * toObjectWith(['one', 'two', 'three'], value => { * switch (value) { * case 'one': return [1] * case 'two': return [2] * case 'three': return [3] * } * }) * // -> { one: [1], two: [2], three: [3] } * * @see toObject * @since v1.0.0 * @tag utilities * @tag collections */ interface ToObjectWith { (value: null | undefined, fn: (value: never) => any): {} (value: T, fn: (value: T) => U): Record, U> , U extends any> (value: T, fn: (value: MapValue) => U): Record, U> , U extends any> (value: T, fn: (value: IterableValue) => U): Record, U> > (value: T, fn: (...args: any[]) => any): T } declare const toObjectWith: ToObjectWith export = toObjectWith