This is a NodeJS module for getting information about Bower packages from the Bower registry, which is a REST API. It can be used to search for packages, list all packages, and check if a package exists. The package written in JavaScript.
- Search packages
- List packages (All packages, or in chunks)
- Internal cache feature to reduce the number of requests
- Check package exists and name availability
Import the module:
const { searchPackage, listPackages, packageExists } = require("./bower-package");
Search and get the results:
searchPackage("jquery").then((results) => {
console.log("Search results: " + results.length);
// Iterate over the results
results.forEach((result) => {
console.log(result);
});
});
Get the list of all packages:
listPackages().then((packages) => {
console.log("List of packages: " + packages.length);
// Iterate over the results
packages.forEach((package) => {
console.log(package);
});
});
Get the list of packages and chunk them into arrays of 20 packages:
listPackages(20).then((chunks) => {
console.log("List of chunks: " + chunks.length)
console.log("List of packages: " + chunks.reduce((sum, chunk) => sum + chunk.length, 0));
// Iterate over the chunks
chunks.forEach((chunk) => {
console.log(chunk);
// Iterate over the packages in the chunk
// chunk.forEach((package) => {
// console.log(package);
// });
});
});
Check a package exists:
packageExists("jquery").then((exists) => {
console.log("Package exists: " + exists)
});
Copyright 2023, Max Base