chore: merge Tests for check flat case (#689)

* update function documentation and name to match js convention

* add additional documentation explaining what the function does

* add tests for checkFlatCase function

* fix standard.js errors
This commit is contained in:
Charlie Moore
2021-09-19 02:45:47 -04:00
committed by GitHub
parent 401ccd0200
commit e40c62ddd8
2 changed files with 26 additions and 6 deletions

View File

@ -1,13 +1,15 @@
// CheckFlatCase method checks the given string is in flatcase or not.
// checkFlatCase method checks if the given string is in flatcase or not. Flatcase is a convention
// where all letters are in lowercase, and there are no spaces between words.
// thisvariable is an example of flatcase. In camelCase it would be thisVariable, snake_case this_variable and so on.
// Problem Source & Explanation: https://en.wikipedia.org/wiki/Naming_convention_(programming)
/**
* CheckFlatCase method returns true if the string in flatcase, else return the false.
* @param {String} varname the name of the variable to check.
* @returns `Boolean` return true if the string is in flatcase, else return false.
* checkFlatCase method returns true if the string in flatcase, else return the false.
* @param {string} varname the name of the variable to check.
* @returns {boolean} return true if the string is in flatcase, else return false.
*/
const CheckFlatCase = (varname) => {
const checkFlatCase = (varname) => {
// firstly, check that input is a string or not.
if (typeof varname !== 'string') {
return new TypeError('Argument is not a string.')
@ -17,4 +19,4 @@ const CheckFlatCase = (varname) => {
return pat.test(varname)
}
module.exports = CheckFlatCase
export { checkFlatCase }