Skip to content

Commit

Permalink
Refactor: Improve type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
EvandroLG committed Jan 25, 2025
1 parent fdcee42 commit 038e8b3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/playlist/playAudio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ import Audio from '../audio/Audio'
* @param {EventEmitter} emmiter - Event emitter for handling playlist events
* @returns {(files: string[], loop: boolean) => void} A function that handles audio playback
*/
const playAudio = (states: AudioPlaylistState, emmiter: EventEmitter) => {
const playAudio = (
states: AudioPlaylistState,
emmiter: EventEmitter,
): ((files: string[], loop: boolean) => void) => {
const playAudioHelper = (files: string[], loop: boolean) => {
const file = files[states.audioIndex]
const audio = Audio({ file, volume: states.volume })
Expand Down
6 changes: 6 additions & 0 deletions src/playlist/states.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import type { AudioType } from '../audio/types'

/**
* Represents the global state for an audio playlist.
*/
export type AudioPlaylistState = {
volume: number
loop: boolean
Expand All @@ -9,6 +12,9 @@ export type AudioPlaylistState = {
audioIndex: number
}

/**
* Default initial state for the audio playlist.
*/
const states: AudioPlaylistState = {
volume: 1,
loop: false,
Expand Down

0 comments on commit 038e8b3

Please sign in to comment.