{"version":3,"file":"merge.cjs","sources":["../../../../src/utils/async/merge.js"],"sourcesContent":["import { toIterable } from '../types';\n\n/**\n * Merges objects obtained from an iterable of promises sequentially. Each promise is expected to resolve to an object.\n * The properties are merged into an accumulated object, with later ones overwriting earlier duplicates if keys conflict.\n *\n * @template T\n * @param {Iterable<Promise<Object<string, T>>>} objectPromises - An iterable of promises where each promise resolves to an object.\n * @returns {Promise<Object<string, T>>} The accumulated merged object containing properties from all resolved objects. If duplicate keys exist,\n *                    later values overwrite earlier ones.\n * @throws {Error} If any promise does not resolve to an object or rejects, this function will throw an error.\n */\nexport const mergeAwait = async (objectPromises) => {\n  const res = {};\n\n  for await (const obj of toIterable(objectPromises)) {\n    Object.assign(res, obj);\n  }\n\n  return res;\n};\n"],"names":["toIterable"],"mappings":";;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACY,MAAC,UAAU,GAAG,OAAO,cAAc,KAAK;AACpD,EAAE,MAAM,GAAG,GAAG,EAAE;;AAEhB,EAAE,WAAW,MAAM,GAAG,IAAIA,gBAAU,CAAC,cAAc,CAAC,EAAE;AACtD,IAAI,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC;AAC3B,EAAE;;AAEF,EAAE,OAAO,GAAG;AACZ;;;;"}