UNPKG

ramda-extension

Version:

Helpful functions built on top of the mighty Ramda

30 lines (27 loc) 810 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _ramda = require("ramda"); /** * For not-nil string returns string where every single word starts with a capital letter. * * @func * @category String * * @param {any} x Any string * @return {any} String where every word starts with upper-case letter * * @example * * R_.capitalizeAll('seek and destroy') // Seek And Destroy * R_.capitalizeAll('Seek And Destroy') // Seek And Destroy * R_.capitalizeAll(null) // null * R_.capitalizeAll(undefined) // undefined * * @sig String -> String */ var capitalizeAll = (0, _ramda.unless)(_ramda.isNil, (0, _ramda.replace)(/(\b\w(?!\s))/g, _ramda.toUpper)); var _default = capitalizeAll; exports.default = _default;