mirror of
https://github.com/heyarne/berliner-winter.git
synced 2026-05-06 19:23:39 +02:00
28 lines
715 B
JavaScript
28 lines
715 B
JavaScript
export default {
|
|
|
|
/**
|
|
* Returns only the incidents which fall into the given categories
|
|
* @param {Array[Object]} data The incidents to filter
|
|
* @param {Array[String]} categories
|
|
* @return {Array[Obect]}
|
|
*/
|
|
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)
|
|
return true
|
|
|
|
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
|
|
})
|
|
}
|
|
|
|
};
|