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 hyphenate 10 * @typechecks 11 */ 12 13var _uppercasePattern = /([A-Z])/g; 14 15/** 16 * Hyphenates a camelcased string, for example: 17 * 18 * > hyphenate('backgroundColor') 19 * < "background-color" 20 * 21 * For CSS style names, use `hyphenateStyleName` instead which works properly 22 * with all vendor prefixes, including `ms`. 23 * 24 * @param {string} string 25 * @return {string} 26 */ 27function hyphenate(string) { 28 return string.replace(_uppercasePattern, '-$1').toLowerCase(); 29} 30 31module.exports = hyphenate; 32 33