{"version":3,"sources":["iterable/reduce.ts"],"names":[],"mappings":"AAUA,MAAM,UAAU,MAAM,CACpB,MAAmB,EACnB,WAA2E,EAC3E,GAAG,IAAS;IAEZ,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,KAAK,CAAC,CAAC;IAClC,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,GAAG,GAAG,IAAI,CAAC,CAAC,CAAU,CAAC;IAC3B,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE;QACzB,IAAI,QAAQ,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,EAAE;YACpC,GAAG,GAAG,WAAW,CAAI,GAAG,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;SACtC;aAAM;YACL,GAAG,GAAG,IAAI,CAAC;YACX,QAAQ,GAAG,IAAI,CAAC;YAChB,CAAC,EAAE,CAAC;SACL;KACF;IAED,IAAI,CAAC,CAAC,OAAO,IAAI,QAAQ,CAAC,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;KAClD;IAED,OAAO,GAAQ,CAAC;AAClB,CAAC","file":"reduce.js","sourcesContent":["export function reduce<T, R = T>(\n  source: Iterable<T>,\n  accumulator: (previousValue: R, currentValue: T, currentIndex: number) => R,\n  seed?: never[]\n): R;\nexport function reduce<T, R = T>(\n  source: Iterable<T>,\n  accumulator: (previousValue: R, currentValue: T, currentIndex: number) => R,\n  seed?: R\n): R;\nexport function reduce<T, R = T>(\n  source: Iterable<T>,\n  accumulator: (previousValue: R, currentValue: T, currentIndex: number) => R,\n  ...seed: R[]\n): R {\n  const hasSeed = seed.length === 1;\n  let i = 0;\n  let hasValue = false;\n  let acc = seed[0] as T | R;\n  for (const item of source) {\n    if (hasValue || (hasValue = hasSeed)) {\n      acc = accumulator(<R>acc, item, i++);\n    } else {\n      acc = item;\n      hasValue = true;\n      i++;\n    }\n  }\n\n  if (!(hasSeed || hasValue)) {\n    throw new Error('Sequence contains no elements');\n  }\n\n  return acc as R;\n}\n"]}