Last active
November 13, 2021 20:56
-
-
Save tvolodimir/babaa553ad25a6a38276df597230f23e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const npmPackageName = "ts-morph"; // <--- change name | |
const got = require("got@11.8.2"); | |
const url = (name) => | |
`https://api.npms.io/v2/package/${encodeURIComponent(name)}`; | |
const map = []; | |
require("npm-pack-dependents@2.0.0")(npmPackageName) | |
.then((dependents) => { | |
return Promise.allSettled( | |
dependents.map((d) => { | |
return got(url(d)).then((resp) => { | |
const count = JSON.parse(resp.body).collected.npm.downloads[1].count; | |
map.push([d, count]); | |
}); | |
}) | |
); | |
}) | |
.then(() => console.log(map.sort((a, b) => b[1] - a[1])), console.error); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment