"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});

function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }

/**
 * Created by baoyinghai on 10/26/16.
 */
/* eslint-disable */
var getValueByKeyNoDef = exports.getValueByKeyNoDef = function getValueByKeyNoDef(entry, def) {
  for (var _len = arguments.length, keys = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
    keys[_key - 2] = arguments[_key];
  }

  if (keys && keys.length === 0) {
    return entry;
  }
  return entry && getValueByKey.apply(undefined, [entry[keys[0]], def].concat(_toConsumableArray(keys.slice(1))));
};

var getValueByKey = exports.getValueByKey = function getValueByKey(entry, def) {
  for (var _len2 = arguments.length, keys = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
    keys[_key2 - 2] = arguments[_key2];
  }

  var tag = getValueByKeyNoDef.apply(undefined, [entry, def].concat(keys));
  if (tag === undefined || tag === null) {
    return def;
  }
  return tag;
};