2 * object-visit <https://github.com/jonschlinkert/object-visit>
4 * Copyright (c) 2015, 2017, Jon Schlinkert.
5 * Released under the MIT License.
10 var isObject = require('isobject');
12 module.exports = function visit(thisArg, method, target, val) {
13 if (!isObject(thisArg) && typeof thisArg !== 'function') {
14 throw new Error('object-visit expects `thisArg` to be an object.');
17 if (typeof method !== 'string') {
18 throw new Error('object-visit expects `method` name to be a string');
21 if (typeof thisArg[method] !== 'function') {
25 var args = [].slice.call(arguments, 3);
26 target = target || {};
28 for (var key in target) {
29 var arr = [key, target[key]].concat(args);
30 thisArg[method].apply(thisArg, arr);