source: trip-planner-front/node_modules/toidentifier/index.js@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 490 bytes
Line 
1/*!
2 * toidentifier
3 * Copyright(c) 2016 Douglas Christopher Wilson
4 * MIT Licensed
5 */
6
7/**
8 * Module exports.
9 * @public
10 */
11
12module.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
22function 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}
Note: See TracBrowser for help on using the repository browser.