mirror of
https://github.com/heyarne/berliner-winter.git
synced 2026-05-06 19:23:39 +02:00
Implement filter by year
This commit is contained in:
parent
a2b6e437d4
commit
7bf461d097
4 changed files with 54 additions and 10 deletions
|
|
@ -6,7 +6,7 @@ export default {
|
|||
* @param {Array[String]} categories
|
||||
* @return {Array[Obect]}
|
||||
*/
|
||||
categories: function (data, categories) {
|
||||
byCategories: function (data, categories) {
|
||||
return data.filter(function (incident) {
|
||||
for (var i = 0, l = incident.categories.length; i < l; i++)
|
||||
if (categories.indexOf(incident.categories[i]) !== -1)
|
||||
|
|
@ -14,6 +14,15 @@ export default {
|
|||
|
||||
return false
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* Return only the incidents that happened in a given year
|
||||
*/
|
||||
byYear: function (data, year) {
|
||||
return data.filter(function (incident) {
|
||||
return incident.date.indexOf(year) === 0
|
||||
})
|
||||
}
|
||||
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue