Skip to main content
Module

x/rambda/mapToObjectAsync.js

Faster and smaller alternative to Ramda
Go to Latest
File
import { mapAsync } from './mapAsync'
export async function mapToObjectAsyncFn(fn, list){ let toReturn = {}
const innerIterable = async x => { const intermediateResult = await fn(x) if (intermediateResult === false) return toReturn = { ...toReturn, ...intermediateResult, } }
await mapAsync(innerIterable, list)
return toReturn}
export function mapToObjectAsync(fn, list){ if (arguments.length === 1){ return async _list => mapToObjectAsyncFn(fn, _list) }
return new Promise((resolve, reject) => { mapToObjectAsyncFn(fn, list).then(resolve) .catch(reject) })}