Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
module.exports = function mapVisit(collection, method, val) {
if (isObject(val)) {
return visit.apply(null, arguments);
}
if (!Array.isArray(val)) {
throw new TypeError('expected an array: ' + util.inspect(val));
}
var args = [].slice.call(arguments, 3);
for (var i = 0; i < val.length; i++) {
var ele = val[i];
if (isObject(ele)) {
visit.apply(null, [collection, method, ele].concat(args));
} else {
collection[method].apply(collection, [ele].concat(args));
}
}
module.exports = function mapVisit(collection, method, val) {
if (isObject(val)) {
return visit.apply(null, arguments);
}
if (!Array.isArray(val)) {
throw new TypeError('expected an array: ' + util.inspect(val));
}
var args = [].slice.call(arguments, 3);
for (var i = 0; i < val.length; i++) {
var ele = val[i];
if (isObject(ele)) {
visit.apply(null, [collection, method, ele].concat(args));
} else {
collection[method].apply(collection, [ele].concat(args));
}
}
};
module.exports = function(collection, method, val) {
var result;
if (typeof val === 'string' && (method in collection)) {
var args = [].slice.call(arguments, 2);
result = collection[method].apply(collection, args);
} else if (Array.isArray(val)) {
result = mapVisit.apply(null, arguments);
} else {
result = visit.apply(null, arguments);
}
if (typeof result !== 'undefined') {
return result;
}
return collection;
};
module.exports = function(collection, method, val) {
var result;
if (typeof val === 'string' && (method in collection)) {
var args = [].slice.call(arguments, 2);
result = collection[method].apply(collection, args);
} else if (Array.isArray(val)) {
result = mapVisit.apply(null, arguments);
} else {
result = visit.apply(null, arguments);
}
if (typeof result !== 'undefined') {
return result;
}
return collection;
};