diff options
Diffstat (limited to 'node_modules/object-visit/index.js')
-rw-r--r-- | node_modules/object-visit/index.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/node_modules/object-visit/index.js b/node_modules/object-visit/index.js new file mode 100644 index 000000000..50b5800e7 --- /dev/null +++ b/node_modules/object-visit/index.js @@ -0,0 +1,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; +}; |