-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
41 lines (34 loc) · 1.02 KB
/
example.js
File metadata and controls
41 lines (34 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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
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)
});