Function remapProperties

  • Returns a new object with the specified properties mapped to the given object.

    Type Parameters

    • T extends object
    • UArr extends readonly [readonly (keyof T)[], U][]
    • U extends string | number | symbol = UArr[number][1]

    Parameters

    Returns {
        [K in UArr[number][1]]: T[keyof T]
    }

    Example

    // returns { foo: 'bar' }
    remapProperties({ oof: 'bar' }, [[['oof'], 'foo']]);
  • Returns a new object with the specified properties mapped to the given object.

    Type Parameters

    • T extends object
    • UArr extends readonly [readonly (keyof T)[], U][]
    • U extends string | number | symbol = UArr[number][1]

    Parameters

    • obj: T
    • props: UArr
    • merge: "merge"

    Returns T & {
        [K in UArr[number][1]]: T[keyof T]
    }

    Example

    // returns { foo: 'bar' }
    remapProperties({ oof: 'bar' }, [[['oof'], 'foo']]);