{
  "version": 3,
  "sources": ["../../src/jsutils/promiseReduce.ts"],
  "sourcesContent": ["import type { PromiseOrValue } from \"./PromiseOrValue\";\n\nimport { isPromise } from \"./isPromise\";\n\n/**\n * Similar to Array.prototype.reduce(), however the reducing callback may return\n * a Promise, in which case reduction will continue after each promise resolves.\n *\n * If the callback does not return a Promise, then this function will also not\n * return a Promise.\n */\nexport function promiseReduce<T, U>(\n  values: Iterable<T>,\n  callbackFn: (accumulator: U, currentValue: T) => PromiseOrValue<U>,\n  initialValue: PromiseOrValue<U>,\n): PromiseOrValue<U> {\n  let accumulator = initialValue;\n  for (const value of values) {\n    accumulator = isPromise(accumulator)\n      ? accumulator.then((resolved) => callbackFn(resolved, value))\n      : callbackFn(accumulator, value);\n  }\n  return accumulator;\n}\n"],
  "mappings": ";AAEA,SAAS,iBAAiB;AASnB,SAAS,cACd,QACA,YACA,cACmB;AACnB,MAAI,cAAc;AAClB,aAAW,SAAS,QAAQ;AAC1B,kBAAc,UAAU,WAAW,IAC/B,YAAY,KAAK,CAAC,aAAa,WAAW,UAAU,KAAK,CAAC,IAC1D,WAAW,aAAa,KAAK;AAAA,EACnC;AACA,SAAO;AACT;",
  "names": []
}
