# eden-collection

> Eden Node JS Generic Collection Definition

Latest version **0.0.33** (published 2015-08-07) · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install eden-collection
pnpm add eden-collection
yarn add eden-collection
bun add eden-collection
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.33 |
| Published | 2015-08-07 |
| First published | 2014-09-22 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Christian Blanquera |
| Maintainers | cblanquera |
| Keywords | eden, library |

## Links

- npm: https://www.npmjs.com/package/eden-collection
- Repository: https://github.com/edenjs/collection
- Issues: https://github.com/edenjs/collection/issues
- npm.io page: https://npm.io/package/eden-collection

## Dependencies (2)

- [eden-class](https://npm.io/package/eden-class.md) 0.0.32
- [eden-model](https://npm.io/package/eden-model.md) 0.0.33

## Recent versions

- 0.0.33 (latest) — 2015-08-07
- 0.0.32 — 2015-06-01
- 0.0.31 — 2014-11-28
- 0.0.30 — 2014-11-28
- 0.0.28 — 2014-11-11
- 0.0.27 — 2014-11-11
- 0.0.26 — 2014-11-07
- 0.0.25 — 2014-11-06
- 0.0.24 — 2014-11-03
- 0.0.23 — 2014-10-17
- 0.0.21 — 2014-10-13
- 0.0.20 — 2014-10-08
- 0.0.17 — 2014-10-02
- 0.0.16 — 2014-10-02
- 0.0.15 — 2014-10-01
- … 4 more at https://npm.io/package/eden-collection/versions

## README

#Collection

DESCRIPTION

[![Build Status](https://api.travis-ci.org/edenjs/collection.png)](https://travis-ci.org/edenjs/collection)

## General

### Installation

```
npm install eden-collection
```

### Usage

```
var collection = require('eden-collection');
```

## Methods

  * [add](#add)

  * [cut](#cut)

  * [each](#each)

  * [get](#get)

  * [set](#set)

---

<a name="add"></a>

### add

```
 this add('Elizabeth');
```

Adds a row to the collection

#### Parameters

  1. 'Elizabeth' - object (string | character | integer | date)

#### Returns

 this

#### Example

##### Code

```
	users.addName('Elizabeth');
	users.addMi('B');
	users.addAge(22);
	users.addBday('September 13, 1992');

users[2].name;
users[2].mi;
users[2].age;
users[2].bday;
```

##### Outputs

```
'Elizabeth'
'B'
22
'September 13, 1992'
```

---

<a name="cut"></a>

### cut

```
 this cut(first | 1);
```

Cut the element from the array based on the index

#### Parameters

  1. first - string - array(collection) position to be cut
  	| 1 - integer - array(collection) position to be cut

#### Returns

 this

#### Example

##### Code

```
	users = collection([
		{ name: 'chris1', age: 42 },
		{ name: 'chris2', age: 32 },
		{ name: 'chase1', age: 22 },
		{ name: 'chase2', age: 12 },
		{ name: 'chase3', age: 2 }]);

users.cut('first');
users[0].name;
users.cut(1);
users[1].name;
users.cut('last');
users.length;
```

##### Outputs

```
//	cut the first collection - users { name: 'chris1', age: 42 }
'chris2'
//	cut the second collection - users { name: 'chase1', age: 22 }
'chase2'
//	cut the last collection - users { name: 'chase3', age: 2 }
2
```

---

<a name="each"></a>

### each

```
 this each(users[1].getName);
```

Loops through returned result sets

#### Parameters

  1. users[1].getName() - function (loop to be displayed)

#### Returns

 this

#### Example

##### Code

```
	users.each(function(i, user) {
				user.setName('Something2');
				});

users[1].getName();
```

##### Outputs

```
'Something2'
```

---

<a name="get"></a>

### get

```
 array get(raw[0].name);
```

Returns the row array

#### Parameters

  1. raw[0].name - function (to be displayed)

#### Returns

 array

#### Example

##### Code

```
	var raw = users.get();

raw[1].age;
raw[0].name;
```

##### Outputs

```
22
'Something2'
```

---

<a name="set"></a>

### set

```
 this set('bobby');
```

Sets data

#### Parameters

  1. 'bobby' - object (string | character | integer | date)
  			 - to be replace in existing data | rename

#### Returns

 this

#### Example

##### Code

```
	users = collection([
		{ name: 'chris1', age: 42 },
		{ name: 'chris2', age: 32 },
		{ name: 'chase1', age: 22 },
		{ name: 'chase2', age: 12 },
		{ name: 'chase3', age: 2 }]);

	users.setName('bobby');
users[0].name;
users[1].name;
users[2].name;
users[3].name;
users[4].name;
```

##### Outputs

```
'bobby'
'bobby'
'bobby'
'bobby'
'bobby'
```

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