Simple and lightweight library to handle switch statements and Pattern Matching in JavaScript and typescript.
To install the package, you can use npm or your favorite package manager.
npm install switch-matcher
- Simple: Uses a syntax similar to JavaScript switch statements and chainable methods.
- Lightweight: Has few dependencies and is very lightweight.
- Versatile: Can be used in any JavaScript or TypeScript project.
To use the library, you need to import the match
function and use it in your code.
import { match } from "switch-matcher";
const result = match(5)
.case(1, () => "One")
.case(2, () => "Two")
.case(3, () => "Three")
.default(() => "Other");
console.log(result); // Other
If you want to contribute to the project, you can follow these steps:
- Fork the project.
- Create a new branch.
- Make your changes.
- Commit your changes.
- Push your changes to your fork.
- Open a pull request.
And that's it! You can easily contribute to the project and help improve it.
Here we will list the features that we plan to add to the library in the future.
Este paquete fue desarrollado por LeoLizc. Agradecemos a las siguientes personas y proyectos por sus contribuciones:
- leovergaramarq: Descripción breve de su contribución.
Este paquete está bajo la licencia MIT. Puedes ver el archivo de licencia aquí.