filteredArray() {
return this.array
.filter((el) => {
return (!this.search.length ? true : (el?.name?.toLowerCase().includes(this.search) ||
el?.surname?.toLowerCase().includes(this.search))) &&
(this.salary === null ? true : el.salary === this.salary) &&
(this.quality === null ? true : el.quality === this.quality) &&
(this.rating === null ? true : el.rating === this.rating && el.mode !== MODES.HIGH) &&
(this.body === null ? true : (this.body === Bodys.CHECKED ? el.workers.some(({ checked }, index) =>
index <= el.workersIds.length - 1 ? !checked : false
)
: el.workers.every(({ checked }, index) =>
index <= el.workersIds.length - 1 ? checked : true
)) )
}).sort((a, b) => {
if (a?.name?.toLowerCase() > b?.name?.toLowerCase()) {
return isDesc ? -1 : 1;
}
if (a?.name?.toLowerCase() < b?.name?.toLowerCase()) {
return isDesc ? 1 : -1;
}
return 0;
});
},
users.map((user) => {
const findAppointments = appointments.find((item) => item.masterInfo.userId === user.userId && user.timings.some((time) => item.time.includes(time)));
if (!findAppointments) return null;
return user.timings.filter((time) => !findAppointments.time.includes(time));
}).flat();
[...new Map(arr.map((item) => [item["key"], item])).values()]
const uniqueIds = [];
arr.filter(element => {
const isDuplicate = uniqueIds.includes(element.key);
if (!isDuplicate) {
uniqueIds.push(element.key);
return true;
}
return false;
});
Object.values(
arr.reduce( (c, e) => {
if (!c[e.key]) c[e.key] = e;
return c;
}, {})
);
const unique = (arr, key) => {
const keys = new Set();
return arr.filter(el => !keys.has(el[key]) && keys.add(el[key]));
};
unique(arr, 'key')
var mySwiper2 = new Swiper('.swiper-container-two', {
slidesPerView: 'auto',
loop: true,
navigation: {
nextEl: '.lisenses .swiper-button-next',
prevEl: '.lisenses .swiper-button-prev',
},
breakpoints: {
320: {
slidesPerView: 1.5,
},
550: {
slidesPerView: 2.5,
},
768: {
slidesPerView: 3.5,
},
1080: {
slidesPerView: 'auto',
}
}
});
import {throttle} from 'lodash'
const throttled = throttle(() => console.log('throttle'), 1000)
throttled()