ramda-extension
Version:
Helpful functions built on top of the mighty Ramda
20 lines (19 loc) • 611 B
JavaScript
import { o, map, toLower } from 'ramda';
import splitByNonAlphaNumeric from './splitByNonAlphaNumeric';
import joinWithUnderscore from './joinWithUnderscore';
/**
* Converts string into snake_case.
*
* @func
* @category String
*
* @example
*
* R_.toSnakeCase('hello-world') // 'hello_world'
* R_.toSnakeCase('hello- world') // 'hello_world'
* R_.toSnakeCase(' hello-/ world/ ') // 'hello_world'
*
* @sig String -> String
*/
var toSnakeCase = /*#__PURE__*/o(joinWithUnderscore, /*#__PURE__*/o( /*#__PURE__*/map(toLower), splitByNonAlphaNumeric));
export default toSnakeCase;