fix(Queue): watch destroyed state for insert method
This commit is contained in:
parent
751ce122bc
commit
1c9a00bf1a
1 changed files with 1 additions and 0 deletions
|
@ -534,6 +534,7 @@ class Queue<T = unknown> {
|
||||||
* @param {number} [index=0] The index where this track should be
|
* @param {number} [index=0] The index where this track should be
|
||||||
*/
|
*/
|
||||||
insert(track: Track, index = 0) {
|
insert(track: Track, index = 0) {
|
||||||
|
if (this.#watchDestroyed()) return;
|
||||||
if (!track || !(track instanceof Track)) throw new PlayerError("track must be the instance of Track", ErrorStatusCode.INVALID_TRACK);
|
if (!track || !(track instanceof Track)) throw new PlayerError("track must be the instance of Track", ErrorStatusCode.INVALID_TRACK);
|
||||||
if (typeof index !== "number" || index < 0 || !Number.isFinite(index)) throw new PlayerError(`Invalid index "${index}"`, ErrorStatusCode.INVALID_ARG_TYPE);
|
if (typeof index !== "number" || index < 0 || !Number.isFinite(index)) throw new PlayerError(`Invalid index "${index}"`, ErrorStatusCode.INVALID_ARG_TYPE);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue