-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
27 lines (25 loc) · 947 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
'use strict';
var registry = require('npm-stats')();
var packageJson = require('package-json');
var PJV = require('package-json-validator').PJV;
var asyncMap = require('async').map
module.exports = function (username, cb) {
if (typeof username !== 'string') {
throw new TypeError('Expected a string');
}
registry.user(username).list( function (err,modules) {
asyncMap(modules, function(module, callback) {
packageJson(module, 'latest', function (err, json) {
if (err) return callback(err);
callback(null, {
module: module,
homepage: json.homepage,
description: json.description,
info : PJV.validate(JSON.stringify(json), "npm", {warnings: true, recommendations: true})
});
})
}, function(err, results) {
cb(err, results);
});
});
};