mirror of
https://github.com/iptv-org/epg
synced 2026-05-06 01:17:02 -04:00
continue uniformizing + ditch lodash for native JS methods.
This commit is contained in:
@@ -3,18 +3,7 @@ const axios = require('axios')
|
||||
|
||||
// Remove the big lodash dependency by implementing a simple uniqBy function
|
||||
// Complexity = O(n)
|
||||
const uniqBy = (arr, predicate) => {
|
||||
const cb = typeof predicate === 'function' ? predicate : (o) => o[predicate]
|
||||
|
||||
return [...arr.reduce((map, item) => {
|
||||
const key = (item === null || item === undefined) ?
|
||||
item : cb(item)
|
||||
|
||||
if (!map.has(key)) map.set(key, item)
|
||||
|
||||
return map
|
||||
}, new Map()).values()]
|
||||
}
|
||||
const uniqBy = (arr, fn) => [...new Map(arr.map(x => [fn(x), x])).values()]
|
||||
|
||||
module.exports = {
|
||||
site: 'tv.mail.ru',
|
||||
|
||||
Reference in New Issue
Block a user