Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
parseResponse = generateParser.bind(
null,
feed.parse,
plugins[feed.parse].parse
)
}
// Missing
else {
next(new Error('Invalid parse value: ' + feed.parse))
return this
}
}
// Custom
else if (typeChecker.isFunction(feed.parse)) {
parseResponse = generateParser.bind(null, 'custom', feed.parse)
}
// Auto
else if (feed.parse === true) {
parseResponse = function(opts, parseComplete) {
const checkTasks = new TaskGroup().done(parseComplete)
eachr(plugins, function(value, key) {
if (value.parse != null) {
checkTasks.addTask(function(parseTaskComplete) {
generateParser.bind(
null,
key,
value.parse
)(opts, function(err, data) {
if (data) {
module.exports = function (opts, next) {
var config = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
// Empty, set default
if (config.completionCallbackNames == null) {
config.completionCallbackNames = ['next'];
}
// Not array, make array
else if (typeChecker.isArray(config.completionCallbackNames) === false) {
config.completionCallbackNames = [config.completionCallbackNames];
}
// Arguments
if (typeChecker.isFunction(opts) && next == null) {
next = opts;
opts = {};
} else if (!opts) {
opts = {};
}
// Completion callback
if (!next) {
// Cycle the completionCallbackNames to check if the completion callback name exists in opts
// if it does, then use it as the next and delete it's value
eachr(config.completionCallbackNames, function (completionCallbackName) {
if (typeof opts[completionCallbackName] !== 'undefined') {
next = opts[completionCallbackName];
delete opts[completionCallbackName];
return false; // break
// ^ why this only does the first, and not all, using the last, I don't know ...
else {
parseResponse = function(opts, parseComplete) {
parseComplete()
}
}
// ------------------------------
// Checker
let checkResponse = null
// Specific
if (typeChecker.isString(feed.check)) {
// Exists
if (
typeChecker.isFunction(plugins[feed.check] && plugins[feed.check].check)
) {
checkResponse = generateChecker.bind(
null,
feed.check,
plugins[feed.check].check
)
}
// Missing
else {
next(new Error('Invalid check value: ' + feed.check))
return this
}
}
// Custom
`Feedr check [${feed.url}] with ${name} attempt, success`
)
complete(null, data)
})
}
// ------------------------------
// Parser
let parseResponse = null
// Specific
if (typeChecker.isString(feed.parse)) {
// Exists
if (
typeChecker.isFunction(plugins[feed.parse] && plugins[feed.parse].parse)
) {
parseResponse = generateParser.bind(
null,
feed.parse,
plugins[feed.parse].parse
)
}
// Missing
else {
next(new Error('Invalid parse value: ' + feed.parse))
return this
}
}
// Custom
module.exports = function (opts, next, config = {}) {
// Empty, set default
if ( config.completionCallbackNames == null ) {
config.completionCallbackNames = ['next']
}
// Not array, make array
else if ( typeChecker.isArray(config.completionCallbackNames) === false ) {
config.completionCallbackNames = [config.completionCallbackNames]
}
// Arguments
if ( typeChecker.isFunction(opts) && next == null ) {
next = opts
opts = {}
}
else if ( !opts ) {
opts = {}
}
// Completion callback
if ( !next ) {
// Cycle the completionCallbackNames to check if the completion callback name exists in opts
// if it does, then use it as the next and delete it's value
eachr(config.completionCallbackNames, function (completionCallbackName) {
if ( typeof opts[completionCallbackName] !== 'undefined' ) {
next = opts[completionCallbackName]
delete opts[completionCallbackName]
return false // break
checkResponse = generateChecker.bind(
null,
feed.check,
plugins[feed.check].check
)
}
// Missing
else {
next(new Error('Invalid check value: ' + feed.check))
return this
}
}
// Custom
else if (typeChecker.isFunction(feed.check)) {
checkResponse = generateChecker.bind(null, 'custom', feed.check)
}
// Auto
else if (feed.check) {
checkResponse = function(opts, checkComplete) {
const checkTasks = new TaskGroup().done(checkComplete)
eachr(plugins, function(value, key) {
if (value.check != null) {
checkTasks.addTask(function(checkTaskComplete) {
generateChecker.bind(
null,
key,
value.check
)(opts, checkTaskComplete)
})
args.forEach(function(arg) {
if (typeChecker.isString(arg)) {
url = arg
} else if (typeChecker.isFunction(arg)) {
next = arg
} else if (typeChecker.isPlainObject(arg)) {
feed = arg
}
})