function get(name, varsArr) {
  if (!Array.isArray(varsArr)) {
    throw new Error('You should pass vars array to vars.get()');
  }

  const rootVar = name.match(/[^.[]*/)[0];
  const isSimpleVar = rootVar === name;

  // todo: use for.. of after https://github.com/facebook/react-native/issues/4676
  for (let i = 0; i < varsArr.length; i++) {
    let vars = varsArr[i];
    if (!vars || vars[rootVar] === undefined) {
      continue;
    }
    if (isSimpleVar) {
      return vars[name];
    }
    try {
      return resolvePath({[rootVar]: vars[rootVar]}, name);
    } catch (error) {
      return undefined;
    }
  }
}
Return variable value using provided array of variable sets
@param {String} name variable with $, e.g. '$myVar'
@param {Array} varsArr array of variable sets