iptv/scripts/store/setters/regions.js

23 lines
488 B
JavaScript
Raw Normal View History

2021-12-12 05:12:06 +01:00
const _ = require('lodash')
let regions = require('../../data/regions')
module.exports = function ({ countries }) {
if (!countries.length) return []
const output = []
regions = Object.values(regions)
countries.forEach(country => {
regions
.filter(region => region.country_codes.includes(country.code))
.forEach(found => {
output.push({
name: found.name,
code: found.code
})
})
})
return _.uniqBy(output, 'code')
}