src/pluralize.js
function restoreCase (word, token) {
  // Tokens are an exact match.
  if (word === token) return token

  // Upper cased words. E.g. "HELLO".
  if (word === word.toUpperCase()) return token.toUpperCase()

  // Title cased words. E.g. "Title".
  if (word[0] === word[0].toUpperCase()) {
    return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase()
  }

  // Lower cased words. E.g. "test".
  return token.toLowerCase()
}
function restoreCase (word, token) {
  // Tokens are an exact match.
  if (word === token) return token

  // Upper cased words. E.g. "HELLO".
  if (word === word.toUpperCase()) return token.toUpperCase()

  // Title cased words. E.g. "Title".
  if (word[0] === word[0].toUpperCase()) {
    return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase()
  }

  // Lower cased words. E.g. "test".
  return token.toLowerCase()
}
function restoreCase ( word , token ) { // Tokens are an exact match. if ( word === token ) return token // Upper cased words. E.g. "HELLO". if ( word === word . toUpperCase ( ) ) return token . toUpperCase ( ) // Title cased words. E.g. "Title". if ( word [ 0 ] === word [ 0 ] . toUpperCase ( ) ) { return token . charAt ( 0 ) . toUpperCase ( ) + token . substr ( 1 ) . toLowerCase ( ) } // Lower cased words. E.g. "test". return token . toLowerCase ( ) }
Pass in a word token to produce a function that can replicate the case on
another word.

@param  {string}   word
@param  {string}   token
@return {Function}
Pass in a word token to produce a function that can replicate the case on another word .