{"id":33898729,"url":"https://github.com/hazae41/abortable.ts","last_synced_at":"2025-12-11T21:17:39.792Z","repository":{"id":62421770,"uuid":"300068183","full_name":"hazae41/abortable.ts","owner":"hazae41","description":"Abortable promises for Deno","archived":true,"fork":false,"pushed_at":"2020-12-08T19:53:56.000Z","size":9,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-09T23:29:11.222Z","etag":null,"topics":["abortable","deno","promises","race"],"latest_commit_sha":null,"homepage":"https://deno.land/x/abortable","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hazae41.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-30T21:31:34.000Z","updated_at":"2023-05-01T02:15:40.000Z","dependencies_parsed_at":"2022-11-01T17:32:48.485Z","dependency_job_id":null,"html_url":"https://github.com/hazae41/abortable.ts","commit_stats":null,"previous_names":["hazae41/abortable"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/hazae41/abortable.ts","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hazae41%2Fabortable.ts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hazae41%2Fabortable.ts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hazae41%2Fabortable.ts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hazae41%2Fabortable.ts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hazae41","download_url":"https://codeload.github.com/hazae41/abortable.ts/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hazae41%2Fabortable.ts/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":27556736,"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","status":"online","status_checked_at":"2025-12-06T02:00:06.463Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["abortable","deno","promises","race"],"created_at":"2025-12-11T21:17:34.190Z","updated_at":"2025-12-11T21:17:35.117Z","avatar_url":"https://github.com/hazae41.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Abortable promises for Deno\n\nPromises with an abort() method and a cleanup function.\n\n## Install \n\n    deno cache -r https://deno.land/x/abortable/mod.ts\n\n## Test\n\nCatch\n\n    deno run https://deno.land/x/abortable/test/catch.ts\n\nRace\n\n    deno run https://deno.land/x/abortable/test/race.ts\n\n## Usage with await\n\nAbortables are just Promises but with an abort() method and an abort function\n\n```typescript\nimport { Abort } from \"https://deno.land/x/abortable/mod.ts\"\n\nconst timeout = Abort.create((ok, err) =\u003e {\n  const id = setTimeout(ok, 1000)\n  return () =\u003e clearTimeout(id) // Abort function\n})\n\ntimeout.abort() // Call the abort function and reject with AbortSignal\n\ntry{\n  await timeout // Will throw AbortSignal because it has been aborted\n} catch(e){\n  if(e instanceof AbortSignal) // Check if it has been aborted\n    // ...\n}\n```\n\n## Usage with callbacks\n\nAbortables fully implement the Promise interface and it works like a charm\n\n```typescript\nconst test = abortable\n    .then(it =\u003e \"Modified!\", e =\u003e new Error(\"Catched!\"))\n    .then(it =\u003e console.log(\"Resolved\", it))\n    .catch((e) =\u003e console.error(\"Rejected\", e))\n    .finally(() =\u003e console.log(\"Done\"))\n    .abort()\n```\n\n## Usage with fetch\n\nAbortable comes with a shortcut for window.fetch that returns `Abortable\u003cResponse\u003e`\n\n```typescript\nimport { Abort, Abortable } from \"https://deno.land/x/abortable/mod.ts\"\n\n// Shortcut for window.fetch with an abort controller\nconst request = Abort.fetch(\"...\", { ... })\nrequest.abort() // Will abort the request\n```\n\n## Usage with race\n\nAbortable is very useful for racing strategies where we want to abort loosers\n\n```typescript\nimport { Abort, Abortable } from \"https://deno.land/x/abortable/mod.ts\"\n\nconst first = Abort.create((ok, err) =\u003e {\n  const id = setTimeout(ok, 1000)\n  return () =\u003e clearTimeout(id) // Abort function\n})\n\nconst second = Abort.create((ok, err) =\u003e {\n  const id = setTimeout(ok, 2000)\n  return () =\u003e clearTimeout(id) // Abort function\n})\n\n// Wait for the first promise to settle\n// Then call the abort function of the other\nawait Abort.race([first, second])\n```\n\n## Usage with a custom abort signal receiver\n\nThe Abortable factory comes with an extra `signal` parameter that allows you to pass the signal to any third-party library that uses abort signals\n\n```typescript\nconst abortable = Abort.create((ok, err, signal) =\u003e {\n  fetch(\"...\", { signal }).then(ok, err)\n  // No cleanup function since window.fetch is aborted by the signal\n})\n```\n\n## Usage with a custom AbortController\n\nYou can create custom Abortables with a promise and an abort controller\n\n```typescript\nconst aborter = new AbortController()\nconst signal = aborter.signal\n\nconst promise = fetch(\"...\", { signal })\nconst abortable = new Abortable(promise, aborter)\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhazae41%2Fabortable.ts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhazae41%2Fabortable.ts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhazae41%2Fabortable.ts/lists"}