diff --git a/README.md b/README.md index 0d015fbee..bb968c164 100644 --- a/README.md +++ b/README.md @@ -1204,9 +1204,9 @@ Omit the scond argument to use a default separator of '_'. const fromCamelCase = (str, separator = '_') => str.replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2') .replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + separator + '$2').toLowerCase(); -// decamelize('someDatabaseFieldName', ' ') -> 'some database field name' -// decamelize('someLabelThatNeedsToBeCamelized', '-') -> 'some-label-that-needs-to-be-camelized' -// decamelize('someJavascriptProperty', '_') -> 'some_javascript_property' +// fromCamelCase('someDatabaseFieldName', ' ') -> 'some database field name' +// fromCamelCase('someLabelThatNeedsToBeCamelized', '-') -> 'some-label-that-needs-to-be-camelized' +// fromCamelCase('someJavascriptProperty', '_') -> 'some_javascript_property' ``` [⬆ back to top](#table-of-contents) @@ -1218,10 +1218,10 @@ Use `replace()` to remove underscores, hyphens and spaces and convert words to c ```js const toCamelCase = str => str.replace(/^([A-Z])|[\s-_]+(\w)/g, (match, p1, p2, offset) => p2 ? p2.toUpperCase() : p1.toLowerCase()); -// camelize("some_database_field_name") -> 'someDatabaseFieldName' -// camelize("Some label that needs to be camelized") -> 'someLabelThatNeedsToBeCamelized' -// camelize("some-javascript-property") -> 'someJavascriptProperty' -// camelize("some-mixed_string with spaces_underscores-and-hyphens") -> 'someMixedStringWithSpacesUnderscoresAndHyphens' +// toCamelCase("some_database_field_name") -> 'someDatabaseFieldName' +// toCamelCase("Some label that needs to be camelized") -> 'someLabelThatNeedsToBeCamelized' +// toCamelCase("some-javascript-property") -> 'someJavascriptProperty' +// toCamelCase("some-mixed_string with spaces_underscores-and-hyphens") -> 'someMixedStringWithSpacesUnderscoresAndHyphens' ``` [⬆ back to top](#table-of-contents)