@samitouri / QOS-React-2 / commits / 8bbbe900a5

Sync out camelize module

For use in #1662

Paul O’Shannessy committed Jun 17, 2014 at 09:27 UTC 8bbbe900a525c4f85cfb1a5031c44da574684bc7
1 file changed +37
src/vendor/core/camelize.js new
+37
@@ -0,0 +1,37 @@
1 +/**
2 + * Copyright 2013-2014 Facebook, Inc.
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + *
16 + * @providesModule camelize
17 + * @typechecks
18 + */
19 +
20 +var _hyphenPattern = /-(.)/g;
21 +
22 +/**
23 + * Camelcases a hyphenated string, for example:
24 + *
25 + * > camelize('background-color')
26 + * < "backgroundColor"
27 + *
28 + * @param {string} string
29 + * @return {string}
30 + */
31 +function camelize(string) {
32 + return string.replace(_hyphenPattern, function(_, character) {
33 + return character.toUpperCase();
34 + });
35 +}
36 +
37 +module.exports = camelize;