Skip to content

Instantly share code, notes, and snippets.

@nfiniteset
Created August 7, 2018 02:21
Show Gist options
  • Save nfiniteset/abdeb1c02be36a125a8d6a2e403827d9 to your computer and use it in GitHub Desktop.
Save nfiniteset/abdeb1c02be36a125a8d6a2e403827d9 to your computer and use it in GitHub Desktop.
Structures values from npmcharts.com
var modules = Array.from(document.querySelectorAll('.module'));
console.log(
modules
.map(el => ({ downloads: el.querySelector('.downloads').innerText, name: el.querySelector('.name').innerText }))
.sort((moduleA, moduleB) => {
const nameA = moduleA.name.toUpperCase();
const nameB = moduleB.name.toUpperCase();
if (nameA < nameB) {
return -1;
}
if (nameA > nameB) {
return 1;
}
// names must be equal
return 0;
})
.reduce((acc, mod) => (acc.concat(`${mod.name}\n`)), '\n')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment