2023.01.24-4
This commit is contained in:
parent
9726841065
commit
88cd6ab7db
3 changed files with 18 additions and 23 deletions
|
@ -1,8 +1,8 @@
|
|||
Work IN PROGRESS
|
||||
|
||||
```js
|
||||
require('@thundernetworkrad/std').cin('Question')
|
||||
.then((response) => {
|
||||
const { cin } = require('@thundernetworkrad/std');
|
||||
cin('Question').then((response) => {
|
||||
console.log(response)
|
||||
})
|
||||
```
|
||||
|
@ -10,7 +10,7 @@ require('@thundernetworkrad/std').cin('Question')
|
|||
```js
|
||||
const { createCout } = require('@thundernetworkrad/std');
|
||||
|
||||
let ccout = new createCout(0); // debugLevel
|
||||
let ccout = new createCout(0, true); // debugLevel, logs enabled (file)
|
||||
|
||||
let cout = ccout.cout;
|
||||
|
||||
|
|
31
index.js
31
index.js
|
@ -1,7 +1,10 @@
|
|||
const { writeFile, readFile, mkdir } = require('node:fs/promises');
|
||||
const { stdin, stdout } = require('node:process');
|
||||
const { appendFile, existsSync } = require('node:fs');
|
||||
const { mkdir } = require('node:fs/promises')
|
||||
var readlineSync = require('readline-sync');
|
||||
var name, debug, logs1;
|
||||
var debug, logs1;
|
||||
|
||||
let time = getTime()
|
||||
const name = `${time.year}.${time.month}.${time.day}.${time.hours}.${time.minutes}.${time.seconds}.log`;
|
||||
|
||||
function getTime () {
|
||||
const date_time = new Date();
|
||||
|
@ -14,20 +17,12 @@ function getTime () {
|
|||
return({year, month, day, hours, minutes, seconds})
|
||||
};
|
||||
|
||||
function createLog () {
|
||||
mkdir('./logs', { recursive: true });
|
||||
var time = getTime();
|
||||
name = `${time.year}.${time.month}.${time.day}.${time.hours}.${time.minutes}.${time.seconds}.log`;
|
||||
writeFile(`./logs/${name}`, '');
|
||||
return(name)
|
||||
};
|
||||
|
||||
function log (string) {
|
||||
readFile(`./logs/${name}`, 'utf8')
|
||||
.then(async (err, data) => {
|
||||
if (!data) data = '';
|
||||
data += string + '\n';
|
||||
writeFile(`./logs/${name}`, data);
|
||||
if (!existsSync('./logs')) mkdir('./logs', { recursive: true });
|
||||
appendFile(`./logs/${name}`, string+'\n', err => {
|
||||
if (err) {
|
||||
throw err
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
|
@ -60,11 +55,11 @@ class createCout {
|
|||
if (debug >= debugLevel) {
|
||||
console.log(`[${time.year}.${time.month}.${time.day}-${time.hours}:${time.minutes}:${time.seconds}] | ${String(string)}`);
|
||||
if (logs1) {
|
||||
log(string);
|
||||
log(`[${time.year}.${time.month}.${time.day}-${time.hours}:${time.minutes}:${time.seconds}] | ${String(string)}`);
|
||||
}
|
||||
}
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = { cin, createCout, createLog, log };
|
||||
module.exports = { cin, createCout, log };
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@thundernetworkrad/std",
|
||||
"version": "2023.01.24-3",
|
||||
"version": "2023.01.24-4",
|
||||
"description": "Standard module for javascript",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
@ -25,6 +25,6 @@
|
|||
},
|
||||
"homepage": "https://github.com/FIUSDevelopment/std#readme",
|
||||
"dependencies": {
|
||||
"readline-sync": "^1.4.10"
|
||||
"@thundernetworkrad/readline-sync": "^2023.1.10"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue