index.js
function getRecursiveHash(dependency, hashMap, dependencyMap) {

    // 递归分析出的完整的依赖列表
    var dependencies = [ ];
    var map = { };

    var addDependency = function (dependency) {
        // 要避免循环依赖
        if (!map[ dependency ]) {

            map[ dependency ] = 1;

            dependencies.push(dependency);

            var childDependencies = dependencyMap[ dependency ];
            if (Array.isArray(childDependencies)) {
                childDependencies.forEach(addDependency);
            }

        }
    };

    addDependency(dependency);

    // 按字母表顺序排序，确保每次顺序一致
    dependencies.sort(
        function (a, b) {
            if (a > b) {
                return 1;
            }
            else if (a < b) {
                return -1;
            }
            else {
                return 0;
            }
        }
    );

    var list = [ ];

    dependencies.forEach(
        function (dependency) {

            var hash = hashMap[ dependency ];
            if (hash) {
                list.push(hash);
            }

        }
    );

    var hash;

    switch (list.length) {
        case 0:
            hash = '';
            break;
        case 1:
            hash = list[0];
            break;
        default:
            hash = md5(new Buffer(list.join('')));
            break;
    }

    return hash;

}
function getRecursiveHash(dependency, hashMap, dependencyMap) {

    // 递归分析出的完整的依赖列表
    var dependencies = [ ];
    var map = { };

    var addDependency = function (dependency) {
        // 要避免循环依赖
        if (!map[ dependency ]) {

            map[ dependency ] = 1;

            dependencies.push(dependency);

            var childDependencies = dependencyMap[ dependency ];
            if (Array.isArray(childDependencies)) {
                childDependencies.forEach(addDependency);
            }

        }
    };

    addDependency(dependency);

    // 按字母表顺序排序，确保每次顺序一致
    dependencies.sort(
        function (a, b) {
            if (a > b) {
                return 1;
            }
            else if (a < b) {
                return -1;
            }
            else {
                return 0;
            }
        }
    );

    var list = [ ];

    dependencies.forEach(
        function (dependency) {

            var hash = hashMap[ dependency ];
            if (hash) {
                list.push(hash);
            }

        }
    );

    var hash;

    switch (list.length) {
        case 0:
            hash = '';
            break;
        case 1:
            hash = list[0];
            break;
        default:
            hash = md5(new Buffer(list.join('')));
            break;
    }

    return hash;

}
获取递归计算的 md5

@inner
@param {string} dependency
@param {Object} hashMap
@param {Object} dependencyMap
@return {string}