2023.01.24-4

This commit is contained in:
Killer Boss Original 2023-01-24 22:50:10 +01:00 committed by GitHub
parent 9726841065
commit 88cd6ab7db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 23 deletions

View file

@ -1,8 +1,8 @@
Work IN PROGRESS Work IN PROGRESS
```js ```js
require('@thundernetworkrad/std').cin('Question') const { cin } = require('@thundernetworkrad/std');
.then((response) => { cin('Question').then((response) => {
console.log(response) console.log(response)
}) })
``` ```
@ -10,7 +10,7 @@ require('@thundernetworkrad/std').cin('Question')
```js ```js
const { createCout } = require('@thundernetworkrad/std'); 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; let cout = ccout.cout;

View file

@ -1,7 +1,10 @@
const { writeFile, readFile, mkdir } = require('node:fs/promises'); const { appendFile, existsSync } = require('node:fs');
const { stdin, stdout } = require('node:process'); const { mkdir } = require('node:fs/promises')
var readlineSync = require('readline-sync'); 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 () { function getTime () {
const date_time = new Date(); const date_time = new Date();
@ -14,20 +17,12 @@ function getTime () {
return({year, month, day, hours, minutes, seconds}) 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) { function log (string) {
readFile(`./logs/${name}`, 'utf8') if (!existsSync('./logs')) mkdir('./logs', { recursive: true });
.then(async (err, data) => { appendFile(`./logs/${name}`, string+'\n', err => {
if (!data) data = ''; if (err) {
data += string + '\n'; throw err
writeFile(`./logs/${name}`, data); }
}) })
}; };
@ -60,11 +55,11 @@ class createCout {
if (debug >= debugLevel) { if (debug >= debugLevel) {
console.log(`[${time.year}.${time.month}.${time.day}-${time.hours}:${time.minutes}:${time.seconds}] | ${String(string)}`); console.log(`[${time.year}.${time.month}.${time.day}-${time.hours}:${time.minutes}:${time.seconds}] | ${String(string)}`);
if (logs1) { if (logs1) {
log(string); log(`[${time.year}.${time.month}.${time.day}-${time.hours}:${time.minutes}:${time.seconds}] | ${String(string)}`);
} }
} }
return; return;
}; };
} }
module.exports = { cin, createCout, createLog, log }; module.exports = { cin, createCout, log };

View file

@ -1,6 +1,6 @@
{ {
"name": "@thundernetworkrad/std", "name": "@thundernetworkrad/std",
"version": "2023.01.24-3", "version": "2023.01.24-4",
"description": "Standard module for javascript", "description": "Standard module for javascript",
"main": "index.js", "main": "index.js",
"scripts": { "scripts": {
@ -25,6 +25,6 @@
}, },
"homepage": "https://github.com/FIUSDevelopment/std#readme", "homepage": "https://github.com/FIUSDevelopment/std#readme",
"dependencies": { "dependencies": {
"readline-sync": "^1.4.10" "@thundernetworkrad/readline-sync": "^2023.1.10"
} }
} }