keymirror

WebJar for keymirror

Лицензия

Лицензия

Категории

Категории

KeY Данные Data Formats Formal Verification Mirror Библиотеки уровня приложения Introspection
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

keymirror
Последняя версия

Последняя версия

0.1.1
Дата

Дата

Тип

Тип

jar
Описание

Описание

keymirror
WebJar for keymirror
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/STRML/keyMirror

Скачать keymirror

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/keymirror/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>keymirror</artifactId>
    <version>0.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/keymirror/
implementation 'org.webjars.npm:keymirror:0.1.1'
// https://jarcasting.com/artifacts/org.webjars.npm/keymirror/
implementation ("org.webjars.npm:keymirror:0.1.1")
'org.webjars.npm:keymirror:jar:0.1.1'
<dependency org="org.webjars.npm" name="keymirror" rev="0.1.1">
  <artifact name="keymirror" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='keymirror', version='0.1.1')
)
libraryDependencies += "org.webjars.npm" % "keymirror" % "0.1.1"
[org.webjars.npm/keymirror "0.1.1"]

Зависимости

Библиотека не имеет зависимостей. Это самодостаточное приложение, которое не зависит ни от каких других библиотек.

Модули Проекта

Данный проект не имеет модулей.

KeyMirror

Create an object with values equal to its key names.

I thought react/lib/keyMirror was useful and wanted to reuse it without any dependencies.

This is not my code, this is property of Facebook.

Why?

From this discussion:

The main purpose of keyMirror is to deal with the fact that Closure Compiler advanced mode crushes keys, which allows you to write code like

keyMirror({monkey: null, gorilla: null})

and have it become something like

k({m:null,g:null})

which evaluates to

{m:"m",g:"g"}

at runtime. If it was specified as a list of strings, they wouldn't get crushed matching the property names.

Usage

npm install keymirror

var keyMirror = require('keymirror');
var COLORS = keyMirror({blue: null, red: null});
var myColor = COLORS.blue;
var isColorValid = !!COLORS[myColor];

The last line could not be performed if the values of the generated enum were not equal to their keys.

Input: {key1: val1, key2: val2}

Output: {key1: key1, key2: key2}

I sometimes use this with lodash - use the following upon your first use of lodash to mix it in:

var _ = require('lodash');
_.mixin({keyMirror: require('keymirror')});
// Can now be used as _.keyMirror(object)

Версии библиотеки

Версия
0.1.1