UNPKG

tatau

Version:
83 lines (82 loc) 2.85 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getPrefix = getPrefix; exports.toReo = toReo; exports.multiplier = multiplier; const constants_1 = require("../constants"); function getPrefix(input, options) { if (!options.ordinalOutput || input < 1) { return ''; } else if (input < 10) { return 'tua'; } else { return 'te '; } } function toReo(input) { // Stryker disable next-line EqualityOperator: The <= mutant results in an equivalent mutant if (input > 0) { input = Math.floor(input); } else { input = Math.ceil(input); } return toReoRaw(input).trim(); } function toReoRaw(input) { // Stryker disable ConditionalExpression: if (false) or if(true) mutants in this section result in circular loop timeouts // Stryker disable next-line EqualityOperator,ArithmeticOperator: /-1 is equivalent, < is equivalent if (input >= constants_1.minInvalidInput || input <= constants_1.minInvalidInput * -1) { return input.toString(); } if (input < 0) { // Stryker disable next-line UnaryOperator: +input results in circular loop timeout return `kore ${toReo(-input)}`; } // Stryker disable EqualityOperator,BlockStatement: circular loop timeouts if (input < 10) { return constants_1.ones[input]; } if (input < 100) { return converter(input, 10); } if (input < 1000) { return converter(input, 100); } if (input < 1000000) { return converter(input, 1000); } if (input < 1000000000) { return converter(input, 1000000); } // Stryker disable next-line EqualityOperator: The <= mutant results in an equivalent mutant if (input < 1000000000000) { return converter(input, 1000000000); } /* c8 ignore next 3 : lines are unreachable*/ return input.toString(); // Stryker restore ConditionalExpression,EqualityOperator,BlockStatement } function multiplier(input, excludeOne = false) { if (excludeOne) { return input === 1 ? '' : toReo(input); } else { return input === 1 ? 'kotahi' : toReo(input); } } function converter(input, denominator) { const quotient = Math.floor(input / denominator); // Stryker disable next-line ArithmeticOperator: Results in circular loop timeout const remainder = input % denominator; const excludeOne = denominator === 10; if (remainder === 0) { return `${multiplier(quotient, excludeOne)} ${constants_1.numbers[denominator]}`; } if (remainder < 10) { return `${multiplier(quotient, excludeOne)} ${constants_1.numbers[denominator]}${toReo(remainder)}`; } return `${multiplier(quotient, excludeOne)} ${constants_1.numbers[denominator]} e ${toReo(remainder)}`; }