# digitaledgeit-observable-collection

> An `Array` wrapper that emits events when the underlying `Array` is modified.

Latest version **0.1.1** (published 2015-04-19) · 0 weekly downloads

## Install

```sh
npm install digitaledgeit-observable-collection
pnpm add digitaledgeit-observable-collection
yarn add digitaledgeit-observable-collection
bun add digitaledgeit-observable-collection
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2015-04-19 |
| First published | 2015-04-13 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | jameslnewell |

## Links

- npm: https://www.npmjs.com/package/digitaledgeit-observable-collection
- npm.io page: https://npm.io/package/digitaledgeit-observable-collection

## Dependencies (1)

- [component-emitter](https://npm.io/package/component-emitter.md) ^1.2.0

## Recent versions

- 0.1.1 (latest) — 2015-04-19
- 0.1.0 — 2015-04-13

## README

# observable-collection

An `Array` wrapper that emits events when the underlying `Array` is modified.

## Installation

    $ npm install --save digitaledgeit-observable-collection

## Usage
    
    var collection = require('digitaledgeit-observable-collection');
    
    function update(item, index) {
      //update the view
    }
    
    collection()
      .on('added',    update)
      .on('removed',  update)
      .on('emptied',  update)
      .append({name: 'Bill'})
      .append({name: 'Mark'})
      .prepend({name: 'Steve'})
      .each(function(item) {
        console.log(item);
      })
    ;

## API

### new Collection()

Create a new collection.

### Properties

#### .first : *

Get the first item in the collection.

#### .last : *

Get the last item in the collection.

#### .empty : boolean

Check whether the collection is empty.

#### .length : number

Get the length of the collection.

### Methods

#### .at(index : number) : *
#### .contains(item : *) : boolean
#### .indexOf(item : *) : number
#### .prepend(item : *)
#### .append(item : *)
#### .remove(item : *)
#### .removeAt(index : number)
#### .removeAll()
#### .each(fn : function)
#### .find(fn : function) : *
#### .toArray() : Array
#### .toString() : string

### Events

#### #added
- item
- index

#### #removed
- item
- index

#### #emptied

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