continue uniformizing + ditch lodash for native JS methods.

This commit is contained in:
theofficialomega
2025-07-16 12:37:34 +02:00
parent 2f5d209f5f
commit d8e4372f22
13 changed files with 67 additions and 31 deletions

View File

@@ -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',