@khatastroffik/one-ts-for-all
Version:
A PoC demonstrating a Typescript 'library' project with multiple targets (CJS, EMS, CLI...)
41 lines (37 loc) • 1.25 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.main = void 0;
const tslib_1 = require("tslib");
const library_1 = require("./lib/library");
const chalk_1 = tslib_1.__importDefault(require("chalk"));
const cliinfo = chalk_1.default.yellow(`
--------------------------------------------------
INFORMATION:
------------
CLI of the PoC "one-ts-for-all"
please visit
https://github.com/khatastroffik/one-ts-for-all
for more info.
`) + chalk_1.default.blueBright(`--------------------------------------------------
APPLICATION OUTPUT:
-------------------
`);
function randomSpeed(c) {
return Math.floor(Math.random() * c.getStatus().maxSpeed);
}
function main() {
console.log(cliinfo);
const cars = [];
cars.push(new library_1.Car('Trabi', 95));
cars.push(new library_1.Car('2 CV', 75));
cars.push(new library_1.Car('Veron', 375));
cars.forEach((c) => c.startEngine());
cars.forEach((c) => c.accelerate(randomSpeed(c)));
cars.forEach((c) => {
let info = c.getStatus();
console.log(chalk_1.default.blueBright(`Car "${info.name}" is driving at speed: ${info.speed}.`));
});
}
exports.main = main;
main();