ramda-extension
Version:
Helpful functions built on top of the mighty Ramda
22 lines (21 loc) • 704 B
JavaScript
import { replace, toLower, unless, isNil } from 'ramda';
/**
* For not-nil string returns string where every single word starts with a lower-case letter.
*
* @func
* @category String
*
* @param {any} x Any string
* @return {any} String where every word starts with lower-case letter
*
* @example
*
* R_.decapitalizeAll('Seek And Destroy') // seek and destroy
* R_.decapitalizeAll('seek and destroy') // seek and destroy
* R_.decapitalizeAll(null) // null
* R_.decapitalizeAll(undefined) // undefined
*
* @sig String -> String
*/
var decapitalizeAll = /*#__PURE__*/unless(isNil, /*#__PURE__*/replace(/(\b\w(?!\s))/g, toLower));
export default decapitalizeAll;