{"id":49701979,"url":"https://github.com/cbmongithub/handy-functions","last_synced_at":"2026-05-08T07:36:55.852Z","repository":{"id":319329228,"uuid":"1078367760","full_name":"cbmongithub/handy-functions","owner":"cbmongithub","description":"Tiny, reusable helpers that remove the boilerplate from modern HTTP calls and error handling","archived":false,"fork":false,"pushed_at":"2025-10-17T16:59:42.000Z","size":40,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-15T05:30:21.055Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/cbmongithub.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-10-17T16:08:10.000Z","updated_at":"2026-03-29T14:32:47.000Z","dependencies_parsed_at":null,"dependency_job_id":"ae1c8285-41db-422d-b6d9-f98666c5fbf4","html_url":"https://github.com/cbmongithub/handy-functions","commit_stats":null,"previous_names":["cbmongithub/handy-functions"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cbmongithub/handy-functions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbmongithub%2Fhandy-functions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbmongithub%2Fhandy-functions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbmongithub%2Fhandy-functions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbmongithub%2Fhandy-functions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cbmongithub","download_url":"https://codeload.github.com/cbmongithub/handy-functions/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cbmongithub%2Fhandy-functions/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32771240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-08T02:36:36.067Z","status":"ssl_error","status_checked_at":"2026-05-08T02:36:07.210Z","response_time":54,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":[],"created_at":"2026-05-08T07:36:55.029Z","updated_at":"2026-05-08T07:36:55.824Z","avatar_url":"https://github.com/cbmongithub.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# handy-functions\n\nTiny, reusable helpers that remove the boilerplate from modern HTTP calls and error handling. `handy-functions` gives you a predictable fetch wrapper, typed verb shortcuts, and a flexible `tryCatch` utility so you can focus on application logic instead of plumbing.\n\n\u003e **Status**: early library – more helpers will be added as the toolkit grows.\n\n## When To Use (and When Not)\n\n- ✅ **Use it** when you manage many API requests, share utilities across projects, or ship SDK-like code. Centralizing the fetch contract keeps headers, serialization, and errors consistent everywhere.\n- ✅ **Use it** in teams where a tuple-based `[data, error]` pattern improves clarity and avoids scattered `try…catch` blocks.\n- 🚫 **Skip it** for one-off scripts or apps with only a couple of requests—the native `fetch` may be simpler.\n- 🚫 **Skip it** if you already rely on a heavier request client (Axios, ky, etc.) unless you specifically want these lean abstractions.\n\n## Installation\n\n```bash\nbun install handy-functions\n# or\nnpm install handy-functions\n```\n\n## Usage\n\n```ts\nimport { get, post, retry, tryCatch } from \"handy-functions\";\n\ntype Todo = { id: number; title: string; completed: boolean };\n\n// Fetch JSON with sensible defaults\nconst todos = await get\u003cTodo[]\u003e(\"https://jsonplaceholder.typicode.com/todos\");\n\n// POST body objects without manually stringifying\nawait post(\"https://jsonplaceholder.typicode.com/todos\", {\n  title: \"Ship handy-functions\",\n  completed: false,\n});\n\n// Tuple-based error handling: fetch by URL string or supply a thunk/promise\nconst [profile, error] = await tryCatch\u003c{ id: string; name: string }\u003e(\n  \"https://api.example.com/users/42\",\n  { headers: { Authorization: `Bearer ${token}` } }\n);\n\nif (error) {\n  console.error(error.message);\n}\n\n// Add resilient retry behavior to flaky endpoints\nconst notifications = await retry(\n  () =\u003e get\u003c{ id: string; read: boolean }[]\u003e(\"https://api.example.com/inbox\"),\n  {\n    attempts: 4,\n    delay: (attempt) =\u003e 250 * 2 ** (attempt - 1),\n    retryable: (err) =\u003e err instanceof TypeError, // only network-ish failures\n  }\n);\n```\n\n## Available Helpers\n\n- `fetcher\u003cT\u003e(url, options?)` – core wrapper over `fetch` with JSON detection, body serialization (plain objects/arrays → JSON, `FormData` untouched), and normalized error messages.\n- `get`, `post`, `put`, `patch`, `del` – verb-specific entry points that forward to `fetcher`, accepting any valid `BodyInit` for mutations.\n- `tryCatch(input, requestOptions?)` – returns `[data, null]` or `[null, error]` while supporting:\n  - plain values or promises,\n  - promise-returning thunks,\n  - URL strings (auto routed through `fetcher` with optional request options).\n- `retry(target, retryOptions?, requestOptions?)` – retries async work with exponential backoff by default; accepts promise factories or URLs (delegating to `fetcher`), supports custom retry rules, delays, and abort signals.\n\nAll exports are available through the main entry point (`import { ... } from \"handy-functions\"`).\n\n## Building \u0026 Testing\n\n```bash\n# run vitest suites\nbun test\n\n# produce minified ESM + CJS bundles and declaration files\nbun run build\n```\n\nThe build uses Vite’s Rolldown bundler and aggressive Terser minimization (mangling, console stripping, multiple compression passes) to keep the footprint tiny.\n\n## Contributing\n\nThis repository is still evolving. PRs and issues are welcome—just run `bun test` and `bun run build` before submitting. Future iterations will introduce more cross-project helpers, so feel free to suggest additions or enhancements.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcbmongithub%2Fhandy-functions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcbmongithub%2Fhandy-functions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcbmongithub%2Fhandy-functions/lists"}