getProp.js 443 B

123456789101112131415161718192021222324
  1. "use strict";
  2. exports.__esModule = true;
  3. exports["default"] = getProp;
  4. function getProp(obj) {
  5. for (var _len = arguments.length, props = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  6. props[_key - 1] = arguments[_key];
  7. }
  8. while (props.length > 0) {
  9. var prop = props.shift();
  10. if (!obj[prop]) {
  11. return undefined;
  12. }
  13. obj = obj[prop];
  14. }
  15. return obj;
  16. }
  17. module.exports = exports.default;