lib/libs.js
function keyOfMax (o, func) {
                    if(!o || typeof o !== 'object') return o;
                    if(libs.object.size(o) === 0) return;

                    if(!(func instanceof Function)) func = undefined;
                    var max, maxValue, maxKey;

                    if(!func) {
                        max    = libs.object.first(o);
                        maxKey = libs.object.keys(o)[0];
                        libs.object.each(o, 1, function (item, key) {
                            if(item >= max) {
                                max    = item;
                                maxKey = key;
                            }
                        });
                    }
                    else {
                        max      = libs.object.first(o);
                        maxKey   = libs.object.keys(o)[0];
                        maxValue = func.call(max, max);

                        libs.object.each(o, 1, function (item, key) {
                            var value = func.call(item, item);
                            if(value >= maxValue) {
                                if(value >= maxValue) {
                                    max      = item;
                                    maxValue = value;
                                    maxKey   = key;
                                }
                            }
                        });
                    }
                    return maxKey;
                }
function keyOfMax (o, func) {
                    if(!o || typeof o !== 'object') return o;
                    if(libs.object.size(o) === 0) return;

                    if(!(func instanceof Function)) func = undefined;
                    var max, maxValue, maxKey;

                    if(!func) {
                        max    = libs.object.first(o);
                        maxKey = libs.object.keys(o)[0];
                        libs.object.each(o, 1, function (item, key) {
                            if(item >= max) {
                                max    = item;
                                maxKey = key;
                            }
                        });
                    }
                    else {
                        max      = libs.object.first(o);
                        maxKey   = libs.object.keys(o)[0];
                        maxValue = func.call(max, max);

                        libs.object.each(o, 1, function (item, key) {
                            var value = func.call(item, item);
                            if(value >= maxValue) {
                                if(value >= maxValue) {
                                    max      = item;
                                    maxValue = value;
                                    maxKey   = key;
                                }
                            }
                        });
                    }
                    return maxKey;
                }
function keyOfMax ( o , func ) { if ( ! o || typeof o !== 'object' ) return o ; if ( libs . object . size ( o ) === 0 ) return ; if ( ! ( func instanceof Function ) ) func = undefined ; var max , maxValue , maxKey ; if ( ! func ) { max = libs . object . first ( o ) ; maxKey = libs . object . keys ( o ) [ 0 ] ; libs . object . each ( o , 1 , function ( item , key ) { if ( item >= max ) { max = item ; maxKey = key ; } } ) ; } else { max = libs . object . first ( o ) ; maxKey = libs . object . keys ( o ) [ 0 ] ; maxValue = func . call ( max , max ) ; libs . object . each ( o , 1 , function ( item , key ) { var value = func . call ( item , item ) ; if ( value >= maxValue ) { if ( value >= maxValue ) { max = item ; maxValue = value ; maxKey = key ; } } } ) ; } return maxKey ; }
Returns the key of the item with the highest value in the object.
@param {Object} o The object to operate on.
@param {Function=} func If passed, the function will be invoked for each item in the object collection.
@return {*} The maximum item in the object collection.
Returns the key of the item with the highest value in the object .