index.js 207 B

1234567
  1. export default function dlv(obj, key, def, p, undef) {
  2. key = key.split ? key.split('.') : key;
  3. for (p = 0; p < key.length; p++) {
  4. obj = obj ? obj[key[p]] : undef;
  5. }
  6. return obj === undef ? def : obj;
  7. }