entriesToObject function

dynamic entriesToObject(
  1. dynamic entries
)

Implementation

entriesToObject(entries) {
  var o = {};
  for (var i = 0; i < entries.length; i += 1) {
    var key = entries[i][0];
    var values = entries[i][1];
    var value;
    if (values.length == 1) {
      value = values[0];
    } else {
      value = values;
    }

    if (o.keys.toList().indexOf(key) >= 0 && o[key] != null) {
      throw ('Object ${o} already has key ' + key);
    }

    o[key] = value;
  }

  return o;
}