src/phonetics/caverphone.js
function caverphone(rules, name) {

  if (typeof name !== 'string')
    throw Error('talisman/phonetics/caverphone: the given name is not a string.');

  // Preparing the name
  name = deburr(name)
    .toLowerCase()
    .replace(/[^a-z]/g, '');

  // Applying the rules
  for (let i = 0, l = rules.length; i < l; i++) {
    const [match, replacement] = rules[i];
    name = name.replace(match, replacement);
  }

  // Returning the padded code
  return pad(name);
}
function caverphone(rules, name) {

  if (typeof name !== 'string')
    throw Error('talisman/phonetics/caverphone: the given name is not a string.');

  // Preparing the name
  name = deburr(name)
    .toLowerCase()
    .replace(/[^a-z]/g, '');

  // Applying the rules
  for (let i = 0, l = rules.length; i < l; i++) {
    const [match, replacement] = rules[i];
    name = name.replace(match, replacement);
  }

  // Returning the padded code
  return pad(name);
}
function caverphone ( rules , name ) { if ( typeof name !== 'string' ) throw Error ( 'talisman/phonetics/caverphone: the given name is not a string.' ) ; // Preparing the name name = deburr ( name ) . toLowerCase ( ) . replace ( / [^a-z] / g , '' ) ; // Applying the rules for ( let i = 0 , l = rules . length ; i < l ; i ++ ) { const [ match , replacement ] = rules [ i ] ; name = name . replace ( match , replacement ) ; } // Returning the padded code return pad ( name ) ; }
Function taking a single name and computing its caverphone code.

@param  {array}  rules - The rules to use.
@param  {string} name  - The name to process.
@return {string}       - The caverphone code.

@throws {Error} The function expects the name to be a string.
Function taking a single name and computing its caverphone code .