Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marpme/niniera
Elevating JavaScript with Rust's Error Magic ๐ช - Bridging the Gap Between JavaScript and Rust for Effortless Error Handling and Elegance
https://github.com/marpme/niniera
error-handling javascript library optional promises rust-lang typescript wrapper
Last synced: about 1 month ago
JSON representation
Elevating JavaScript with Rust's Error Magic ๐ช - Bridging the Gap Between JavaScript and Rust for Effortless Error Handling and Elegance
- Host: GitHub
- URL: https://github.com/marpme/niniera
- Owner: marpme
- License: apache-2.0
- Created: 2023-11-04T10:34:08.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-05-14T09:16:47.000Z (6 months ago)
- Last Synced: 2024-05-14T10:34:34.099Z (6 months ago)
- Topics: error-handling, javascript, library, optional, promises, rust-lang, typescript, wrapper
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/nini-era
- Size: 64.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# nini-era ๐
### Bringing Rust-Inspired Optional and Error Handling to JavaScript
**nini-era** is a npm package that introduces Rust's `Option` and error handling concepts to JavaScript, offering a powerful and elegant solution.
The name "nini-era" is inspired by the Japanese term "nini era" (ไปปๆใจใฉใผ), which conveys the idea of an error that is not mandatory and can be managed or ignored based on the context. This library aims to simplify and enhance error handling and optional value management in your JavaScript code.
## Key Features ๐
With **nini-era**, you can:
- Effortlessly handle errors ๐ ๏ธ
- Streamline your error-handling workflow with clean and concise code ๐You can chain error-handling operations, making your code more readable and maintainable, particularly in scenarios involving multiple error-prone operations.
## Installation ๐ก
You can install **nini-era** via npm:
```bash
npm add nini-era
```## Usage ๐ป
Here's a brief overview of how you can use **nini-era** in your JavaScript code:
```javascript
// Everything happens synchronously
// Similar to working with promises
const result = Optional.of(anyFunction)
// Continue using the return value
.then((value) => transform(value))
// Customize the error message if 'then' fails
.expect("something to happen")
// Handle any occurring error, attempting to rescue or rethrow
.catch((error) => transformError(error))
// Unwrap the final value
.unwrap();
```In certain cases, you may wish to provide a default value in the event of an error. This default value is utilized only when an error occurs.
```javascript
// Result will either be the return type of 'transform(value)' or 'defaultTransformed'
const result = Optional.of(anyFunction)
// Continue using the return value
.then((value) => transform(value))
// Unwrap the final value or provide an alternative value
.elseUnwrap(() => defaultTransformed);
```## Documentation ๐
For more in-depth information on using **nini-era**, refer to the [documentation](./API.md) of this repository.
## Contributing ๐ค
We welcome contributions from the community! If you want to enhance **nini-era**, please review our [contribution guidelines](./CONTRIBUTING.md) to get started.
## License ๐
**nini-era** is licensed under the Apache-2.0 License. See [LICENSE](LICENSE) for more details.
## Credits ๐
**nini-era** draws inspiration from the simplicity and elegance of Rust's `Option` and error handling. We extend our gratitude to the Rust community for inspiring this project.
[GitHub Repository](https://github.com/marpme/niniera)
---
_"nini-era - Where simplicity meets elegance."_