From f9c26089cd09aef37c66757427daef4c68395f42 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Tue, 19 May 2015 15:25:44 +0200 Subject: [PATCH] Document exceptions. --- packages/xo-collection/README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/xo-collection/README.md b/packages/xo-collection/README.md index 96a669f7c..50ed2bded 100644 --- a/packages/xo-collection/README.md +++ b/packages/xo-collection/README.md @@ -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