Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

property.js 453B

1234567891011121314
  1. import isArray from './isArray.js';
  2. import shallowProperty from './_shallowProperty.js';
  3. import deepGet from './_deepGet.js';
  4. // Creates a function that, when passed an object, will traverse that object’s
  5. // properties down the given `path`, specified as an array of keys or indices.
  6. export default function property(path) {
  7. if (!isArray(path)) {
  8. return shallowProperty(path);
  9. }
  10. return function(obj) {
  11. return deepGet(obj, path);
  12. };
  13. }