Skip to main content

Fake Async

"Fake" Async

Currently, AutoMapper is manipulating the Event Loop to provide a "fake" async support for the mapAsync() and mutateAsync() variants.

//                  👇 simplified for brevity
function mapAsync(...args) {
const result = map(...args);
return new Promise((res) => {
setTimeout(res, 0, result);

// 👇 simplified for brevity
function mutateAsync(...args) {
return new Promise((res) => {

Help wanted

Real async support can be achieved by some Isomorphic Worker that would execute the map operations on the Worker thread. However, AutoMapper implementation is full of Function which cannot be serialized (easily) to transfer to the Worker thread. If anyone wants to contribute Asynchronous support, I'm happy to walk you through the repository.