diff options
Diffstat (limited to 'tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/invokePath.js')
-rw-r--r-- | tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/invokePath.js | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/invokePath.js b/tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/invokePath.js new file mode 100644 index 0000000000..935110fd12 --- /dev/null +++ b/tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/internal/invokePath.js @@ -0,0 +1,26 @@ +var baseGet = require('./baseGet'), + baseSlice = require('./baseSlice'), + isKey = require('./isKey'), + last = require('../array/last'), + toPath = require('./toPath'); + +/** + * Invokes the method at `path` on `object`. + * + * @private + * @param {Object} object The object to query. + * @param {Array|string} path The path of the method to invoke. + * @param {Array} args The arguments to invoke the method with. + * @returns {*} Returns the result of the invoked method. + */ +function invokePath(object, path, args) { + if (object != null && !isKey(path, object)) { + path = toPath(path); + object = path.length == 1 ? object : baseGet(object, baseSlice(path, 0, -1)); + path = last(path); + } + var func = object == null ? object : object[path]; + return func == null ? undefined : func.apply(object, args); +} + +module.exports = invokePath; |