utils
Version:
Fast, generic JavaScript/node.js utility functions.
25 lines (20 loc) • 408 B
JavaScript
;
var isString = require('./isString');
var chop = require('./chop');
/**
* Replace spaces in a string with hyphens. This
*
* ```js
* hyphenate("a b c");
* //=> 'a-b-c'
* ```
*
* @name .hyphenate
* @param {String} `string`
* @return {String}
* @api public
*/
module.exports = function hyphenate(str) {
if (!isString(str)) return '';
return chop(str).split(' ').join('-');
};