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

property.js 479B

12345678910111213141516
  1. var isArray = require('./isArray.js');
  2. var _shallowProperty = require('./_shallowProperty.js');
  3. var _deepGet = require('./_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. function property(path) {
  7. if (!isArray(path)) {
  8. return _shallowProperty(path);
  9. }
  10. return function(obj) {
  11. return _deepGet(obj, path);
  12. };
  13. }
  14. module.exports = property;