# @cheesebit/partition

> Creates an object splitting given collection into groups, based on the return of the given predicate when invoked with each collection's item.

Latest version **1.1.0** (published 2021-02-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install @cheesebit/partition
pnpm add @cheesebit/partition
yarn add @cheesebit/partition
bun add @cheesebit/partition
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2021-02-28 |
| First published | 2021-02-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Welington Silva |
| Maintainers | welingtonms |
| Keywords | partition, groups, group by |

## Links

- npm: https://www.npmjs.com/package/@cheesebit/partition
- Repository: https://github.com/cheesebit/partition
- Homepage: https://github.com/cheesebit/partition#readme
- Issues: https://github.com/cheesebit/partition/issues
- npm.io page: https://npm.io/package/@cheesebit/partition

## Dependencies (1)

- [@babel/preset-typescript](https://npm.io/package/@babel/preset-typescript.md) 7.13.0

## Recent versions

- 1.1.0 (latest) — 2021-02-28
- 1.0.0 — 2021-02-28

## README

# @cheesebit/partition

[![Coverage Status](https://img.shields.io/coveralls/github/cheesebit/partition?style=flat-square)](https://coveralls.io/github/cheesebit/partition)
[![npm package](https://img.shields.io/npm/v/@cheesebit/partition?style=flat-square)](https://www.npmjs.com/package/@cheesebit/partition)

Creates an object splitting given collection into groups, based on the return of the given predicate when invoked with each collection's item.

## Instalation

You can add this library as a dependency by running `npm install @cheesebit/partition` or `yarn add @cheesebit/partition`.

## Usage guide

```js
  import partition from '@cheesebit/partition';

  const { supplies, tools, toys } = partition([{
    name: 'pen',
    type: 'supply'
  }, {
    name: 'lamp',
    usage: 'maintenance'
  }, {
    name: 'Buzz lightyear',
    type: 'toy'
  }, {
    name: 'pliers',
    type: 'tool'
  }], item => {
    if (item.usage === 'maintenance' || item.type === 'tool') {
      return 'tools'
    }

    if (item.type === 'toy') {
      return 'toys'
    }

    return 'supplies'
  })

  console.log(supplies); // [{ name: 'pen', type: 'supply' }]
  console.log(tools); // [{ name: 'lamp', usage: 'maintenance' }, { name: 'pliers', type: 'tool' }]
  console.log(toys); // [{ name: 'Buzz lightyear', type: 'toy' }]
```

---
_Source: https://npm.io/package/@cheesebit/partition · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
