{"id":23454915,"url":"https://github.com/lilbunnyrabbit/optional","last_synced_at":"2026-02-11T20:31:51.055Z","repository":{"id":265149294,"uuid":"895279985","full_name":"lilBunnyRabbit/optional","owner":"lilBunnyRabbit","description":"TypeScript implementation of java.util.Optional\u003cT\u003e","archived":false,"fork":false,"pushed_at":"2025-01-24T00:19:49.000Z","size":123,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-24T01:20:50.750Z","etag":null,"topics":["java-optional","npm-package","null-safety","optional","type-safety","typescript","typescript-library"],"latest_commit_sha":null,"homepage":"https://lilbunnyrabbit.github.io/optional/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lilBunnyRabbit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2024-11-27T22:50:26.000Z","updated_at":"2025-01-24T00:19:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"040b9fee-c378-4288-bff8-651871108cf0","html_url":"https://github.com/lilBunnyRabbit/optional","commit_stats":null,"previous_names":["lilbunnyrabbit/optional"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lilBunnyRabbit%2Foptional","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lilBunnyRabbit%2Foptional/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lilBunnyRabbit%2Foptional/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lilBunnyRabbit%2Foptional/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lilBunnyRabbit","download_url":"https://codeload.github.com/lilBunnyRabbit/optional/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239060460,"owners_count":19574970,"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":["java-optional","npm-package","null-safety","optional","type-safety","typescript","typescript-library"],"created_at":"2024-12-24T03:17:39.650Z","updated_at":"2025-10-30T21:30:26.707Z","avatar_url":"https://github.com/lilBunnyRabbit.png","language":"TypeScript","readme":"# [TypeScript](https://www.typescriptlang.org/) implementation of [java.util.Optional\u003cT\u003e](https://docs.oracle.com/javase/8/docs/api/java/util/Optional.html)\n\n[![npm version](https://img.shields.io/npm/v/@lilbunnyrabbit/optional.svg)](https://www.npmjs.com/package/@lilbunnyrabbit/optional)\n[![npm downloads](https://img.shields.io/npm/dt/@lilbunnyrabbit/optional.svg)](https://www.npmjs.com/package/@lilbunnyrabbit/optional)\n\n\u003e **Definition**\n\u003e A container object which may or may not contain a non-null value. If a value is present, isPresent() will return true and get() will return the value.\n\u003e Additional methods that depend on the presence or absence of a contained value are provided, such as orElse() (return a default value if value not present) and ifPresent() (execute a block of code if the value is present).\n\u003e\n\u003e This is a value-based class; use of identity-sensitive operations (including reference equality (==), identity hash code, or synchronization) on instances of Optional may have unpredictable results and should be avoided.\n\nThe main difference is that it doesn't throw errors if the value is not defined and simply just returns `null`.\n\n## Installation\n\nTo use this package in your project, run:\n\n```sh\nnpm i @lilbunnyrabbit/optional\n```\n\n## Simple Example\n\n```ts\nimport { Optional } from \"@lilbunnyrabbit/optional\";\n\nconst optional: Optional\u003cnumber\u003e = Optional(123);\n\nconst value: number | null = optional.get();\n\nif (optional.isPresent()) {\n  const copy: Optional.Present\u003cnumber\u003e = optional;\n  const presentValue: number = optional.get();\n} else {\n  const copy: OptionalEmpty = optional;\n  const emptyValue: null = optional.get();\n}\n\noptional.ifPresent((value) =\u003e console.log(\"Present:\", value));\n\nconst nested: string = optional.filter((value: number) =\u003e value \u003e 3)\n                               .map((value: number) =\u003e String(value))\n                               .orElse(456); // \"123\"\n```\n\n## Documentation\n\nIf you're looking for detailed API docs, check out the [full documentation](http://lilbunnyrabbit.github.io/optional) generated via [Typedoc](https://typedoc.org/).\n\n## Development\n\nThis section provides a guide for developers to set up the project environment and utilize various npm scripts defined in the project for efficient development and release processes.\n\n### Setting Up\n\nClone the repository and install dependencies:\n\n```sh\ngit clone https://github.com/lilBunnyRabbit/optional.git\ncd optional\nnpm install\n```\n\n### NPM Scripts\n\nThe project includes several npm scripts to streamline common tasks such as building, testing, and cleaning up the project.\n\n| Script              | Description                                                                                                                                                                                       | Command                 |\n| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------- |\n| **`build`**         | Compiles the [TypeScript](https://www.typescriptlang.org/) source code to JavaScript, placing the output in the `dist` directory. Essential for preparing the package for publication or testing. | `npm run build`         |\n| **`test`**          | Executes the test suite using [Jest](https://jestjs.io/). Crucial for ensuring that your code meets all defined tests and behaves as expected.                                                    | `npm test`              |\n| **`clean`**         | Removes both the `dist` directory and the `node_modules` directory. Useful for resetting the project's state during development or before a fresh install.                                        | `npm run clean`         |\n| **`changeset`**     | Manages versioning and changelog generation based on conventional commit messages. Helps prepare for a new release by determining which parts of the package need version updates.                | `npm run changeset`     |\n| **`release`**       | Publishes the package to npm. Uses `changeset publish` to automatically update package versions and changelogs before publishing. Streamlines the release process.                                | `npm run release`       |\n| **`generate:docs`** | Generates project documentation using [Typedoc](https://typedoc.org/). Facilitates the creation of comprehensive and accessible API documentation.                                                | `npm run generate:docs` |\n\nThese scripts are designed to facilitate the development process, from cleaning and building the project to running tests and releasing new versions. Feel free to use and customize them as needed for your development workflow.\n\n## Contribution\n\nContributions are always welcome! For any enhancements or bug fixes, please open a pull request linked to the relevant issue. If there's no existing issue related to your contribution, feel free to create one.\n\n## Support\n\nYour support is greatly appreciated! If this package has been helpful, consider supporting its development. Your contributions help maintain and improve this project.  \n\n[![GitHub Sponsor](https://img.shields.io/static/v1?label=Sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\u0026color=%23fe8e86)](https://github.com/sponsors/lilBunnyRabbit)\n\n## License\n\nMIT © Andraž Mesarič-Sirec","funding_links":["https://github.com/sponsors/lilBunnyRabbit"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flilbunnyrabbit%2Foptional","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flilbunnyrabbit%2Foptional","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flilbunnyrabbit%2Foptional/lists"}