src/index.js
function isCaseAcronym(testString, stringToRank, caseRank) {
  let splitValue = null
  switch (caseRank) {
    case caseRankings.SNAKE:
      splitValue = '_'
      break
    case caseRankings.KEBAB:
      splitValue = '-'
      break
    case caseRankings.PASCAL:
    case caseRankings.CAMEL:
      splitValue = /(?=[A-Z])/
      break
    default:
      splitValue = null
  }

  const splitTestString = testString.split(splitValue)
  return stringToRank
    .toLowerCase()
    .split('')
    .reduce((correct, char, charIndex) => {
      const splitItem = splitTestString[charIndex]
      return correct && splitItem && splitItem[0].toLowerCase() === char
    }, true)
}
function isCaseAcronym(testString, stringToRank, caseRank) {
  let splitValue = null
  switch (caseRank) {
    case caseRankings.SNAKE:
      splitValue = '_'
      break
    case caseRankings.KEBAB:
      splitValue = '-'
      break
    case caseRankings.PASCAL:
    case caseRankings.CAMEL:
      splitValue = /(?=[A-Z])/
      break
    default:
      splitValue = null
  }

  const splitTestString = testString.split(splitValue)
  return stringToRank
    .toLowerCase()
    .split('')
    .reduce((correct, char, charIndex) => {
      const splitItem = splitTestString[charIndex]
      return correct && splitItem && splitItem[0].toLowerCase() === char
    }, true)
}
function isCaseAcronym ( testString , stringToRank , caseRank ) { let splitValue = null switch ( caseRank ) { case caseRankings . SNAKE : splitValue = '_' break case caseRankings . KEBAB : splitValue = '-' break case caseRankings . PASCAL : case caseRankings . CAMEL : splitValue = / (?=[A-Z]) / break default : splitValue = null } const splitTestString = testString . split ( splitValue ) return stringToRank . toLowerCase ( ) . split ( '' ) . reduce ( ( correct , char , charIndex ) => { const splitItem = splitTestString [ charIndex ] return correct && splitItem && splitItem [ 0 ] . toLowerCase ( ) === char } , true ) }
Check if stringToRank is an acronym for a partial case
@example
// returns true
isCaseAcronym('super_duper_file', 'sdf', caseRankings.SNAKE)
@param {String} testString - the string to test against
@param {String} stringToRank - the acronym to test
@param {Number} caseRank - the ranking of the case
@returns {Boolean} whether the stringToRank is an acronym for the testString
Check if stringToRank is an acronym for a partial case