Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function writeFeed(response, data, writeFeedComplete) {
// Log
me.log('debug', `Feedr === writing [${feed.url}] to [${feed.path}]`)
// Prepare
const writeTasks = TaskGroup.create({ concurrency: 0 }).done(function(
err
) {
if (err) {
// Log
me.log(
'warn',
`Feedr === writing [${feed.url}] to [${feed.path}], write failed`,
err.stack
)
// Exit
writeFeedComplete(err)
return
}
// Log
function viaCache(viaCacheComplete) {
// Log
me.log('debug', `Feedr === remembering [${feed.url}] from cache`)
// Prepare
let meta = null
let data = null
const readTasks = TaskGroup.create().done(function(err) {
viaCacheComplete(err, data, meta && meta.headers)
})
readTasks.addTask('read the meta data in a cache somewhere', function(
viaCacheTaskComplete
) {
readMetaFile(feed.metaPath, function(err, result) {
if (err || !result) {
viaCacheTaskComplete(err)
return
}
meta = result
viaCacheTaskComplete()
})
})
} else if (typeChecker.isArray(arg)) {
feeds = arg
} else if (typeChecker.isPlainObject(arg)) {
if (index === 0) {
feeds = arg
} else {
extendr.extend(defaultfeed, arg)
}
}
})
// Extract
const results = {}
// Tasks
const tasks = TaskGroup.create({
concurrency: 0,
abortOnError: false
}).done(function() {
let message = 'Feedr finished fetching'
let err = null
if (failures.length !== 0) {
message +=
`with ${failures.length} failures:\n` +
failures
.map(function(i) {
return i.message
})
.join('\n')
err = new Error(message)
me.log('warn', err)