{"id":27934847,"url":"https://github.com/uri/maybe-proxy","last_synced_at":"2025-10-11T10:46:21.577Z","repository":{"id":142775916,"uuid":"110842855","full_name":"uri/maybe-proxy","owner":"uri","description":"Maybe monad implemented using Proxy for maximum sweetness","archived":false,"fork":false,"pushed_at":"2017-11-15T14:19:37.000Z","size":1,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-05T06:57:06.139Z","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/uri.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":"2017-11-15T14:19:17.000Z","updated_at":"2017-11-15T14:19:37.000Z","dependencies_parsed_at":"2023-07-01T01:20:40.387Z","dependency_job_id":null,"html_url":"https://github.com/uri/maybe-proxy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/uri/maybe-proxy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uri%2Fmaybe-proxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uri%2Fmaybe-proxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uri%2Fmaybe-proxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uri%2Fmaybe-proxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uri","download_url":"https://codeload.github.com/uri/maybe-proxy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uri%2Fmaybe-proxy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279006866,"owners_count":26084208,"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-11T02:00:06.511Z","response_time":55,"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":[],"created_at":"2025-05-07T06:08:36.587Z","updated_at":"2025-10-11T10:46:21.572Z","avatar_url":"https://github.com/uri.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# maybe-proxy\n\nThis maybe monad implemented with a `Proxy`. This monad let's you chain method\ncalls without relying on a higher order `then`/`chain`/`andThen` function\n\n```javascript\nvar {Maybe} = require(\"./index\");\n\nfunction apiRequest() {\n  if (Math.random() \u003c 0.5) {\n   return {person: {name: 'bobby', projects: [{lang: 'elixir', name: 'brute'}]}};\n  } else {\n  return {projects: []};\n  }\n}\n\nvar lang = maybePerson.person.projects[0].lang.value\nconsole.log(lang)\n```\n\nUse `value` to return the current value. This returns the value or `null`.\n\n`andThen` is still useful if wanting to use a function not implemented on the underlying value:\n\n```javascript\nfunction someOp(value) {\n  console.log(\"Performing some op\", value)\n}\nmaybePerson.person.projects.andThen(projects =\u003e someOp(projects))\n```\n\nChaining methods together with will always return a new `Maybe`.\n\n```javascript\nvar maybeProjects = maybePerson.projects\nconsole.log(maybePerson.value) // prints null or value\nconsole.log(maybeProjects.value) // prints null or value\n\nmaybeProjects.andThen(value =\u003e { // only prints value if value is not null\n  console.log(value)\n  return value // value must be return if chaining is to continue\n}).andThen(v =\u003e someOp(v)).andThen(v =\u003e someOtherOp(v))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furi%2Fmaybe-proxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Furi%2Fmaybe-proxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Furi%2Fmaybe-proxy/lists"}