Пример #1
0
    }).then(function(statsResults) {
        var outTable = new CliTable({
            head: ['version', 'name', 'size (min)']
        });

        outTable.push.apply(outTable, _.map(statsResults, function(result) {
            return [result.name, result.version, result.size];
        }));

        console.log(outTable.toString());
    }).fail(_.flow(_.property('stack'), console.error));
Пример #2
0
module.exports = function getStats(depVersions) {
    return q.all(_.map(getMatchedDeps(depVersions), function(matchedDep, depName) {
        return qHttp.request(matchedDep.url.replace(/^\/\//, 'http://')).then(function(res) {
            if (res.status < 200 || res.status >= 300) {
                return null;
            }

            return res.body.read().then(function(bodyBuf) {
                return _.safeMerge(matchedDep, {
                    name: depName,
                    version: matchedDep.version,
                    size: numeral(bodyBuf.length).format('0.0b')
                });
            });
        });
    })).then(_.compact);
};