mirror of
https://github.com/mastodon/mastodon.git
synced 2025-01-10 04:06:27 +01:00
Refactor uniq
function for TS compliance and efficiency improvements
This commit refactors the `uniq` function found in the emoji utilities to accept an explicitly defined array as an argument, improving overall TypeScript compliance. It also replaces the `.indexOf` method with the more efficient `.includes` method for better performance.
This commit is contained in:
parent
728ca82d79
commit
d922b619e3
@ -200,25 +200,22 @@ function getData(...[emoji, skin, set]: GetDataArgs) {
|
||||
/* eslint-enable @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-return */
|
||||
}
|
||||
|
||||
/* eslint-disable */
|
||||
|
||||
// @ts-expect-error
|
||||
function uniq(arr) {
|
||||
// @ts-expect-error
|
||||
function uniq(arr: []) {
|
||||
return arr.reduce((acc, item) => {
|
||||
if (acc.indexOf(item) === -1) {
|
||||
if (!acc.includes(item)) {
|
||||
acc.push(item);
|
||||
}
|
||||
return acc;
|
||||
}, []);
|
||||
}
|
||||
|
||||
/* eslint-disable */
|
||||
|
||||
// @ts-expect-error
|
||||
function intersect(a, b) {
|
||||
const uniqA = uniq(a);
|
||||
const uniqB = uniq(b);
|
||||
|
||||
// @ts-expect-error
|
||||
return uniqA.filter((item) => uniqB.indexOf(item) >= 0);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user