Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add function maxVal & minVal #193

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Apr 17, 2015

  1. add function maxVal & minVal

    The maxVal function will iterate through each of the properties in an object and select for the property that has the greatest numeric value. If there are no properties with in the object that contain a numeric value the generic result ' ["key",-Infinity] ' is returned. The function minVal operates in the same manner except that it selects for the property with the least numeric value and it's default return value is ' ["key", Infinity] '.
    
    This offers the user much shorter syntax than than ' _.max(obj,function(property){property;}); ' and also provides the key where the max value resides. I also included it's complimentary minVal function as well. 
    
    These functions provide a direct cross-over for ruby users looking for ' hash.max_by{|k,v| v} ' & ' hash.min_by{|k,v| v} '. Since these functions are specific to objects, I thought it would be appropriate to put this in object selectors.
    banned4hax committed Apr 17, 2015
    Configuration menu
    Copy the full SHA
    6f44a8c View commit details
    Browse the repository at this point in the history