"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.mergeDeepOnlyMaps = exports.compact = exports.keyBy = void 0;

var _immutable = require("immutable");

var keyBy = function keyBy(immutableList, keyAttr) {
  return immutableList.reduce(function (keyedMap, i) {
    return keyedMap.set(i.get(keyAttr), i);
  }, (0, _immutable.Map)());
}; // Remove any undefined values


exports.keyBy = keyBy;

var compact = function compact(immutableList) {
  return immutableList.filter(function (i) {
    return !!i;
  });
}; // Deep merge Maps, but not Lists or other Collections


exports.compact = compact;

var mergeDeepOnlyMaps = function mergeDeepOnlyMaps(oldVal, newVal, key) {
  if (_immutable.Map.isMap(oldVal) && _immutable.Map.isMap(newVal)) {
    return oldVal.mergeWith(mergeDeepOnlyMaps, newVal);
  }

  return newVal;
};

exports.mergeDeepOnlyMaps = mergeDeepOnlyMaps;