{"id":20595580,"url":"https://github.com/johnpaulada/maybe","last_synced_at":"2026-04-20T02:37:36.564Z","repository":{"id":57121841,"uuid":"100923609","full_name":"johnpaulada/maybe","owner":"johnpaulada","description":"A simple, lightweight, Maybe implementation in JavaScript.","archived":false,"fork":false,"pushed_at":"2018-07-07T13:51:27.000Z","size":41,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-13T09:45:36.835Z","etag":null,"topics":["functional-programming","maybe","monad"],"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/johnpaulada.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":"2017-08-21T07:11:37.000Z","updated_at":"2018-07-07T13:51:28.000Z","dependencies_parsed_at":"2022-08-24T14:56:58.683Z","dependency_job_id":null,"html_url":"https://github.com/johnpaulada/maybe","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnpaulada%2Fmaybe","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnpaulada%2Fmaybe/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnpaulada%2Fmaybe/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnpaulada%2Fmaybe/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnpaulada","download_url":"https://codeload.github.com/johnpaulada/maybe/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242231434,"owners_count":20093636,"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":["functional-programming","maybe","monad"],"created_at":"2024-11-16T08:13:33.932Z","updated_at":"2026-04-20T02:37:36.517Z","avatar_url":"https://github.com/johnpaulada.png","language":"JavaScript","readme":"# Maybe\nA simple Maybe implementation in JavaScript.\n\n[![forthebadge](http://forthebadge.com/images/badges/fuck-it-ship-it.svg)](http://forthebadge.com)\n[![forthebadge](http://forthebadge.com/images/badges/uses-js.svg)](http://forthebadge.com)\n\n[![](https://data.jsdelivr.com/v1/package/npm/@johnpaulada/maybe/badge)](https://www.jsdelivr.com/package/npm/@johnpaulada/maybe)\n\n## Getting Started\n\n### Importing the library\nTo use the library, first import it:\n\nIn Node:\n```javascript\nconst Maybe = require('@johnpaulada/maybe')\n```\n\nAs ES Module:\n```javascript\nimport Maybe from '@johnpaulada/maybe'\n```\n\nOn the browser:\n```html\n\u003cscript src=\"https://cdn.jsdelivr.net/npm/@johnpaulada/maybe@3.0.2/maybe.min.js\"\u003e\u003c/script\u003e\n```\n\n### Using the library\nTo create a Maybe (Just/Nothing) use the `of()` method like this:\n\n```javascript\nconst value = Maybe.of(1) // Just(1)\n```\n\nTo work with the value, you can `map()` for example:\n\n```javascript\nconst plusFive = value.map(x =\u003e x + 5) // Just(6)\n```\n\nTo get the value outside of Maybe, use the `reduce()` method:\n\n```javascript\nconst sixValue = plusFive.reduce(x =\u003e x) // 6\n```\n\nor the `value()` method:\n\n```javascript\nconst sixValue = plusFive.value(0)\n```\n\nThis will get the value of the Maybe if it's a `Just` and will return a 0 if it's a `Nothing`.\n\n## Development\n1. Install [Yarn](https://yarnpkg.com).\n2. Install Rollup.\n2. Run `yarn` on the terminal to install dependencies.\n3. Running `rollup -c` will build the library.\n\n## Roadmap\n- [ ] Lazy Evaluation\n- [ ] Example for `ap`\n- [ ] Example for `branch`\n\n## License\nMIT","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnpaulada%2Fmaybe","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnpaulada%2Fmaybe","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnpaulada%2Fmaybe/lists"}