{"id":15696834,"url":"https://github.com/zkat/cond","last_synced_at":"2026-04-09T15:34:49.922Z","repository":{"id":15043752,"uuid":"17769733","full_name":"zkat/cond","owner":"zkat","description":"Restartable error handling system for JavaScript","archived":false,"fork":false,"pushed_at":"2015-02-13T07:30:18.000Z","size":395,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"develop","last_synced_at":"2025-04-12T00:42:41.057Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zkat.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":"2014-03-15T06:30:05.000Z","updated_at":"2021-02-06T13:22:07.000Z","dependencies_parsed_at":"2022-08-31T16:25:03.413Z","dependency_job_id":null,"html_url":"https://github.com/zkat/cond","commit_stats":null,"previous_names":["sykopomp/cond"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkat%2Fcond","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkat%2Fcond/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkat%2Fcond/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkat%2Fcond/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zkat","download_url":"https://codeload.github.com/zkat/cond/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253162604,"owners_count":21863947,"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-03T19:10:08.488Z","updated_at":"2025-12-12T04:54:30.406Z","avatar_url":"https://github.com/zkat.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CondJS\n\n`cond` is [hosted at Github](http://github.com/zkat/cond). `mona` is a\npublic domain work, dedicated using\n[CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/). Feel free to do\nwhatever you want with it.\n\n# Quickstart\n\n### Install\n\n`$ npm install cond`\nor\n`$ bower install cond`\n\n### Example\n\nExecute the following in a browser session, with developer tools open, and\nfollow the instructions:\n\n```javascript\n\nvar availableFlavors = [\"chocolate\", \"vanilla\", \"mint chocolate chip\"];\nfunction getIceCream(flavor) {\n    if (availableFlavors.indexOf(flavor) !== -1) {\n        return flavor + \" ice cream ゲットー!\";\n    } else {\n        // Just like throw new Error(\"something\"), but we provide a way\n        // the user can recover from it.\n        return cond.error(\"Sorry, that flavor is not available\", [\n            \"different-flavor\", \"Try a different flavor\", getIceCream\n        ], [\n            \"add-flavor\", \"Add this flavor to available ones and retry\", function() {\n                availableFlavors.push(flavor);\n                return getIceCream(flavor);\n            }\n        ]);\n    }\n}\n\nconsole.log(getIceCream(\"coffee\"));\nconsole.log(\"I really like this flavor!\");\n\n// In the console, do:\n\n// \u003e showRecoveries();\n// \u003e recover(0, \"chocolate\");\n\n// You can also access recoveries programmatically:\nconsole.log(cond.handlerBind(function() {\n    return getIceCream(\"bubblegum\");\n}, [Error, function(e) { return cond.recover(\"add-flavor\"); }]));\n```\n\n# Introduction\n\n`cond` is a JavaScript implementation of\n[Common Lisp's condition system](http://gigamonkeys.com/book/beyond-exception-handling-conditions-and-restarts.html),\na system for handling errors and other conditions of interest that handles\nsignals at the call site, before the stack is unwound -- allowing you to repair\nor alter what happens at the callsite, and continuing executing as if nothing\nhad been signaled/thrown.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzkat%2Fcond","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzkat%2Fcond","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzkat%2Fcond/lists"}