1 Star 0 Fork 0

UnPourTous/lodash

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
method.js 717 Bytes
一键复制 编辑 原始数据 按行查看 历史
Roman Gusev 提交于 2017-03-31 00:42 +08:00 . Remove constant function from examples (#3086)
import invoke from './invoke.js'
/**
* Creates a function that invokes the method at `path` of a given object.
* Any additional arguments are provided to the invoked method.
*
* @since 3.7.0
* @category Util
* @param {Array|string} path The path of the method to invoke.
* @param {Array} [args] The arguments to invoke the method with.
* @returns {Function} Returns the new invoker function.
* @example
*
* const objects = [
* { 'a': { 'b': () => 2 } },
* { 'a': { 'b': () => 1 } }
* ]
*
* map(objects, method('a.b'))
* // => [2, 1]
*
* map(objects, method(['a', 'b']))
* // => [2, 1]
*/
function method(path, args) {
return (object) => invoke(object, path, args)
}
export default method
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/UnPourTous/lodash.git
git@gitee.com:UnPourTous/lodash.git
UnPourTous
lodash
lodash
master

搜索帮助