Created
January 3, 2025 18:06
-
-
Save johnwargo/6890b6adc8aa4b242052c0e19fc28755 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/********************************************************** | |
* Fetches all packages from the npm registry for a | |
* given author. | |
**********************************************************/ | |
// https://github.com/npm/registry/blob/main/docs/REGISTRY-API.md | |
function _compareFunction(a, b) { | |
if (a.package.name < b.package.name) return -1; | |
if (a.package.name > b.package.name) return 1; | |
return 0; | |
} | |
module.exports = async function () { | |
const author = 'johnwargo'; | |
var response = await fetch(`https://registry.npmjs.com/-/v1/search?text=author:${author}`); | |
var data = await response.json(); | |
var packages = data.objects; | |
packages.sort(_compareFunction); | |
return packages; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment