twitst4tz

twitter statistics web application
Log | Files | Refs | README | LICENSE

index.js (490B)


      1 /*!
      2  * toidentifier
      3  * Copyright(c) 2016 Douglas Christopher Wilson
      4  * MIT Licensed
      5  */
      6 
      7 /**
      8  * Module exports.
      9  * @public
     10  */
     11 
     12 module.exports = toIdentifier
     13 
     14 /**
     15  * Trasform the given string into a JavaScript identifier
     16  *
     17  * @param {string} str
     18  * @returns {string}
     19  * @public
     20  */
     21 
     22 function toIdentifier (str) {
     23   return str
     24     .split(' ')
     25     .map(function (token) {
     26       return token.slice(0, 1).toUpperCase() + token.slice(1)
     27     })
     28     .join('')
     29     .replace(/[^ _0-9a-z]/gi, '')
     30 }