-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample08.ts
More file actions
37 lines (32 loc) · 928 Bytes
/
example08.ts
File metadata and controls
37 lines (32 loc) · 928 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
class FileLoader {
load(path: string): Buffer {
console.log(`Завантаження файлу з ${path}`);
return Buffer.from("file data");
}
}
class Decoder {
decode(data: Buffer): string {
console.log("Декодування даних");
return data.toString();
}
}
class AudioProcessor {
normalize(audio: string): string {
console.log("Нормалізація аудіо");
return audio.toUpperCase();
}
}
class AudioPlayer {
play(audio: string): void {
console.log(`Відтворення: ${audio}`);
}
}
// Клієнтський код повинен знати всі кроки
const loader = new FileLoader();
const decoder = new Decoder();
const processor = new AudioProcessor();
const player = new AudioPlayer();
const file = loader.load("song.mp3");
const decoded = decoder.decode(file);
const processed = processor.normalize(decoded);
player.play(processed);