'use strict';

/*!
 * @techmely/utils
 * Copyright(c) 2021-2024 Techmely <techmely.creation@gmail.com>
 * MIT Licensed
 */


// src/normalizeArray.ts
function normalize(array, key) {
  if (!array || array.length === 0)
    return {};
  return array.reduce(
    (acc, cur) => {
      const keyValue = cur[key];
      if (keyValue) {
        return Object.assign(acc, { [keyValue]: cur });
      }
      return acc;
    },
    {}
  );
}

exports.normalize = normalize;
