index.js
function isMatch(file, license, rate, srcNLReg) {
        var srcLines = file.contents.toString('utf8').split(/\r?\n/),
                templateLines = license.split(/\r?\n/),
                type = path.extname(file.path),
                matchRates = 0,
                removed = false;

        // after '<?php' has new line, remove it 
        switch (type) {
            case '.php':
                if (srcLines[1].replace(/\s/, '') === '') {
                    srcLines.splice(1, 1);
                    removed = true;
                }
                break;
            default:
                break;
        }

        // count match line
        var minLength = templateLines.length > srcLines.length ? srcLines.length : templateLines.length;
        for (var i = 0; i < minLength; i++) {
            if (templateLines[templateLines.length - 1] === '' && i === templateLines.length - 1) {
                matchRates += 1;
            } else {
                switch (type) {
                    case '.php':
                        matchRates += getMatchRate(srcLines[i + 1], templateLines[i]);
                        break;
                    default:
                        matchRates += getMatchRate(srcLines[i], templateLines[i]);
                        break;
                }
            }
        }

        // has similar license, remove the license.
        var matchPer = matchRates / templateLines.length;

        if (matchPer >= rate && matchPer < 1) {
            // remove
            switch (type) {
                case '.php':
                    if (srcLines[templateLines.length].replace(/\s/, '') === '' && !removed) {
                        // after license, should be have a blank line. if has not, we don't need remove blank line. && after '<?php' has not new line
                        srcLines.splice(1, templateLines.length);
                    } else {
                        srcLines.splice(1, templateLines.length - 1);
                    }
                    file.contents = new Buffer(srcLines.join(srcNLReg));
                    break;
                default:
                    // after license, should be have a blank line. if have not, we don't need remove blank line.
                    if (srcLines[templateLines.length - 1].replace(/\s/, '') === '') {
                        srcLines.splice(0, templateLines.length);
                    } else {
                        srcLines.splice(0, templateLines.length - 1);
                    }
                    file.contents = new Buffer(srcLines.join(srcNLReg));
                    break;
            }
            return false;
        } else if (matchPer === 1) {
            return true;
        }
    }
function isMatch(file, license, rate, srcNLReg) {
        var srcLines = file.contents.toString('utf8').split(/\r?\n/),
                templateLines = license.split(/\r?\n/),
                type = path.extname(file.path),
                matchRates = 0,
                removed = false;

        // after '<?php' has new line, remove it 
        switch (type) {
            case '.php':
                if (srcLines[1].replace(/\s/, '') === '') {
                    srcLines.splice(1, 1);
                    removed = true;
                }
                break;
            default:
                break;
        }

        // count match line
        var minLength = templateLines.length > srcLines.length ? srcLines.length : templateLines.length;
        for (var i = 0; i < minLength; i++) {
            if (templateLines[templateLines.length - 1] === '' && i === templateLines.length - 1) {
                matchRates += 1;
            } else {
                switch (type) {
                    case '.php':
                        matchRates += getMatchRate(srcLines[i + 1], templateLines[i]);
                        break;
                    default:
                        matchRates += getMatchRate(srcLines[i], templateLines[i]);
                        break;
                }
            }
        }

        // has similar license, remove the license.
        var matchPer = matchRates / templateLines.length;

        if (matchPer >= rate && matchPer < 1) {
            // remove
            switch (type) {
                case '.php':
                    if (srcLines[templateLines.length].replace(/\s/, '') === '' && !removed) {
                        // after license, should be have a blank line. if has not, we don't need remove blank line. && after '<?php' has not new line
                        srcLines.splice(1, templateLines.length);
                    } else {
                        srcLines.splice(1, templateLines.length - 1);
                    }
                    file.contents = new Buffer(srcLines.join(srcNLReg));
                    break;
                default:
                    // after license, should be have a blank line. if have not, we don't need remove blank line.
                    if (srcLines[templateLines.length - 1].replace(/\s/, '') === '') {
                        srcLines.splice(0, templateLines.length);
                    } else {
                        srcLines.splice(0, templateLines.length - 1);
                    }
                    file.contents = new Buffer(srcLines.join(srcNLReg));
                    break;
            }
            return false;
        } else if (matchPer === 1) {
            return true;
        }
    }
function isMatch ( file , license , rate , srcNLReg ) { var srcLines = file . contents . toString ( 'utf8' ) . split ( / \r?\n / ) , templateLines = license . split ( / \r?\n / ) , type = path . extname ( file . path ) , matchRates = 0 , removed = false ; // after '<?php' has new line, remove it  switch ( type ) { case '.php' : if ( srcLines [ 1 ] . replace ( / \s / , '' ) === '' ) { srcLines . splice ( 1 , 1 ) ; removed = true ; } break ; default : break ; } // count match line var minLength = templateLines . length > srcLines . length ? srcLines . length : templateLines . length ; for ( var i = 0 ; i < minLength ; i ++ ) { if ( templateLines [ templateLines . length - 1 ] === '' && i === templateLines . length - 1 ) { matchRates += 1 ; } else { switch ( type ) { case '.php' : matchRates += getMatchRate ( srcLines [ i + 1 ] , templateLines [ i ] ) ; break ; default : matchRates += getMatchRate ( srcLines [ i ] , templateLines [ i ] ) ; break ; } } } // has similar license, remove the license. var matchPer = matchRates / templateLines . length ; if ( matchPer >= rate && matchPer < 1 ) { // remove switch ( type ) { case '.php' : if ( srcLines [ templateLines . length ] . replace ( / \s / , '' ) === '' && ! removed ) { // after license, should be have a blank line. if has not, we don't need remove blank line. && after '<?php' has not new line srcLines . splice ( 1 , templateLines . length ) ; } else { srcLines . splice ( 1 , templateLines . length - 1 ) ; } file . contents = new Buffer ( srcLines . join ( srcNLReg ) ) ; break ; default : // after license, should be have a blank line. if have not, we don't need remove blank line. if ( srcLines [ templateLines . length - 1 ] . replace ( / \s / , '' ) === '' ) { srcLines . splice ( 0 , templateLines . length ) ; } else { srcLines . splice ( 0 , templateLines . length - 1 ) ; } file . contents = new Buffer ( srcLines . join ( srcNLReg ) ) ; break ; } return false ; } else if ( matchPer === 1 ) { return true ; } }
According to rate, get matching.

@param {object} file nodeJS file object.
@param {string} license The license template string.
@param {float} rate Matching rate.
@param {string} srcNLReg new line char code.
@returns {boolean} dose match.
According to rate get matching .