property.js 383 B

123456789101112131415
  1. define(['./_deepGet', './_toPath'], function (_deepGet, _toPath) {
  2. // Creates a function that, when passed an object, will traverse that object’s
  3. // properties down the given `path`, specified as an array of keys or indices.
  4. function property(path) {
  5. path = _toPath(path);
  6. return function(obj) {
  7. return _deepGet(obj, path);
  8. };
  9. }
  10. return property;
  11. });