Download code/validation/JavaScript/0074070_rank.js from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/code/validation/JavaScript/0074070_rank.js
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/code/validation/JavaScript/0074070_rank.js
-
curl -L -o 0074070_rank.js https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/code/validation/JavaScript/0074070_rank.js
1.17 kB
| /** | |
| * Internal dependencies. | |
| */ | |
| var Formatter = require('../formatter'); | |
| /** | |
| * Rank formatter. | |
| * | |
| * @constructor | |
| */ | |
| var Rank = Formatter.extend(); | |
| /** | |
| * Run the formatter. | |
| * | |
| * @api public | |
| */ | |
| Rank.prototype.run = function() { | |
| var rows = []; | |
| var longestScore = 0; | |
| var longestSignature = 0; | |
| this.sources.forEach(function(source) { | |
| source.eachContext(function(context) { | |
| var score = context.score(); | |
| var signature = context.signature(); | |
| if (score < this.options.min) return; | |
| score = this.toFixed(score); | |
| longestSignature = Math.max(signature.length, longestSignature); | |
| longestScore = Math.max(score.length, longestScore); | |
| rows.push([score, signature, source.path + ':' + context.location()]); | |
| }, this); | |
| }, this); | |
| rows.sort(function(a, b) { | |
| var first = +a[0]; | |
| var second = +b[0]; | |
| if (first > second) return -1; | |
| if (first < second) return 1; | |
| return 0; | |
| }).forEach(function(row) { | |
| this.print( | |
| this.ljust(row[0], longestScore) + ' ' + | |
| this.ljust(row[1], longestSignature) + ' ' + | |
| row[2]); | |
| }, this); | |
| }; | |
| /** | |
| * Primary export. | |
| */ | |
| module.exports = Rank; | |