property.js 360 B

123456789101112
  1. import deepGet from './_deepGet.js';
  2. import toPath from './_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. export default function property(path) {
  6. path = toPath(path);
  7. return function(obj) {
  8. return deepGet(obj, path);
  9. };
  10. }