feat(Queue): queue#insert method

This commit is contained in:
Snowflake107 2021-06-30 01:14:44 +05:45
parent 47039821ee
commit 67648af97b
2 changed files with 15 additions and 1 deletions

View file

@ -498,6 +498,20 @@ class Queue<T = unknown> {
return void this.skip();
}
/**
* Inserts the given track to specified index
* @param {Track} track The track to insert
* @param {number} [index=0] The index where this track should be
*/
insert(track: Track, index = 0) {
if (!track || !(track instanceof Track)) throw new TypeError("track must be the instance of Track");
if (typeof index !== "number" || index < 0 || !Number.isFinite(index)) throw new Error(`Invalid index "${index}"`);
this.tracks.splice(index, 0, track);
this.player.emit("trackAdd", this, track);
}
/**
* @typedef {object} PlayerTimestamp
* @property {string} current The current progress