This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// #### Гуард-функции с утиной типизацией | |
// Создайте гуард-функцию `isGameCharacter` с использованием оператора `is`, | |
// которая проверяет, является ли объект игровым персонажем по принципам утиной типизации. | |
// Объект должен иметь свойства `name: string` и метод `move(): string`. | |
// Используйте эту гуард-функцию в функции processCharacter, которая возвращает | |
// описание персонажа (например, ` `${name} moves: ${move()}` `) для валидных персонажей | |
// или `"Not a game character!"` для остальных. | |
// Пример использования: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// #### Паттерн Композиция — Система умного дома | |
// Создайте систему управления умным домом, использующую паттерн Композиция | |
// для управления различными устройствами (например, свет, термостат). | |
// Реализуйте класс SmartHome, который содержит коллекцию устройств и предоставляет методы | |
// для их массового включения, выключения и получения статуса. | |
// Каждое устройство должно реализовать интерфейс с методами включения, выключения и получения статуса. | |
// Требования: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type User = { | |
id: number | |
name: string | |
email?: string | |
} | |
type UserDict = { | |
[key: User['id']]: User | |
} | |
function getUserEmail(id: number, users: UserDict): string | undefined { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Identifier = string | number | |
// ======= | |
const ReadOperation: symbol = Symbol('Read') | |
const WriteOperation: symbol = Symbol('Write') | |
const UpdateOperation: symbol = Symbol('Update') | |
type Operations = typeof ReadOperation | typeof WriteOperation | typeof UpdateOperation | |
// ======= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @name Parameters | |
* @type {object} | |
* @property {Record<string, string>} [headers] - Request headers | |
* @property {string|JSON|ArrayBuffer} [body] - Request body | |
* @property {"json"|"text"|"document"|"buffer"} [contentType] - Content type | |
*/ | |
/** | |
* @name ResponseObject |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
'drag', 'dragdrop', 'dragend', 'dragenter', 'dragexit', 'draggesture', 'dragleave', 'dragover', 'dragstart', 'drop', | |
'click', 'dblclick', | |
'keydown', 'keypress', 'keyup', | |
'mousedown', 'mouseenter', 'mouseleave', 'mousemove', 'mouseout', 'mouseover', 'mouseup', 'mousewheel', | |
'pointerlockchange', 'pointerlockerror', | |
'wheel', | |
'touchcancel', 'touchend', 'touchenter', 'touchleave', 'touchmove', 'touchstart', | |
'pointerover', 'pointerenter', 'pointerdown', 'pointermove', 'pointerup', 'pointercancel', 'pointerout', 'pointerleave', 'gotpointercapture', 'lostpointercapture', | |
].forEach(eName => document.addEventListener(eName, e => console.log(e.type))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://developer.mozilla.org/en/docs/Web/Guide/Events/Media_events | |
export const mediaEvents = [ | |
'abort', | |
'canplay', | |
'canplaythrough', | |
'durationchange', | |
'emptied', | |
// 'encrypted', | |
'ended', |