You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 9, 2022. It is now read-only.
I just switched https://github.com/mozilla/fathom from lodash to wu because lodash isn't very interested in supporting ES6 iterables. However, that meant I had to bring my own max() and sum() functions. Would you consider a PR for them in wu? I wrote them so they're polymorphic, able to be used on numbers, strings, or whatever supports the > operator, without any undue casting influence from a static initializer.
// Return the maximum item from an iterable, as defined by >.//// Works with any type that works with >. If multiple items are equally great,// return the first.//// by: a function that, given an item of the iterable, returns a value to// comparefunctionmax(iterable,by=identity){letmaxSoFar,maxKeySoFar;letisFirst=true;forEach(function(item){constkey=by(item);if(key>maxKeySoFar||isFirst){maxSoFar=item;maxKeySoFar=key;isFirst=false;}},iterable);returnmaxSoFar;}functionidentity(x){returnx;}
// Return the sum of an iterable, as defined by the + operator.functionsum(iterable){lettotal;letisFirst=true;forEach(functionassignOrAdd(addend){if(isFirst){total=addend;isFirst=false;}else{total+=addend;}},iterable);returntotal;}
Thanks for considering, and thanks for filling a big hole with wu!
I just switched https://github.com/mozilla/fathom from lodash to wu because lodash isn't very interested in supporting ES6 iterables. However, that meant I had to bring my own max() and sum() functions. Would you consider a PR for them in wu? I wrote them so they're polymorphic, able to be used on numbers, strings, or whatever supports the
>operator, without any undue casting influence from a static initializer.Thanks for considering, and thanks for filling a big hole with wu!