diff --git a/docs/examples/github_api/index.js b/docs/examples/github_api/index.js new file mode 100644 index 0000000..ec71e79 --- /dev/null +++ b/docs/examples/github_api/index.js @@ -0,0 +1,17 @@ +import _ from 'https://unpkg.com/lodash-es' + +async function getPopularLanguages() { + const url = 'https://api.github.com/search/repositories?q=stars:%3E1&sort=stars' + const resp = await fetch(url) + const repos = await resp.json() + return _(repos.items) + .map(r => r.language) + .filter(l => l != null) + .countBy() + .toPairs() + .sortBy(([lang, useCount]) => useCount) + .map(([lang]) => lang) + .value() +} + +await getPopularLanguages()