Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
internal func map_parallel<A, B, S: Sequence>(context: Context, items: S, transform: @escaping (A) throws -> Promise<B>) -> Promise<[B]> where S.Iterator.Element == A {
let transformPromise = Promise<Void>(resolved: ())
return transformPromise.then(in: context) { (Void) -> Promise<[B]> in
do {
let mappedPromises: [Promise<B>] = try{ item in
return try transform(item)
return all(mappedPromises)
} catch let error {
return Promise<[B]>(rejected: error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.