index.js
function getMatchRate(src, str) {
        if (typeof (src) === 'undefined' || typeof (str) === 'undefined') {
            return 0;
        }

        var maxLength = src.length > str.length ? src.length : str.length,
                matchCnt = 0;
        if (maxLength === 0) {
            return 1;
        }

        for (var i = 0; i < maxLength; i++) {
            if (str.charAt(i) === src.charAt(i)) {
                matchCnt++;
            }
        }

        if (matchCnt === 0) {
            return 0;
        }

        return matchCnt / maxLength;
    }
function getMatchRate(src, str) {
        if (typeof (src) === 'undefined' || typeof (str) === 'undefined') {
            return 0;
        }

        var maxLength = src.length > str.length ? src.length : str.length,
                matchCnt = 0;
        if (maxLength === 0) {
            return 1;
        }

        for (var i = 0; i < maxLength; i++) {
            if (str.charAt(i) === src.charAt(i)) {
                matchCnt++;
            }
        }

        if (matchCnt === 0) {
            return 0;
        }

        return matchCnt / maxLength;
    }
function getMatchRate ( src , str ) { if ( typeof ( src ) === 'undefined' || typeof ( str ) === 'undefined' ) { return 0 ; } var maxLength = src . length > str . length ? src . length : str . length , matchCnt = 0 ; if ( maxLength === 0 ) { return 1 ; } for ( var i = 0 ; i < maxLength ; i ++ ) { if ( str . charAt ( i ) === src . charAt ( i ) ) { matchCnt ++ ; } } if ( matchCnt === 0 ) { return 0 ; } return matchCnt / maxLength ; }
Compare each character for ever line, and get ever line match rate.

@param {type} src text for template.
@param {type} str text for file.
@returns {float} match rate.
Compare each character for ever line and get ever line match rate .