Skip to content

mazecodes/categorizer

Repository files navigation

Categorizer

Tiny package to categorize array elements.


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.

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/AwesomeFeature)
  3. Commit your changes (git commit -m "Add Awesome Feature")
  4. Push to the branch (git push origin feature/AwesomeFeature)
  5. Open a Pull Request

Author

Maze Peterson:

Show your support

Give a ⭐ if you liked this project!

License

MIT © Maze Peterson

About

Tiny package to categorize array elements.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published