# Module: mirror

Generates a key mirror (also known as key-value mirror), which is an object where for each property, the key is the same as the value.

import { mirror } from 'utilist';

mirror(['one', 'two']); // returns { one: 'one', two: 'two' };
mirror({ one: null, two: 'value' }); // returns { one: 'one', two: 'two' };

# Functions

# mirror

mirror(source: string[]): object

Defined in src/mirror.ts:18

Parameters:

Name Type Description
source string[] Either an array of strings or an object from where to pick the mirrored keys and values. If it's an object, the values will be overwritten.

Returns: object

  • [ key: string]: string

mirrorT, K›(source: T): object

Defined in src/mirror.ts:19

Type parameters:

T

K: keyof T

Parameters:

Name Type
source T

Returns: object

  • [ key: string]: K