blob: 50b5800e752aee38e9dd2d8b36085accc469430d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
/*!
* object-visit <https://github.com/jonschlinkert/object-visit>
*
* Copyright (c) 2015, Jon Schlinkert.
* Licensed under the MIT License.
*/
'use strict';
var isObject = require('isobject');
module.exports = function visit(thisArg, method, target) {
if (!isObject(thisArg) && typeof thisArg !== 'function') {
throw new Error('object-visit expects `thisArg` to be an object.');
}
if (typeof method !== 'string') {
throw new Error('object-visit expects `method` name to be a string');
}
if (typeof thisArg[method] !== 'function') {
return thisArg;
}
target = target || {};
for (var key in target) {
thisArg[method](key, target[key]);
}
return thisArg;
};
|