Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Added sort function to VarnishLog
Browse files Browse the repository at this point in the history
  • Loading branch information
rangoo94 committed Mar 22, 2015
1 parent 235ca88 commit bd7197b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/js/modules/log/varnish.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

/**
* Transform data in row to correct
*
* @param {Object} row
* @returns {Object}
*/
Expand All @@ -30,5 +31,18 @@
return row;
};

/**
* Select specified number of element after sorting by specified function
*
* @param {Function} [sortFunc]
* @param {Number} [limit]
* @returns {Object[]}
*/
VarnishLog.prototype.best = function(sortFunc, limit) {
this.data.sort(sortFunc);

return this.data.slice(0, limit);
};

module.exports = VarnishLog;
}());

0 comments on commit bd7197b

Please sign in to comment.