UNPKG

@appworks/doctor

Version:

Analyse and running codemods over react/rax projects, troubleshooting and automatically fixing errors

48 lines (47 loc) 1.6 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var Scanner = /** @class */ (function () { function Scanner(options) { if (options === void 0) { options = {}; } this.highestScore = options.highestScore || 100; this.lowestScore = options.lowestScore || 10; this.digits = options.digits || 2; this.currentScore = options.start || this.highestScore; } Scanner.prototype.plus = function (score) { this.currentScore += score; return this.getScore(); }; Scanner.prototype.minus = function (score) { this.currentScore -= score; return this.getScore(); }; Scanner.prototype.getAverage = function (list) { if (list.length) { var sum_1 = 0; if (list.length > 3) { // Calculate average without max and min list.sort(function (a, b) { return a - b; }); list.pop(); list.shift(); } list.forEach(function (num) { sum_1 += num; }); this.currentScore = sum_1 / list.length; } return this.getScore(); }; Scanner.prototype.getScore = function () { if (this.currentScore > this.highestScore) { return this.highestScore; } else if (this.currentScore < this.lowestScore) { return this.lowestScore; } // Avoid NaN return Number((this.currentScore || 0).toFixed(this.digits)); }; return Scanner; }()); exports.default = Scanner;