index.js
function compareNames(a, b) {
	if (!isArray(a)) a = splitAuthorString(a);
	if (!isArray(b)) b = splitAuthorString(b);

	var aPos = 0, bPos = 0;
	var authorLimit = Math.min(a.length, b.length);
	var failed = false;

	while (aPos < authorLimit && bPos < authorLimit) {
		if (fuzzyStringCompare(a[aPos], b[bPos])) { // Direct or fuzzy matching of entire strings
			aPos++;
			bPos++;
		} else {
			var aAuth = splitAuthor(a[aPos]);
			var bAuth = splitAuthor(b[bPos]);
			var nameLimit = Math.min(aAuth.length, bAuth.length);
			var nameMatches = 0;
			for (var n = 0; n < nameLimit; n++) {
				if (
					aAuth[n] == bAuth[n] || // Direct match
					aAuth[n].length == 1 && bAuth[n].substr(0, 1) || // A is initial and B is full name
					bAuth[n].length == 1 && aAuth[n].substr(0, 1) ||
					(aAuth[n].length > 1 && bAuth[n].length > 1 && fuzzyStringCompare(aAuth[n], bAuth[n], 3))
				) {
					nameMatches++;
				}
			}

			if (nameMatches >= nameLimit) {
				aPos++;
				bPos++;
			} else {
				failed = true;
			}
			break;
		}
	}
	return !failed;
}
function compareNames(a, b) {
	if (!isArray(a)) a = splitAuthorString(a);
	if (!isArray(b)) b = splitAuthorString(b);

	var aPos = 0, bPos = 0;
	var authorLimit = Math.min(a.length, b.length);
	var failed = false;

	while (aPos < authorLimit && bPos < authorLimit) {
		if (fuzzyStringCompare(a[aPos], b[bPos])) { // Direct or fuzzy matching of entire strings
			aPos++;
			bPos++;
		} else {
			var aAuth = splitAuthor(a[aPos]);
			var bAuth = splitAuthor(b[bPos]);
			var nameLimit = Math.min(aAuth.length, bAuth.length);
			var nameMatches = 0;
			for (var n = 0; n < nameLimit; n++) {
				if (
					aAuth[n] == bAuth[n] || // Direct match
					aAuth[n].length == 1 && bAuth[n].substr(0, 1) || // A is initial and B is full name
					bAuth[n].length == 1 && aAuth[n].substr(0, 1) ||
					(aAuth[n].length > 1 && bAuth[n].length > 1 && fuzzyStringCompare(aAuth[n], bAuth[n], 3))
				) {
					nameMatches++;
				}
			}

			if (nameMatches >= nameLimit) {
				aPos++;
				bPos++;
			} else {
				failed = true;
			}
			break;
		}
	}
	return !failed;
}
function compareNames ( a , b ) { if ( ! isArray ( a ) ) a = splitAuthorString ( a ) ; if ( ! isArray ( b ) ) b = splitAuthorString ( b ) ; var aPos = 0 , bPos = 0 ; var authorLimit = Math . min ( a . length , b . length ) ; var failed = false ; while ( aPos < authorLimit && bPos < authorLimit ) { if ( fuzzyStringCompare ( a [ aPos ] , b [ bPos ] ) ) { // Direct or fuzzy matching of entire strings aPos ++ ; bPos ++ ; } else { var aAuth = splitAuthor ( a [ aPos ] ) ; var bAuth = splitAuthor ( b [ bPos ] ) ; var nameLimit = Math . min ( aAuth . length , bAuth . length ) ; var nameMatches = 0 ; for ( var n = 0 ; n < nameLimit ; n ++ ) { if ( aAuth [ n ] == bAuth [ n ] || // Direct match aAuth [ n ] . length == 1 && bAuth [ n ] . substr ( 0 , 1 ) || // A is initial and B is full name bAuth [ n ] . length == 1 && aAuth [ n ] . substr ( 0 , 1 ) || ( aAuth [ n ] . length > 1 && bAuth [ n ] . length > 1 && fuzzyStringCompare ( aAuth [ n ] , bAuth [ n ] , 3 ) ) ) { nameMatches ++ ; } } if ( nameMatches >= nameLimit ) { aPos ++ ; bPos ++ ; } else { failed = true ; } break ; } } return ! failed ; }
Compare an array of authors against a second array
@param array a The first array of authors
@param array b The second array of authors
@return bolean True if a ≈ b
Compare an array of authors against a second array