Iterate over declarations, executing a callback function for each matched dependency.
function forEach(declarations, reqName, callback) {
        var d;
        if (reqName === "*") {
            // Iterate over all declarations.
            for (d in declarations) {
                callback.call(this, d);
            }
        } else if (reqName.charAt(reqName.length - 1) === "*") {
            // Iterate over uncapped `*` declarations.
            var baseName = reqName.substring(0, reqName.length - 1);
            for (d in declarations) {
                if (d.indexOf(baseName) === 0) {
                    callback.call(this, d);
                }
            }
        } else {
            // A single dependency iteration.
            if (declarations[reqName]) {
                callback.call(this, reqName);
            } else {
                error("Invalid dependency '" + reqName + "'");
            }
        }
    }