UNPKG

ngx-monitorias-uniandes-lib

Version:

This library is used for Monitorias-Uniandes system.

51 lines 2.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var AlphanumericToSectionPipe = /** @class */ (function () { function AlphanumericToSectionPipe() { this.letters = [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' ]; this.numbers = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 ]; } AlphanumericToSectionPipe.prototype.transform = function (alphanumeric) { var firstCharacter = alphanumeric.charAt(0); if (this.letters.some(function (letter) { return letter === firstCharacter; })) { return this.getSectionNumber(firstCharacter, alphanumeric); } else { return parseInt(alphanumeric); } }; AlphanumericToSectionPipe.prototype.getSectionNumber = function (letter, alphanumeric) { var indexWhereIsLetter = this.letters.indexOf(letter); var lastDigit = alphanumeric.charAt(alphanumeric.length - 1); var secondLastDigit = alphanumeric.charAt(alphanumeric.length - 2); var firstNumber = this.numbers[indexWhereIsLetter]; if (alphanumeric.length === 1) { var numberInString = firstNumber + "000"; return parseInt(numberInString); } else if (alphanumeric.length === 2) { var numberInString = firstNumber + "00" + lastDigit; return parseInt(numberInString); } else { var numberInString = firstNumber + "0" + secondLastDigit + lastDigit; return parseInt(numberInString); } }; AlphanumericToSectionPipe.decorators = [ { type: core_1.Pipe, args: [{ name: 'alphanumericToSection' },] }, ]; return AlphanumericToSectionPipe; }()); exports.AlphanumericToSectionPipe = AlphanumericToSectionPipe; //# sourceMappingURL=alphanumericToSection.pipe.js.map