Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for passing arrays #8

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

omnidan
Copy link

@omnidan omnidan commented Sep 13, 2015

this keyMirror({blue: null, red: null}) is equivalent to keyMirror(['blue', 'red']) now

having to write the nulls is redundant and makes the code longer when it doesn't need to be (if you don't use lodash)

this `keyMirror({blue: null, red: null})` is equivalent to `keyMirror(['blue', 'red'])` now

having to write the `null`s is redundant and makes the code longer when it doesn't need to be
@CatTail
Copy link

CatTail commented Sep 23, 2015

+1

@alex35mil
Copy link

Agreed, for those who don't use Closure Compiler advanced mode I posted lib to define constants via array: https://github.com/shakacode/mirror-creator

@tomkur
Copy link

tomkur commented Oct 27, 2015

👍

1 similar comment
@techapman
Copy link

👍

@kevzettler
Copy link

merge?

@ghost
Copy link

ghost commented Jan 6, 2020

  1. Not equivalent. This comment explains it well.

The main purpose of keyMirror is to deal with the fact that Closure Compiler advanced mode crushes keys... If it was specified as a list of strings, they wouldn't get crushed matching the property names.

  1. This will act as bloat to projects that don't (or won't ever use) mirrorArray(arr).

If you want to use arrays, try the npm package mirror-array-to-object.

@glanzz
Copy link

glanzz commented May 18, 2023

100%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants