property.js 383 B

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