diff --git a/lib/utils/index.js b/lib/utils/index.js index cede5b3..14ec8b9 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -1,22 +1,21 @@ const checkOptions = (options) => { - let { apiKey, title, artist } = options; - if (!apiKey) { - throw '"apiKey" property is missing from options'; - } else if (!title) { - throw '"title" property is missing from options'; - } else if (!artist) { - throw '"artist" property is missing from options'; - } + if (!("apiKey" in options) || !options.apiKey) { + throw '"apiKey" property is missing from options'; + } else if (!("title" in options)) { + throw '"title" property is missing from options'; + } else if (!("artist" in options)) { + throw '"artist" property is missing from options'; + } }; const getTitle = (title, artist) => { - return `${title} ${artist}` - .toLowerCase() - .replace(/ *\([^)]*\) */g, '') - .replace(/ *\[[^\]]*]/, '') - .replace(/feat.|ft./g, '') - .replace(/\s+/g, ' ') - .trim(); + return `${title} ${artist}` + .toLowerCase() + .replace(/ *\([^)]*\) */g, "") + .replace(/ *\[[^\]]*]/, "") + .replace(/feat.|ft./g, "") + .replace(/\s+/g, " ") + .trim(); }; module.exports = { checkOptions, getTitle };