jsshort
Version:
It will make your codes much short and easiar
64 lines (63 loc) • 1.93 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.print = exports.input = exports.end = void 0;
const readline_1 = __importDefault(require("readline"));
exports.end = "\n";
global.end = '\n';
const rl = readline_1.default.createInterface({
input: process.stdin,
output: process.stdout,
});
const input = async (question = "") => {
return new Promise((resolve) => {
rl.question(question, (input) => {
resolve(input.trim());
});
});
};
exports.input = input;
// export const print = (...args: any[]) => {
// // Join the arguments with spaces and add the specified ending character
// let output: any;
// // Check if the last argument is an object and extract 'sep'
// const lastArg = args[args.length - 1];
// if (typeof lastArg === "object" || lastArg === "" || lastArg === " ") {
// args.pop();
// }
// if (typeof lastArg === "object") {
// if (lastArg.hasOwnProperty("sep")) {
// let sep = lastArg.sep;
// output = args.join(sep)
// }
// if (lastArg.end != null) {
// if (!output)
// output = args.join(" ") + lastArg.end;
// else
// output += lastArg.end;
// }
// } else if (lastArg == "" || lastArg == " ") {
// output = args.join(' ') + (global as any).end;
// }
// else {
// output = args.join(' ') + (global as any).end;
// }
// if (lastArg && lastArg.file) {
// fs.writeFile(lastArg.file, output, (err: any) => {
// if (err) {
// console.error(err);
// }
// });
// } else {
// process.stdout.write(output);
// }
// (global as any).end = "\n"
// }
let print = (params) => {
return params;
};
exports.print = print;
global.print = exports.print;
global.input = exports.input;
;