3 ms·
> ‘matchAll’ looks great but why make it an iterator vs a ‘map’ style callback? Because that makes it significantly easier to e.g. optionally collect into an a
by masklinn 8y ago
> ‘matchAll’ looks great but why make it an iterator vs a ‘map’ style callback?
Because that makes it significantly easier to e.g. optionally collect into an array, or to only partially iterate the sequence (e.g. only get the first 3 matches) which is painful to impossible using JS's callbacks. An iterator is simply more flexible.