| var restArguments = require('./restArguments.js'); | |
| var isFunction = require('./isFunction.js'); | |
| var map = require('./map.js'); | |
| var _deepGet = require('./_deepGet.js'); | |
| var _toPath = require('./_toPath.js'); | |
| // Invoke a method (with arguments) on every item in a collection. | |
| var invoke = restArguments(function(obj, path, args) { | |
| var contextPath, func; | |
| if (isFunction(path)) { | |
| func = path; | |
| } else { | |
| path = _toPath(path); | |
| contextPath = path.slice(0, -1); | |
| path = path[path.length - 1]; | |
| } | |
| return map(obj, function(context) { | |
| var method = func; | |
| if (!method) { | |
| if (contextPath && contextPath.length) { | |
| context = _deepGet(context, contextPath); | |
| } | |
| if (context == null) return void 0; | |
| method = context[path]; | |
| } | |
| return method == null ? method : method.apply(context, args); | |
| }); | |
| }); | |
| module.exports = invoke; | |
Xet Storage Details
- Size:
- 875 Bytes
- Xet hash:
- 3784f070b42b2df01c99fcafd8fc5faba0709bb690dc999f3f495c97a2f3c062
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.