# @anonmily/collections

> Representation of a collection of objects. Filter, sort, map, and query at will.

Latest version **0.1.5** (published 2017-01-16) · ISC license · 0 weekly downloads

## Install

```sh
npm install @anonmily/collections
pnpm add @anonmily/collections
yarn add @anonmily/collections
bun add @anonmily/collections
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.5 |
| Published | 2017-01-16 |
| First published | 2016-11-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Michelle Liu |
| Maintainers | anonmily |

## Links

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

## Dependencies (2)

- [lodash](https://npm.io/package/lodash.md) ^4.17.0
- [simply-is](https://npm.io/package/simply-is.md) ^2.5.8

## Recent versions

- 0.1.5 (latest) — 2017-01-16
- 0.1.4 — 2017-01-10
- 0.1.3 — 2016-11-15
- 0.1.2 — 2016-11-15
- 0.1.1 — 2016-11-15
- 0.1.0 — 2016-11-15
- 0.0.6 — 2016-11-15

## README

# Collection utilities

Representation of a collection of objects.

# Usage example

```
let people = new Collection([
	{ name: 'john', age: 41 }, 
	{ name: 'amy', age: 30 },
	{ name: 'harry', age: 4 } 
	{ name: 'amy', age: 30 }
])

// Cloning, get unique elements only, filter, and sort
let adults = collection
	.clone()
	.unique()
	.filter( person => person.age > 21 )
	.sort({ name: 'asc' })
```

Mapping is also supported.

```
let ages = people.unique().map( x => x.age ).sort()

// will return [4, 30, 41]
```


Complex filters can be used. 

```
people.filter([(x => x.age > 21), { name: 'amy' }]
```

When adding new data to a collection, it can be helpful to only add/update changes.

```
let new_people = [
	{ name: 'john', age: 41 }
	{ name: 'anthony', age: 23 }
]

people.merge( new_people, 'name' }

```

To return the collection to its original state, when it was first declared, (e.g. to reset filters):

```
people.reset()
```

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