0.1.1 • Published 11 years ago

keymirror v0.1.1

Weekly downloads
183,485
License
-
Repository
github
Last release
11 years ago

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.

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)
@dterekhova/schemas@applicaster/zapp-react-native-default-playerextension-chromemaicai.m.ddxq.mobitest-l-hreact-native-video-forkeddekoa-hdmircoai-guiscratch-gui-freerangenodebb-plugin-custom-fields-vitereact-testcardreact-native-webview-bridge-fork@atlastix/euiuca-service@infinitebrahmanuniverse/nolb-keymglitchyscratch-guidl-react-native-mock-render@everything-registry/sub-chunk-2012blockzie-guitap-fluxtd-stylekitwxpay-nodejsxbuilder-formswftda-bouttimexiaoyaoji-mock-serverxiaoyaoji-mock-server-cookiexl-react-componentsscratch-guisuny-guitest_fabtest_fabric_controllersupport-bundle-uploadtf-react-map-glvizceral-examplevooks-video-playervisualtesting-apivd_chooservasanthmortarjs@bpanel/bpanel-ui@runaway518/react-native-mock-renderjison-debuggeritch-scratch-guiiris-react-webrtcixaris-uxfioauthoringkepler.gl-forked-ismakutlkepler.gl.geoiqkepler.gl.sh.customlatitude-flexporthuge-tablein1t-react-native-videoima-playergulp-jscs-html-reporterhappycode-painthasoopiobeam-clientlevel-explorelocker-factoryleaf-orientlongevo-react-native-videolivialivia-orientdblivia-titanmaglevkyy-react-native-videold-schedulerkulbot-guikjdshfskdjhfskdjhsdjkhgfdjhskgfmemory-alpha@wanmi/react-native-video@wbur/react-google-publisher-tag@wrethink/react-native-video@uhaider15/constants@uhaider15/layers@uhaider15/schemas@uhaider15/utils@tiarebalbi/flux-main-sample@tychot/gql@tommy2gis/swsk.kepler.gl@thang2162/react-native-video@tomjamesallen/react-flux-boilerplate@vikk2411/react-data-grid@useoptic/ui@yanv1991/react-native-video-with-ads-v2@youpen/react-native-webview-bridge@xyezir/orientose@yakies/cli@zalastax/nolb-keymRhinoStyleGoldfishakid-guiaikitten-paintaitl-processoractor-sdkalinkRNTestbaba-jsarachne-uiarachne-ui-componentsaqmthai.js@iotracks/fog-controller
0.1.1

11 years ago

0.1.0

11 years ago