The url property could be type of string

This commit is contained in:
freearhey 2021-04-02 17:49:00 +03:00
parent 13ce560427
commit 6860beba28
2 changed files with 3 additions and 3 deletions

View File

@ -33,7 +33,7 @@ async function main() {
let programs = [] let programs = []
console.log('Parsing:') console.log('Parsing:')
for (let item of queue) { for (let item of queue) {
const url = config.url(item) const url = typeof config.url === 'function' ? config.url(item) : config.url
if (options.debug) console.time(' time') if (options.debug) console.time(' time')
const progs = await client const progs = await client
.get(url) .get(url)

View File

@ -21,8 +21,8 @@ utils.loadConfig = function (file) {
if (!config.site) throw new Error("The required 'site' property is missing") if (!config.site) throw new Error("The required 'site' property is missing")
if (!config.channels) throw new Error("The required 'channels' property is missing") if (!config.channels) throw new Error("The required 'channels' property is missing")
if (!config.url) throw new Error("The required 'url' property is missing") if (!config.url) throw new Error("The required 'url' property is missing")
if (typeof config.url !== 'function') if (typeof config.url !== 'function' && typeof config.url !== 'string')
throw new Error("The 'url' property should return the function") throw new Error("The 'url' property should return the function or string")
if (!config.parser) throw new Error("The required 'parser' function is missing") if (!config.parser) throw new Error("The required 'parser' function is missing")
if (typeof config.parser !== 'function') if (typeof config.parser !== 'function')
throw new Error("The 'parser' property should return the function") throw new Error("The 'parser' property should return the function")