conveyal/modeify

View on GitHub
client/components/ianstormtaylor/to-capital-case/0.1.1/index.js

Summary

Maintainability
A
0 mins
Test Coverage

var clean = require('to-no-case');


/**
 * Expose `toCapitalCase`.
 */

module.exports = toCapitalCase;


/**
 * Convert a `string` to capital case.
 *
 * @param {String} string
 * @return {String}
 */


function toCapitalCase (string) {
  return clean(string).replace(/(^|\s)(\w)/g, function (matches, previous, letter) {
    return previous + letter.toUpperCase();
  });
}