{"id":21278516,"url":"https://github.com/wdalmut/maybe-with-promises-2","last_synced_at":"2026-06-23T08:32:14.420Z","repository":{"id":142589607,"uuid":"146974571","full_name":"wdalmut/maybe-with-promises-2","owner":"wdalmut","description":"Improved example of usage for maybes with promises","archived":false,"fork":false,"pushed_at":"2018-09-01T06:36:43.000Z","size":1,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-27T13:31:17.380Z","etag":null,"topics":["example","javascript","js","maybe-monad","promise"],"latest_commit_sha":null,"homepage":"https://github.com/wdalmut/maybe-with-promises","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/wdalmut.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}},"created_at":"2018-09-01T06:36:30.000Z","updated_at":"2018-09-01T06:43:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"32e35782-0d6a-42c1-84a2-ceae69e125bf","html_url":"https://github.com/wdalmut/maybe-with-promises-2","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wdalmut/maybe-with-promises-2","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wdalmut%2Fmaybe-with-promises-2","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wdalmut%2Fmaybe-with-promises-2/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wdalmut%2Fmaybe-with-promises-2/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wdalmut%2Fmaybe-with-promises-2/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wdalmut","download_url":"https://codeload.github.com/wdalmut/maybe-with-promises-2/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wdalmut%2Fmaybe-with-promises-2/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34682625,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-23T02:00:07.161Z","response_time":65,"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":["example","javascript","js","maybe-monad","promise"],"created_at":"2024-11-21T10:14:46.708Z","updated_at":"2026-06-23T08:32:14.404Z","avatar_url":"https://github.com/wdalmut.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Use maybes with promises\n\nIn order to improve readability an example of data maybe with promises\n\n```\nconst is_confirmed = compose(equals(true), prop('confirmed'));\nget_order(id)\n  .then(ifElse(is_confirmed, Just, Nothing))\n  .then(map(create_guests_for_event))\n  .then(map(send_invoice_ticket))\n  .then(console.log)\n;\n```\n\nIf the order from `get_order` is not confirmed `confirmed = false` nothing is\nexecuted.\n\n## Usage\n\n### Install dependencies\n\n```sh\nnpm install\n```\n\n### Run it\n\nExecute the data pipeline\n\n```sh\n$ node index.js 1\nGuests created! { id: '1', confirmed: true, price: 89.9 }\nInvoice sent! Promise { { id: '1', confirmed: true, price: 89.9 } }\nMaybe {\n  value: Promise { { id: '1', confirmed: true, price: 89.9 } } }\n```\n\n_nothing to do (confirmed = false)_\n\n```sh\nnode index.js 0\nMaybe {}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwdalmut%2Fmaybe-with-promises-2","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwdalmut%2Fmaybe-with-promises-2","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwdalmut%2Fmaybe-with-promises-2/lists"}