{"size": 579, "ext": "js", "max_stars_repo_path": "assets/js/npm.js", "max_stars_repo_name": "autofelix/autofelix", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "assets/js/npm.js", "max_issues_repo_name": "autofelix/autofelix", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "assets/js/npm.js", "max_forks_repo_name": "autofelix/autofelix", "max_forks_repo_forks_event_min_datetime": "2022-03-31T06:42:50.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-31T06:42:50.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 34.0588235294, "max_line_length": 72, "alphanum_fraction": 0.7288428325}
const config = require('./config')
const { getNPMPackages, getNPMPackagesDownloads } = require('./service')

exports.getNPMDownloadsMap = async () => {
  const packageDownloadsMap = new Map()
  const packages = await getNPMPackages(config.NPM_UID)
  await Promise.all(
    packages.map(async (package) => {
      const packageName = package.package.name
      const downloadsResult = await getNPMPackagesDownloads(packageName)
      const downloads = downloadsResult?.downloads || 0
      packageDownloadsMap.set(packageName, downloads)
    })
  )

  return packageDownloadsMap
}