Document exceptions.

This commit is contained in:
Julien Fontanet 2015-05-19 15:25:44 +02:00
parent 7ddb57078c
commit f9c26089cd

View File

@ -31,12 +31,16 @@ var col = new Collection()
col.add('foo', true)
```
- **Throws** `DuplicateItem` if the item is already in the collection.
**Updating an existing item**
```javascript
col.update('foo', false)
```
- **Throws** `NoSuchItem` if the item is not in the collection.
**Inserting or updating an item**
```javascript
@ -67,12 +71,17 @@ col.touch('baz')
col.touch('baz').prop = false
```
- **Throws** `NoSuchItem` if the item is not in the collection.
- **Throws** `IllegalTouch` if the item is not an object.
**Removing an existing item**
```javascript
col.remove('bar')
```
- **Throws** `NoSuchItem` if the item is not in the collection.
**Removing all items**
```javascript
@ -97,6 +106,9 @@ var foo = col.get('foo')
var bar = col.get('bar', 6.28)
```
- **Throws** `NoSuchItem` if the item is not in the collection and no
fallback has been passed.
**Getting a read-only view of the collection**
> This property is useful for example to iterate over the collection