diff --git a/src/index.js b/src/index.js index 61d4849..3352668 100644 --- a/src/index.js +++ b/src/index.js @@ -32,7 +32,7 @@ class YoutubeMusicApi { }) this.client.interceptors.response.use(res => { if (res.headers.hasOwnProperty('set-cookie')) { - if (res.headers['set-cookie'] instanceof Array) { + if (Array.isArray(res.headers['set-cookie'])) { res.headers['set-cookie'].map(value => { this.cookies.setCookieSync(tough.Cookie.parse(value), res.config.baseURL) }) @@ -215,7 +215,7 @@ class YoutubeMusicApi { result.content = _.concat(result.content, continuationResult.content) result.continuation = continuationResult.continuation } - if (!Array.isArray(continuationResult.continuation) && result.continuation instanceof Object) { + if (!Array.isArray(continuationResult.continuation) && typeof result.continuation === 'object') { if (contentLimit > result.content.length) { getContinuations(continuationResult.continuation) } else { @@ -227,7 +227,7 @@ class YoutubeMusicApi { }) } - if (contentLimit > result.content.length && (!Array.isArray(result.continuation) && result.continuation instanceof Object)) { + if (contentLimit > result.content.length && (!Array.isArray(result.continuation) && typeof result.continuation === 'object')) { getContinuations(result.continuation) } else { return resolve(result) diff --git a/src/parsers.js b/src/parsers.js index 6c6a2a7..c0d2428 100644 --- a/src/parsers.js +++ b/src/parsers.js @@ -47,7 +47,7 @@ exports.parseSearchResult = (context) => { })(), album: (function() { var c = (_.nth(utils.fv(_.nth(flexColumn, 1), 'runs'), 4)) - if (!Array.isArray(c) && c instanceof Object) return { + if (!Array.isArray(c) && typeof c === 'object') return { name: utils.fv(c, 'text'), browseId: utils.fv(c, 'browseEndpoint:browseId') } @@ -179,7 +179,7 @@ exports.parseSongSearchResult = (context) => { })(), album: (function() { var c = _.first(utils.fv(flexColumn[1], 'runs', true)) - if (!Array.isArray(c) && c instanceof Object) return { + if (!Array.isArray(c) && typeof c === 'object') return { name: utils.fv(c, 'text'), browseId: utils.fv(c, 'browseEndpoint:browseId', true) } @@ -388,7 +388,7 @@ exports.parseArtistPage = context => { name: utils.fv(_.nth(flexColumn, 0), 'runs:text'), album: (function() { var c = (utils.fv(_.nth(flexColumn, 2), 'runs')) - if (!Array.isArray(c) && c instanceof Object) return { + if (!Array.isArray(c) && typeof c === 'object') return { name: utils.fv(c, 'text'), browseId: utils.fv(c, 'browseEndpoint:browseId') } @@ -469,7 +469,7 @@ exports.parseArtistPage = context => { break } } - } else if (itemContext instanceof Object) { + } else if (typeof itemContext === 'object') { switch (carouselName) { case 'singles': result.products[carouselName].content.push({