function assertNotPartial<T>(entry: Partial<T>): asserts entry is Required<T> {
if (Object.values(entry).every((value) => value !== undefined)) {
return;
}
throw Error('YOUR ERROR MESSAGE');
}
assertNotPartial(videoInfo);
console.log(videoInfo); // Тут не будет в типе undefined'ов
const groupBy = (collection, extractKey) =>
collection.reduce((acc, item) => {
const key = extractKey(item);
acc[key] ??= [];
acc[key].push(item);
return acc;
}, {});
const data = groupBy(array, (person) => person.role);
Object.groupBy(array, (person) => person.role);
<div class="scroll-blocker">
<YOUR_MAP />
</div>
const mouse = { x: -1, y: -1 };
const elements = document.getElementsByClassName('scroll-blocker');
window.addEventListener('mousemove', (event) => {
mouse.x = event.clientX;
mouse.y = event.clientY;
});
window.addEventListener('wheel', (event) => {
const target = document.elementFromPoint(mouse.x, mouse.y);
for (const element of elements) {
if (element.contains(target)) {
event.preventDefault();
return;
}
}
}, { passive: false, capture: true });
const input = document.querySelector('input');
input.addEventListener('input', (event) => {
const value = event.target.value
.replace(/^\+?[78]/, '')
.replace(/[^0-9]/g, '')
.slice(0, 10);
event.target.value = value;
});
IMask(document.querySelector('input'), { mask: '000 000 00 00' });
$(document).on('click', '.content .child', function(event){
event.stopPropagation();
});
.option:has(input:checked) {
background-color: peachpuff;
}
.option.active {
background-color: peachpuff;
}
const optionsContainer = document.querySelector('.options');
const options = optionsContainer.querySelectorAll('.option');
optionsContainer.addEventListener('click', (event) => {
const option = event.target.closest('.option');
if (option !== null) {
options.forEach((entry) => entry.classList.remove('active'));
option.classList.add('active');
}
});