UNPKG

d2-ui

Version:
23 lines (22 loc) 760 B
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = camelCaseToUnderscores; /** * Convert a camelCase word to its underscore_case equivalent * * @name camelCaseToUnderscores * @param {string} wordToTransform The string to transform. * @returns {string} The wordToTransform as a underscore separated string eg. camelCase -> camel_case * * @example * const word = 'HelloMyAmazingWorld'; * camelCaseToUnderscores(word); // Returns: 'hello_my_amazing_world' */ function camelCaseToUnderscores(wordToTransform) { return wordToTransform.replace(/[a-z][A-Z]/g, function (match) { return [match.charAt(0), match.charAt(1)].join('_'); }).toLowerCase(); } //# sourceMappingURL=camelCaseToUnderscores.js.map