• Convert Array of the object to Object

    Returns

    Example

     const arr = [{name: 'john'}, {name: 'chris'}, {name: 'sravan'}, {name: 'hoon'}];
    const obj = arrayToMap(arr, 'name');

    console.log(obj);
    // {
    // 'john': {name: 'john'},
    // 'chris': {name: 'chris'},
    // 'sravan': {name: 'sravan'},
    // 'hoon': {name: 'hoon'}
    // }

    Type Parameters

    • T extends Record<K, unknown>

    • K extends string | number | symbol = keyof T

    Parameters

    Returns Record<string, T>

  • Convert Array of the object to Object

    Returns

    Example

     const arr = [{name: 'john'}, {name: 'chris'}, {name: 'sravan'}, {name: 'hoon'}];
    const obj = arrayToMap(arr, 'name');

    console.log(obj);
    // {
    // 'john': {name: 'john'},
    // 'chris': {name: 'chris'},
    // 'sravan': {name: 'sravan'},
    // 'hoon': {name: 'hoon'}
    // }

    Type Parameters

    • T extends Record<K, unknown>

    • K extends string | number | symbol = keyof T

    Parameters

    • arr: T[]
    • selector: string
    • fallbackSelector: K

    Returns Record<string, T>

  • Convert Array of the object to Object

    Returns

    Example

     const arr = [{name: 'john'}, {name: 'chris'}, {name: 'sravan'}, {name: 'hoon'}];
    const obj = arrayToMap(arr, 'name');

    console.log(obj);
    // {
    // 'john': {name: 'john'},
    // 'chris': {name: 'chris'},
    // 'sravan': {name: 'sravan'},
    // 'hoon': {name: 'hoon'}
    // }

    Type Parameters

    • T extends Record<K, unknown>

    • K extends string | number | symbol = keyof T

    Parameters

    • arr: T[]
    • selector: string
    • selector2: string
    • combineKey: true

    Returns Record<string, T>

Generated using TypeDoc