{"_id":"@1-/url_exist","_rev":"2-1e1f167b1b458e9766632687e3bb4469","name":"@1-/url_exist","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@1-/url_exist","version":"0.1.0","keywords":["exist","fetch","head","timeout","url"],"author":{"name":"x-at-01@googlegroups.com"},"license":"MulanPSL-2.0","_id":"@1-/url_exist@0.1.0","maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"homepage":"https://github.com/webc-site/npm/tree/main/url_exist","bugs":{"url":"https://github.com/webc-site/npm/issues"},"dist":{"shasum":"7014717e36b881e1f474111f762b29a1354d7b0e","tarball":"https://registry.npmjs.org/@1-/url_exist/-/url_exist-0.1.0.tgz","fileCount":3,"integrity":"sha512-5CiSLMyAf0INnfa+Pokk7PPuVT/gmyNQOGnqF8NjngScOnWdprjcUMBUTJ2vZPHZdOkgvHlj/ZSkRwq+gd0hRg==","signatures":[{"sig":"MEUCIF/1R7SsImSXGge+1zISZFE7dde1Ei00oIroiw+696S/AiEAoWJoabkfwICzAI2W+7TCAiZCGIrch90uRRCrYASkCK0=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":5216},"type":"module","exports":{".":"./_.js","./*":"./*"},"_npmUser":{"name":"i18n-now","email":"i18n.site@gmail.com"},"repository":{"url":"git+https://github.com/webc-site/npm.git","type":"git"},"_npmVersion":"11.13.0","description":"Check if URL exists using HTTP HEAD request with timeout / 基于 HTTP HEAD 请求且支持超时控制的 URL 存在性检测","directories":{},"_nodeVersion":"26.2.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/url_exist_0.1.0_1781018608804_0.3830003487493565","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@1-/url_exist","version":"0.1.1","description":"Check if URL exists using HTTP HEAD request with timeout / 基于 HTTP HEAD 请求且支持超时控制的 URL 存在性检测","keywords":["exist","fetch","head","timeout","url"],"homepage":"https://github.com/webc-site/npm/tree/main/url_exist","license":"MulanPSL-2.0","author":{"name":"x-at-01@googlegroups.com"},"repository":{"type":"git","url":"git+https://github.com/webc-site/npm.git"},"type":"module","exports":{".":"./_.js","./*":"./*"},"_id":"@1-/url_exist@0.1.1","bugs":{"url":"https://github.com/webc-site/npm/issues"},"_nodeVersion":"26.2.0","_npmVersion":"11.13.0","dist":{"integrity":"sha512-42l7sN0G9d1ILFOmvJ5dvcbXuwzRzo69W7EWODuegpfe1VTnuZO3Mll3mnpnGuTkeS3pndNEPAgCHusWhxMuXw==","shasum":"43a2c98fe30532ebd8c9491e486a318e27d19d79","tarball":"https://registry.npmjs.org/@1-/url_exist/-/url_exist-0.1.1.tgz","fileCount":3,"unpackedSize":5238,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIGJ5KeLq/Ex23wnL0j21GrsEtQM8ucpwUNdX265l+6n6AiBXZkIU/0h3mrIc4Rplmw/Jsukax1Sc96dOFlmIQHO9Lg=="}]},"_npmUser":{"name":"i18n-now","email":"i18n.site@gmail.com"},"directories":{},"maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/url_exist_0.1.1_1781019446316_0.8932189377396433"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-09T15:23:28.638Z","modified":"2026-06-09T15:37:26.563Z","0.1.0":"2026-06-09T15:23:28.992Z","0.1.1":"2026-06-09T15:37:26.464Z"},"bugs":{"url":"https://github.com/webc-site/npm/issues"},"author":{"name":"x-at-01@googlegroups.com"},"license":"MulanPSL-2.0","homepage":"https://github.com/webc-site/npm/tree/main/url_exist","keywords":["exist","fetch","head","timeout","url"],"repository":{"type":"git","url":"git+https://github.com/webc-site/npm.git"},"description":"Check if URL exists using HTTP HEAD request with timeout / 基于 HTTP HEAD 请求且支持超时控制的 URL 存在性检测","maintainers":[{"name":"i18n-now","email":"i18n.site@gmail.com"}],"readme":"[English](#en) | [中文](#zh)\n\n---\n\n<a id=\"en\"></a>\n# @1-/url_exist : Detect URL existence via HTTP HEAD request with timeout control\n\n## 1. Features\n\nDetect target URL existence.\n\nSend HTTP HEAD request via Fetch API.\n\nSupport custom timeout, defaulting to 3000 milliseconds.\n\nReturn boolean or `undefined`.\n\nAvoid downloading response body to minimize bandwidth usage and latency.\n\n## 2. Usage\n\nInstall dependency:\n\n```bash\nnpm install @1-/url_exist\n```\n\nCode example:\n\n```javascript\nimport urlExist from \"@1-/url_exist\";\n\n// Check URL existence with default timeout (3000ms)\nconst ok = await urlExist(\"https://example.com\");\nconsole.log(ok); // true or false\n\n// Customize timeout (1000ms)\nconst exist = await urlExist(\"https://example.com\", 1000);\nconsole.log(exist);\n```\n\n## 3. Design\n\nSend HTTP HEAD request to retrieve response status.\n\nDetermine URL existence based on `response.ok`.\n\nUse `AbortSignal.timeout` to handle request timeouts.\n\nCatch exceptions (network error, timeout, DNS failure) and return `undefined`.\n\n![](https://fastly.jsdelivr.net/gh/webc-fs/-@yA/vks3MqEXJ_VMY_cskDVg.svg)\n\n## 4. Tech Stack\n\n- Runtime: Bun / Node.js\n- Language Standard: ECMAScript (ES Module)\n- Networking: Native Fetch API, AbortSignal\n\n## 5. Code Structure\n\n```\nurl_exist/\n├── src/\n│   └── _.js          # Core detection logic\n├── tests/\n│   └── _.test.js     # Unit tests\n├── package.json      # Configuration file\n└── README.md         # Entry document\n```\n\n## 6. History\n\nHTTP HEAD method was defined in 1999 within RFC 2616 (HTTP/1.1 specification). It retrieved resource metadata without transferring message body.\n\nHistorically, checking URL validity required downloading full contents via HTTP GET, causing network overhead and latency.\n\nHEAD method turned link validation into low-cost network operation.\n\nAfter Fetch API gained popularity, lack of native timeout support forced developers to combine `Promise.race` and `AbortController` manually.\n\nNative support for `AbortSignal.timeout` in modern runtimes (Node.js, Bun, browsers) simplified timeout handling.\n\n## About\n\nThis library is developed by [WebC.site](https://webc.site).\n\n[WebC.site](https://webc.site): A new paradigm of web development for AI\n\n---\n\n<a id=\"zh\"></a>\n# @1-/url_exist : 基于 HTTP HEAD 请求与超时控制的 URL 存在性检测\n\n## 1. 功能介绍\n\n检测目标 URL 存在性。\n\n基于 Fetch API 发送 HTTP HEAD 请求。\n\n支持自定义超时，默认 3000 毫秒。\n\n返回布尔值或 `undefined`。\n\n避免下载响应体，减少带宽消耗与网络延迟。\n\n## 2. 使用演示\n\n安装依赖：\n\n```bash\nnpm install @1-/url_exist\n```\n\n代码示例：\n\n```javascript\nimport urlExist from \"@1-/url_exist\";\n\n// 默认超时 (3000ms) 检测\nconst ok = await urlExist(\"https://example.com\");\nconsole.log(ok); // true 或 false\n\n// 自定义超时 (1000ms) 检测\nconst exist = await urlExist(\"https://example.com\", 1000);\nconsole.log(exist);\n```\n\n## 3. 设计思路\n\n通过发送 HTTP HEAD 请求获取响应状态。\n\n响应正常 (`response.ok` 为 `true`) 则判定 URL 存在。\n\n利用 `AbortSignal.timeout` 实施超时控制。\n\n捕获异常 (网络错误、请求超时、DNS 解析失败等) 并返回 `undefined`。\n\n![](https://fastly.jsdelivr.net/gh/webc-fs/-@qH/cIVZgsaw3uTjVUiqr14Q.svg)\n\n## 4. 技术栈\n\n- 运行环境：Bun / Node.js\n- 语言标准：ECMAScript (ES Module)\n- 网络通信：原生 Fetch API, AbortSignal\n\n## 5. 代码结构\n\n```\nurl_exist/\n├── src/\n│   └── _.js          # 核心检测逻辑\n├── tests/\n│   └── _.test.js     # 单元测试\n├── package.json      # 配置文件\n└── README.md         # 引导文件\n```\n\n## 6. 历史故事\n\nHTTP HEAD 方法定义于 1999 年 RFC 2616 (HTTP/1.1 规范)。设计初衷为获取资源元数据而无需传输主体内容。\n\n早期检测链接存在性需下载完整网页内容 (HTTP GET)，产生额外网络开销与高延迟。\n\nHEAD 方法使链接校验成为低开销网络操作。\n\nFetch API 普及初期，因缺乏内置超时机制，开发者需手动组合 `Promise.race` 与 `AbortController` 实现中断。\n\n`AbortSignal.timeout` 获得主流运行时 (Node.js、Bun、浏览器) 原生支持后，超时控制得以极大简化。\n\n## 关于\n\n本库由 [WebC.site](https://webc.site) 开发。\n\n[WebC.site](https://webc.site) : 面向人工智能的网站开发新范式\n","readmeFilename":"README.md"}