{"id":21004775,"url":"https://github.com/halfzebra/chilled-js","last_synced_at":"2025-07-11T10:02:49.150Z","repository":{"id":40790760,"uuid":"187526594","full_name":"halfzebra/chilled-js","owner":"halfzebra","description":":ok_hand: Resilient error handling pattern for JavaScript","archived":false,"fork":false,"pushed_at":"2025-06-19T15:38:55.000Z","size":127,"stargazers_count":13,"open_issues_count":14,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-24T06:08:37.551Z","etag":null,"topics":["error-handling","javascript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/halfzebra.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2019-05-19T20:48:37.000Z","updated_at":"2023-07-27T12:05:22.000Z","dependencies_parsed_at":"2024-11-19T08:38:06.988Z","dependency_job_id":"0cea41c1-9f92-41bf-bdd6-59ea0c3628a9","html_url":"https://github.com/halfzebra/chilled-js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/halfzebra/chilled-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halfzebra%2Fchilled-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halfzebra%2Fchilled-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halfzebra%2Fchilled-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halfzebra%2Fchilled-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/halfzebra","download_url":"https://codeload.github.com/halfzebra/chilled-js/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/halfzebra%2Fchilled-js/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264780330,"owners_count":23662629,"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":["error-handling","javascript"],"created_at":"2024-11-19T08:37:51.785Z","updated_at":"2025-07-11T10:02:49.115Z","avatar_url":"https://github.com/halfzebra.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# chilled-js\n\nWhat if JavaScript could chill a little bit with all the errors being thrown here and there?\n\n[![Build Status](https://travis-ci.org/halfzebra/chilled-js.svg?branch=master)](https://travis-ci.org/halfzebra/chilled-js)\n\n## TL;DR\n\n```js\nfunction parse(raw) {\n  try {\n    return [ null, JSON.parse(raw) ]\n  } catch (err) {\n    return [ err, null ]\n  }\n}\n\nlet [ err, ok ] = parse(...)\n```\n\n## Comparing to other kinds of error handling\n\n| | Nullable | try..catch and throw | Callback | Promise | chilled |\n| :--- | :---: | :---: | :---: | :---: | :---: |\n| Sync  | :heavy_check_mark: | :heavy_check_mark: | | | :heavy_check_mark: |\n| Async |  | | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |\n| Error Context | | :confused: | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |\n| Composability | :heavy_check_mark: | | | :heavy_check_mark: | :heavy_check_mark: |\n\n\u003cimg src=\"https://media.giphy.com/media/SGY6C4he2z8T6/giphy.gif\" alt='Dr. Freeze saying \"Everybody Chill!\"'\u003e\n\n## Usage\n\n### Sync\n\nHelps to capture the error close to the context when working with functions which throw exceptions.\n\n```js\nconst parse = chill(JSON.parse)\n\nlet [ err, ok ] = parse('{ \"id\": 1 }')\n\nif (err) {\n  // Handle the error.\n}\n\nconsole.log(ok)\n```\n\n### Async\n\nRemoves exception bubbling when using Async Await.\n\n```js\nconst url = 'https://jsonplaceholder.typicode.com/todos/1'\n\nasync function () {\n  let [ err, ok ] = await chill(\n    () =\u003e fetch(url).then(response =\u003e response.json())\n  )()\n\n  if (err) {\n    // Handle the error.\n  }\n\n  // Celebrate the success at async programming!\n  console.log(ok)\n}()\n```\n\n## Inspiration\n\n- [Error handling and Go](https://blog.golang.org/error-handling-and-go)\n- [Result](https://package.elm-lang.org/packages/elm/core/latest/Result) type from Elm\n- [Data.Either](http://hackage.haskell.org/package/base-4.12.0.0/docs/Data-Either.html) type from Haskell\n- [scopsy/await-to-js](https://github.com/scopsy/await-to-js) a JavaScript library exploring a similar concept\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalfzebra%2Fchilled-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhalfzebra%2Fchilled-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhalfzebra%2Fchilled-js/lists"}