Given an array which contains objects of type A and B, where B can be transformed to a set of A type objects, via an asynchronous call, which would be the best way of transforming the array into an all A objects array (transforming each B object in a set of corresponding A objects) and execute a callback when Bs are transformed?
list = [A, B, A, B, A, A, B, A];
function transform (B, callback) {
//transform B type object into A type objects array [A, A, A].....
callback([A, A, A]);
}
transformBObjectsIntoAObjects(list, callback) {
// ?????????
callback(list); // this should only be A type objects
}