categorizer
v0.1.0
Published
Tiny package to categorize array elements.
Downloads
1
Readme
Table of Contents
Install
npm:
npm install categorizer
Yarn:
yarn add categorizer
GitHub:
git clone https://github.com/mazecodes/categorizer.git
Usage
Using with a categorizer object:
const { categorize } = require('categorizer');
const array = [0, 1, 2, 3, 4];
const result = categorize(array, {
even(value) {
return value % 2 === 0;
},
odd(value) {
return value % 2 !== 0;
},
});
Using with a categorizer function:
const { categorize } = require('categorizer');
const array = [0, 1, 2, 3, 4];
const result = categorize(array, value => {
if (value % 2 === 0) return 'even';
return 'odd';
});
Run tests
npm run test
Contributing
All contributions, issues and feature requests are welcome! Please feel free to check issues page.
- Fork the project
- Create your feature branch (
git checkout -b feature/AwesomeFeature
) - Commit your changes (
git commit -m "Add Awesome Feature"
) - Push to the branch (
git push origin feature/AwesomeFeature
) - Open a Pull Request
Author
Maze Peterson:
Show your support
Give a ⭐ if you liked this project!
License
MIT © Maze Peterson