categorizer

0.1.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i categorizer

Weekly Downloads

1

Version

0.1.0

License

MIT

Unpacked Size

6.42 kB

Total Files

10

Last publish

Collaborators

  • mazecodes