simple-compose
v1.2.2
Published
This is just a simple, zero dependency, vanilla JavaScript, 100% compatible with all browsers and straight forward compose of functions.
Downloads
220
Maintainers
Readme
Simple Compose
This is just a simple, zero dependency, vanilla JavaScript, 100% compatible with all browsers and straight forward compose of functions.
Here's why this exists:
- Redux compose is awesome, but is heavy;
- I searched for another composes libraries, but I don't find anything that I like;
- Come on, this "library" has less than 400 bytes what more do you want?
Built With
Vanilla Javascript and nothing more.
Installation
- Install the lib
ornpm install simple-compose
yarn add simple-compose
- Use it
import { compose } from 'simple-compose'; /* Your code */ export default compose(fn1, fn2, fn3, fn4, fn5, fn6, ..... f284)(mySimpleFunc)
Note
In case you need. The function that is returned by the compose
function, can accept as many params as you want but the subsequence function doesn't. Those functions just accept only one param, which is the param that the last function returned. See the examples below:
Wrong :red_circle:
function fn1(param1, param2, param3) {
/** Implementation */
}
function fn2(param1, param2, param3) {
/** Implementation */
}
compose(fn1, fn2)('foo', 'bar', 'xar');
Right :white_check_mark:
function fn1(param) {
/** Implementation */
}
function fn2(param1, param2, param3) {
/** Implementation */
}
compose(fn1, fn2)('foo', 'bar', 'xar');
Contributing
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
License
Distributed under the MIT License. See LICENSE
for more information.
Contact
Emmanuel Kant Duarte - @emmanuelkantf - [email protected]
Project Link: https://github.com/emmanuelkant/simple-compose