{"id":31655655,"url":"https://github.com/bbb/result4t","last_synced_at":"2025-10-07T13:50:52.058Z","repository":{"id":45746893,"uuid":"514346779","full_name":"BBB/result4t","owner":"BBB","description":"A replacement for Promise that gives us a strongly-typed failure mode.","archived":false,"fork":false,"pushed_at":"2023-12-07T16:09:10.000Z","size":905,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-30T00:44:27.057Z","etag":null,"topics":["fp","result","result-type","typescript"],"latest_commit_sha":null,"homepage":"","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/BBB.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,"governance":null}},"created_at":"2022-07-15T17:09:59.000Z","updated_at":"2023-04-03T12:57:05.000Z","dependencies_parsed_at":"2023-11-28T20:50:03.405Z","dependency_job_id":null,"html_url":"https://github.com/BBB/result4t","commit_stats":{"total_commits":71,"total_committers":1,"mean_commits":71.0,"dds":0.0,"last_synced_commit":"8508cb7542edd34a47707668ec2dc6bc1a2f5780"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BBB/result4t","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BBB%2Fresult4t","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BBB%2Fresult4t/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BBB%2Fresult4t/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BBB%2Fresult4t/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BBB","download_url":"https://codeload.github.com/BBB/result4t/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BBB%2Fresult4t/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278786690,"owners_count":26045588,"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-10-07T02:00:06.786Z","response_time":59,"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":["fp","result","result-type","typescript"],"created_at":"2025-10-07T13:50:49.829Z","updated_at":"2025-10-07T13:50:52.052Z","avatar_url":"https://github.com/BBB.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch2 align=\"center\"\u003eresult4t\u003c/h2\u003e\n\n\u003cp align=\"center\"\u003e\nAvailable now\n\u003c/p\u003e\n\n`pnpm add @ollierelph/result4t` or `pnpm add result4t`\n\n## What's this?\n\n`result4t` takes some pointers from the wonderful [result4k](https://github.com/fork-handles/forkhandles/tree/trunk/result4k)\n\nIt's a replacement for `Promise` that gives us a strongly-typed error mode.\n\n## An example\n\n```typescript\nimport fs from \"node:fs\";\n\nconst readFileAndReverse = () =\u003e\n  fs\n    .readFile(\"./boom.txt\")\n    .then((contents) =\u003e contents.split(\"\\n\").reverse().join(\"\\n\"));\n\nreadFileAndReverse()\n  .then((reversedFile) =\u003e {\n    console.log(reversedFile);\n    process.exit(0);\n  })\n  .catch((error: unknown) =\u003e {\n    console.error(error);\n    process.exit(1);\n  });\n```\n\nin `result4t`:\n\n```typescript\nimport fs from \"node:fs\";\nimport { TaskResult } from \"./TaskResult\";\n\nconst readFileAndReverse = () =\u003e\n  TaskResult.ofPromise(\n    () =\u003e fs.readFile(\"./boom.txt\"),\n    (err: unknown) =\u003e new Error(\"Unable to find file\"),\n  ).map((contents) =\u003e contents.split(\"\\n\").reverse().join(\"\\n\"));\n\nreadFileAndReverse()\n  .peek((reversedFile) =\u003e {\n    console.log(reversedFile);\n    process.exit(0);\n  })\n  .peekLeft((error) =\u003e {\n    // ^--- typed as Error\n    console.error(error);\n    process.exit(1);\n  })\n  .run();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbb%2Fresult4t","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbbb%2Fresult4t","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbbb%2Fresult4t/lists"}