{"id":16057515,"url":"https://github.com/aduth/crawl-domain","last_synced_at":"2025-03-16T06:27:17.579Z","repository":{"id":66273600,"uuid":"305180651","full_name":"aduth/crawl-domain","owner":"aduth","description":"Crawl to discover all paths under a given URL domain","archived":false,"fork":false,"pushed_at":"2020-10-21T01:47:32.000Z","size":39,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-13T22:35:06.415Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aduth.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-18T19:31:29.000Z","updated_at":"2021-07-14T12:17:11.000Z","dependencies_parsed_at":"2023-03-29T04:48:49.780Z","dependency_job_id":null,"html_url":"https://github.com/aduth/crawl-domain","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aduth%2Fcrawl-domain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aduth%2Fcrawl-domain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aduth%2Fcrawl-domain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aduth%2Fcrawl-domain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aduth","download_url":"https://codeload.github.com/aduth/crawl-domain/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243495481,"owners_count":20299920,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-09T03:03:01.490Z","updated_at":"2025-03-16T06:27:17.574Z","avatar_url":"https://github.com/aduth.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# crawl-domain\n\nCrawl to discover all paths under a given URL domain.\n\n## Example\n\n```js\nimport crawl from 'crawl-domain';\n\nfor await (const url of crawl('http://localhost:3000')) {\n\tconsole.log(url);\n}\n\n// → http://localhost:3000/\n// → http://localhost:3000/b\n// → http://localhost:3000/c\n// → http://localhost:3000/d\n```\n\n## Installation\n\n`crawl-domain` is authored as an [ESM module](https://nodejs.org/api/esm.html), and therefore requires Node 12.0 or newer.\n\nInstall using NPM or Yarn:\n\n```\nnpm install crawl-domain\n```\n\n```\nyarn add crawl-domain\n```\n\n## Usage\n\nThe default export will return a [Node pipeline stream](https://nodejs.org/api/stream.html#stream_stream) when called, which can be [iterated asynchronously with `for await`](https://2ality.com/2019/11/nodejs-streams-async-iteration.html) to operate on crawled links as soon as they're discovered:\n\n```js\nimport crawl from 'crawl-domain';\n\nfor await (const url of crawl('http://localhost:3000')) {\n\tconsole.log(url);\n}\n```\n\nIf you'd prefer not to use streams, there are also Node-style callback and promise forms available, where the resolved value will be an array of all discovered URLs:\n\n```js\nimport crawl from 'crawl-domain';\n\ncrawl('http://localhost:3000', (error, urls) =\u003e {\n\tconsole.log(urls);\n});\n```\n\n```js\nimport { promise as crawl } from 'crawl-domain';\n\nconst urls = await crawl('http://localhost:3000');\nconsole.log(urls);\n```\n\n## Options\n\n`crawl` can optionally receive an options object as the second argument.\n\nThe following options are supported:\n\n- `concurrency`: HTTP client concurrency. Defaults to `10`.\n- `timeout`: HTTP client timeout, in milliseconds. Defaults to `10000`.\n\n## API\n\n```ts\nexport function stream(\n\trootURL: string,\n\toptions?: Partial\u003cCrawlOptions\u003e | undefined,\n\tcallback?: CrawlCallback | undefined\n): import('stream').Readable;\n\nexport const promise: CrawlPromise;\n\nexport default stream;\n\nexport type CrawlOptions = {\n\tconcurrency: number;\n\ttimeout: number;\n};\n\nexport type CrawlCallback = (error: Error | null, urls: string[]) =\u003e void;\nexport type CrawlPromise = (\n\trootURL: string,\n\toptions?: CrawlOptions | undefined\n) =\u003e Promise\u003cstring[]\u003e;\n```\n\n## License\n\nCopyright 2020 Andrew Duthie\n\nReleased under the MIT License. See [LICENSE.md](./LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faduth%2Fcrawl-domain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faduth%2Fcrawl-domain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faduth%2Fcrawl-domain/lists"}