MCPcopy Create free account
hub / github.com/jakesgordon/javascript-state-machine / camelize

Function camelize

lib/state-machine.js:155–172  ·  view source on GitHub ↗
(label)

Source from the content-addressed store, hash-verified

153//-------------------------------------------------------------------------------------------------
154
155function camelize(label) {
156
157 if (label.length === 0)
158 return label;
159
160 var n, result, word, words = label.split(/[_-]/);
161
162 // single word with first character already lowercase, return untouched
163 if ((words.length === 1) && (words[0][0].toLowerCase() === words[0][0]))
164 return label;
165
166 result = words[0].toLowerCase();
167 for(n = 1 ; n < words.length ; n++) {
168 result = result + words[n].charAt(0).toUpperCase() + words[n].substring(1).toLowerCase();
169 }
170
171 return result;
172}
173
174//-------------------------------------------------------------------------------------------------
175

Callers 2

state-machine.jsFile · 0.70
buildFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected