UNPKG

moltres-utils

Version:
38 lines (32 loc) 1.07 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _capitalize = _interopRequireDefault(require("./capitalize")); var _words = _interopRequireDefault(require("./words")); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Converts `string` to [camel case](https://en.wikipedia.org/wiki/CamelCase). * * @param {string} [string=''] The string to convert. * @returns {string} Returns the camel cased string. * @see lowerCase, kebabCase, snakeCase, startCase, upperCase, upperFirst * @example * * camelCase('Foo Bar') * // => 'fooBar' * * camelCase('--foo-bar--') * // => 'fooBar' * * camelCase('__FOO_BAR__') * // => 'fooBar' */ const camelCase = string => (0, _words.default)(`${string}`.replace(/['\u2019]/g, '')).reduce((result, word, index) => { word = word.toLowerCase(); return result + (index ? (0, _capitalize.default)(word) : word); }, ''); var _default = camelCase; exports.default = _default; //# sourceMappingURL=camelCase.js.map