UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

20 lines 644 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.nth = nth; const assert_1 = require("./assert"); function nth(n) { (0, assert_1.guard)(isFinite(n) && n >= 1, 'n must be a non-negative number'); const num = String(n); const lastDigit = num[num.length - 1]; switch (lastDigit) { case '1': return n > 0 && n < 20 ? `${n}th` : `${n}st`; case '2': return n > 0 && n < 20 ? `${n}th` : `${n}nd`; case '3': return n > 0 && n < 20 ? `${n}th` : `${n}rd`; default: return `${n}th`; } } //# sourceMappingURL=text.js.map