src/index.js
function getCaseRanking(testString) {
  const containsUpperCase = testString.toLowerCase() !== testString
  const containsDash = testString.indexOf('-') >= 0
  const containsUnderscore = testString.indexOf('_') >= 0

  if (!containsUpperCase && !containsUnderscore && containsDash) {
    return caseRankings.KEBAB
  }

  if (!containsUpperCase && containsUnderscore && !containsDash) {
    return caseRankings.SNAKE
  }

  if (containsUpperCase && !containsDash && !containsUnderscore) {
    const startsWithUpperCase = testString[0].toUpperCase() === testString[0]
    if (startsWithUpperCase) {
      return caseRankings.PASCAL
    }

    return caseRankings.CAMEL
  }

  return caseRankings.NO_CASE
}
function getCaseRanking(testString) {
  const containsUpperCase = testString.toLowerCase() !== testString
  const containsDash = testString.indexOf('-') >= 0
  const containsUnderscore = testString.indexOf('_') >= 0

  if (!containsUpperCase && !containsUnderscore && containsDash) {
    return caseRankings.KEBAB
  }

  if (!containsUpperCase && containsUnderscore && !containsDash) {
    return caseRankings.SNAKE
  }

  if (containsUpperCase && !containsDash && !containsUnderscore) {
    const startsWithUpperCase = testString[0].toUpperCase() === testString[0]
    if (startsWithUpperCase) {
      return caseRankings.PASCAL
    }

    return caseRankings.CAMEL
  }

  return caseRankings.NO_CASE
}
function getCaseRanking ( testString ) { const containsUpperCase = testString . toLowerCase ( ) !== testString const containsDash = testString . indexOf ( '-' ) >= 0 const containsUnderscore = testString . indexOf ( '_' ) >= 0 if ( ! containsUpperCase && ! containsUnderscore && containsDash ) { return caseRankings . KEBAB } if ( ! containsUpperCase && containsUnderscore && ! containsDash ) { return caseRankings . SNAKE } if ( containsUpperCase && ! containsDash && ! containsUnderscore ) { const startsWithUpperCase = testString [ 0 ] . toUpperCase ( ) === testString [ 0 ] if ( startsWithUpperCase ) { return caseRankings . PASCAL } return caseRankings . CAMEL } return caseRankings . NO_CASE }
Returns a score base on the case of the testString
@param {String} testString - the string to test against
@returns {Number} the number of the ranking,
based on the case between 0 and 1 for how the testString matches the case
Returns a score base on the case of the testString