Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

brokenurl

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

brokenurl - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

24

index.ts

@@ -42,3 +42,3 @@ #!/usr/bin/env bun

const checkLink = async (url: string): Promise<void> => {
const checkLink = async (url: string): Promise<boolean> => {
try {

@@ -55,4 +55,6 @@ let response = await fetch(url, { method: "HEAD" });

);
return response.ok;
} catch (error) {
console.error(`Error checking ${url}:`, error);
return false;
}

@@ -70,14 +72,26 @@ };

const startTime = performance.now();
const links = await getLinksFromPage(website);
// Execute link checks in parallel.
await Promise.all(links.map((link) => checkLink(link)));
// Fetch links and check them in parallel for efficiency
const linkStatuses = (await getLinksFromPage(website)).map(checkLink);
const results = await Promise.allSettled(linkStatuses);
const endTime = performance.now();
const okCount = results.filter(
(result) => result.status === "fulfilled" && result.value
).length;
const brokenCount = results.length - okCount;
console.log(chalk.blueBright("~".repeat(40)));
console.log(
`Checked ${links.length} links in ${(endTime - startTime).toFixed(
`Checked ${results.length} links in ${(endTime - startTime).toFixed(
2
)} milliseconds.`
);
console.log(`Total OK: ${chalk.green(okCount.toString())}`);
console.log(`Total Broken: ${chalk.red(brokenCount.toString())}`);
};
main();
{
"name": "brokenurl",
"version": "1.0.3",
"version": "1.0.4",
"main": "index.ts",

@@ -5,0 +5,0 @@ "bin": {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc