'use strict';varutil=require('util');varvisit=require('object-visit');/** * Map `visit` over an array of objects. * * @param {Object} `collection` The context in which to invoke `method` * @param {String} `method` Name of the method to call on `collection` * @param {Object} `arr` Array of objects. */module.exports=functionmapVisit(collection,method,val){if(isObject(val)){returnvisit.apply(null,arguments);}if(!Array.isArray(val)){thrownewTypeError('expected an array: '+util.inspect(val));}varargs=[].slice.call(arguments,3);for(vari=0;i<val.length;i++){varele=val[i];if(isObject(ele)){visit.apply(null,[collection,method,ele].concat(args));}else{collection[method].apply(collection,[ele].concat(args));}}};functionisObject(val){returnval&&(typeofval==='function'||(!Array.isArray(val)&&typeofval==='object'));}