1/** 2 * Copyright 2013-2014, Facebook, Inc. 3 * All rights reserved. 4 * 5 * This source code is licensed under the BSD-style license found in the 6 * LICENSE file in the root directory of this source tree. An additional grant 7 * of patent rights can be found in the PATENTS file in the same directory. 8 * 9 * @providesModule keyOf 10 */ 11 12/** 13 * Allows extraction of a minified key. Let's the build system minify keys 14 * without loosing the ability to dynamically use key strings as values 15 * themselves. Pass in an object with a single key/val pair and it will return 16 * you the string key of that single record. Suppose you want to grab the 17 * value for a key 'className' inside of an object. Key/val minification may 18 * have aliased that key to be 'xa12'. keyOf({className: null}) will return 19 * 'xa12' in that case. Resolve keys you want to use once at startup time, then 20 * reuse those resolutions. 21 */ 22var keyOf = function(oneKeyObj) { 23 var key; 24 for (key in oneKeyObj) { 25 if (!oneKeyObj.hasOwnProperty(key)) { 26 continue; 27 } 28 return key; 29 } 30 return null; 31}; 32 33 34module.exports = keyOf; 35 36