Created
August 7, 2018 02:21
-
-
Save nfiniteset/abdeb1c02be36a125a8d6a2e403827d9 to your computer and use it in GitHub Desktop.
Structures values from npmcharts.com
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
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