nl_tokens: Make a string code friendly . Camel cases a dirty string into a valid javascript variable / constructor name ; Uses replaceStrRegex to replace unwanted characters with a - and then splits and merges the parts with the proper casing pass in true for lcaseFirst to lower case the first character .
pl_tokens: function camelCase ( str , upperFirst , replaceStrRegex ) { upperFirst = upperFirst || false ; replaceStrRegex = replaceStrRegex || / [^a-z\d] / i ; var newStr = '' , // Get clean string parts = str . <mask> ( replaceStrRegex ) ; // Upper Case First char for parts parts . forEach ( function ( part ) { // If alpha chars if ( / [a-z\d] / . test ( part ) ) { // ucase first char and append to new string, // if part is a digit just gets returned by `ucaseFirst` newStr += ucaseFirst ( part ) ; } } ) ; // If should not be upper case first if ( ! upperFirst ) { // Then lower case first newStr = lcaseFirst ( newStr ) ; } return newStr ; }