src/metrics/distance/jaro-winkler.js
function customJaroWinkler(options, a, b) {
  options = options || {};

  const {
    boostThreshold = 0.7,
    scalingFactor = 0.1
  } = options;

  if (scalingFactor > 0.25)
    throw Error('talisman/metrics/distance/jaro-winkler: the scaling factor should not exceed 0.25.');

  if (boostThreshold < 0 || boostThreshold > 1)
    throw Error('talisman/metrics/distance/jaro-winkler: the boost threshold should be comprised between 0 and 1.');

  // Fast break
  if (a === b)
    return 1;

  // Computing Jaro-Winkler score
  const dj = jaro(a, b);

  if (dj < boostThreshold)
    return dj;


  const p = scalingFactor;
  let l = 0;

  const prefixLimit = Math.min(a.length, b.length, 4);

  // Common prefix (up to 4 characters)
  for (let i = 0; i < prefixLimit; i++) {
    if (a[i] === b[i])
      l++;
    else
      break;
  }

  return dj + (l * p * (1 - dj));
}
function customJaroWinkler(options, a, b) {
  options = options || {};

  const {
    boostThreshold = 0.7,
    scalingFactor = 0.1
  } = options;

  if (scalingFactor > 0.25)
    throw Error('talisman/metrics/distance/jaro-winkler: the scaling factor should not exceed 0.25.');

  if (boostThreshold < 0 || boostThreshold > 1)
    throw Error('talisman/metrics/distance/jaro-winkler: the boost threshold should be comprised between 0 and 1.');

  // Fast break
  if (a === b)
    return 1;

  // Computing Jaro-Winkler score
  const dj = jaro(a, b);

  if (dj < boostThreshold)
    return dj;


  const p = scalingFactor;
  let l = 0;

  const prefixLimit = Math.min(a.length, b.length, 4);

  // Common prefix (up to 4 characters)
  for (let i = 0; i < prefixLimit; i++) {
    if (a[i] === b[i])
      l++;
    else
      break;
  }

  return dj + (l * p * (1 - dj));
}
function customJaroWinkler ( options , a , b ) { options = options || { } ; const { boostThreshold = 0.7 , scalingFactor = 0.1 } = options ; if ( scalingFactor > 0.25 ) throw Error ( 'talisman/metrics/distance/jaro-winkler: the scaling factor should not exceed 0.25.' ) ; if ( boostThreshold < 0 || boostThreshold > 1 ) throw Error ( 'talisman/metrics/distance/jaro-winkler: the boost threshold should be comprised between 0 and 1.' ) ; // Fast break if ( a === b ) return 1 ; // Computing Jaro-Winkler score const dj = jaro ( a , b ) ; if ( dj < boostThreshold ) return dj ; const p = scalingFactor ; let l = 0 ; const prefixLimit = Math . min ( a . length , b . length , 4 ) ; // Common prefix (up to 4 characters) for ( let i = 0 ; i < prefixLimit ; i ++ ) { if ( a [ i ] === b [ i ] ) l ++ ; else break ; } return dj + ( l * p * ( 1 - dj ) ) ; }
Function returning the Jaro-Winkler score between two sequences.

@param  {object} options - Custom options.
@param  {mixed}  a       - The first sequence.
@param  {mixed}  b       - The second sequence.
@return {number}         - The Jaro-Winkler score between a & b.
Function returning the Jaro - Winkler score between two sequences .