OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 cr.define('media', function() { | 5 cr.define('media', function() { |
6 | 6 |
7 /** | 7 /** |
8 * This class stores hashes by their id field and provides basic methods for | 8 * This class stores hashes by their id field and provides basic methods for |
9 * iterating over the collection. | 9 * iterating over the collection. |
10 * @constructor | 10 * @constructor |
11 */ | 11 */ |
12 function ItemStore() { | 12 function ItemStore() { |
13 this.items_ = {}; | 13 this.items_ = {}; |
14 }; | 14 } |
15 | 15 |
16 ItemStore.prototype = { | 16 ItemStore.prototype = { |
17 /** | 17 /** |
18 * Get a sorted list of item ids. | 18 * Get a sorted list of item ids. |
19 * @return {Array} A sorted array of ids. | 19 * @return {Array} A sorted array of ids. |
20 */ | 20 */ |
21 ids: function() { | 21 ids: function() { |
22 var ids = []; | 22 var ids = []; |
23 for (var i in this.items_) | 23 for (var i in this.items_) |
24 ids.push(i); | 24 ids.push(i); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 var items = this.items_; | 61 var items = this.items_; |
62 var ids = this.ids(); | 62 var ids = this.ids(); |
63 return ids.map(function(id) { return mapper(items[id]); }); | 63 return ids.map(function(id) { return mapper(items[id]); }); |
64 } | 64 } |
65 }; | 65 }; |
66 | 66 |
67 return { | 67 return { |
68 ItemStore: ItemStore | 68 ItemStore: ItemStore |
69 }; | 69 }; |
70 }); | 70 }); |
OLD | NEW |