From 23e7542871a33d490da45d100ec2675f9c116806 Mon Sep 17 00:00:00 2001 From: Julien Fontanet Date: Tue, 7 Apr 2015 18:15:38 +0200 Subject: [PATCH] Document Collection#all. --- packages/xo-collection/README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/packages/xo-collection/README.md b/packages/xo-collection/README.md index 16ca4daf0..40265afd9 100644 --- a/packages/xo-collection/README.md +++ b/packages/xo-collection/README.md @@ -97,6 +97,25 @@ var foo = col.get('foo') var bar = col.get('bar', 6.28) ``` +**Getting a read-only view of the collection** + +> This property is useful for example to iterate over the collection +> or to make advanced queries with the help of utility libraries such +> as lodash. + +```javascript +var _ = require('lodash') + +// Prints all the entries. +_.forEach(col.all, function (value, key) { + console.log('- %s: %j', key, value) +}) + +// Finds all the entries which are objects and have a property +// `active` which equals `true`. +var results = _.where(col.all, { active: true }) +``` + **Getting the number of entries** ```javascript