metasync icon indicating copy to clipboard operation
metasync copied to clipboard

Make metasync.map compatible with Array.map

Open tshemsedinov opened this issue 6 years ago • 2 comments

Compare

Array.prototype.map((value, index, array) => (result) [, thisArg]) : Array

and current implementation:

metasync.map(array, (value, callback) => callback(result) [, thisArg]);

we may change to:

metasync.map(array, (value, [index], [array], callback) => callback(result));

tshemsedinov avatar Apr 05 '18 17:04 tshemsedinov

@tshemsedinov current implementation of metasync.map has such contract:

metasync.map(array, (value, callback) => callback(err, result), done);

As I understand we should change it to:

metasync.map(array,  (value, [index[, array]], callback) => callback(err, result), done);

Or we may also add optional thisArg to contract, so this will look like this:

metasync.map(array,  (value, [index[, array]], callback) => callback(err, result) [, thisArg],  done);

o-rumiantsev avatar Oct 08 '18 07:10 o-rumiantsev

@tshemsedinov I'd prefer to leave it as it is, but we should use Iterators instead of Arrays, so that any Iterable object may be passed to metasync.map and other functions (#313). On the other hand, we can create metasync.Iterator for such use-cases. WDYT?

nechaido avatar Oct 08 '18 10:10 nechaido