2023.01.28
This commit is contained in:
parent
cdec34ea60
commit
8718af4659
7 changed files with 38 additions and 62 deletions
48
package-lock.json
generated
48
package-lock.json
generated
|
@ -1,48 +0,0 @@
|
|||
{
|
||||
"name": "@thundernetworkrad/std",
|
||||
"version": "2023.01.26",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@thundernetworkrad/std",
|
||||
"version": "2023.01.26",
|
||||
"hasInstallScript": true,
|
||||
"license": "SEE LICENSE IN LICENSE.txt",
|
||||
"dependencies": {
|
||||
"@thundernetworkrad/readline-sync": "^2023.1.26-2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.11.18",
|
||||
"typescript": "^4.9.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@thundernetworkrad/readline-sync": {
|
||||
"version": "2023.1.26-2",
|
||||
"resolved": "https://registry.npmjs.org/@thundernetworkrad/readline-sync/-/readline-sync-2023.1.26-2.tgz",
|
||||
"integrity": "sha512-m07hRMV5evmgbbAMD7hk8yX8Cv2yLj92aZtbC9iEtu5YQ9DRwPvyXmdtHutHI6DYHGs/kGDmjzUfQpJyowsZXA==",
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "18.11.18",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz",
|
||||
"integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "4.9.4",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.4.tgz",
|
||||
"integrity": "sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==",
|
||||
"dev": true,
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4.2.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@thundernetworkrad/std",
|
||||
"version": "2023.01.26",
|
||||
"version": "2023.01.28",
|
||||
"description": "Standard module for javascript",
|
||||
"main": "build/index.js",
|
||||
"type": "module",
|
||||
|
|
13
src/cin.ts
13
src/cin.ts
|
@ -1,6 +1,11 @@
|
|||
import readlineSync from '@thundernetworkrad/readline-sync';
|
||||
|
||||
export default (question: string, hide: boolean) => {
|
||||
/**
|
||||
*
|
||||
* @param question what question you need to make?
|
||||
* @param hide is the question private?
|
||||
* @returns
|
||||
*/
|
||||
function cin (question: string, hide: boolean) {
|
||||
return new Promise((resolve) => {
|
||||
try {
|
||||
let answer: string = readlineSync.question(`${question} `, {
|
||||
|
@ -12,4 +17,6 @@ export default (question: string, hide: boolean) => {
|
|||
return resolve('error');
|
||||
}
|
||||
})
|
||||
};
|
||||
};
|
||||
|
||||
export default cin;
|
11
src/cout.ts
11
src/cout.ts
|
@ -2,6 +2,11 @@ let debug: number, logs1: boolean|undefined|null;
|
|||
import getTime from './getTime.js';
|
||||
import log from './log.js';
|
||||
export default class createCout {
|
||||
/**
|
||||
* @constructor
|
||||
* @param debugLevel from what debug level you want to log?
|
||||
* @param logs do you want files log?
|
||||
*/
|
||||
constructor (debugLevel: number, logs?: boolean) {
|
||||
if (!debugLevel) debugLevel = 0;
|
||||
if (!logs) logs = false;
|
||||
|
@ -9,6 +14,12 @@ export default class createCout {
|
|||
logs1 = logs;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string what to log?
|
||||
* @param debugLevel from what debug level this will logged?
|
||||
* @returns
|
||||
*/
|
||||
cout (string: string, debugLevel?: number) {
|
||||
if (!debugLevel) debugLevel = 0;
|
||||
var time = getTime();
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
export default () => {
|
||||
|
||||
/**
|
||||
*
|
||||
* @returns
|
||||
*/
|
||||
function getTime () {
|
||||
const date_time = new Date();
|
||||
const year = date_time.getFullYear();
|
||||
const month = parseInt(("0" + (date_time.getMonth() + 1)).slice(-2));
|
||||
|
@ -7,4 +12,5 @@ export default () => {
|
|||
const minutes = date_time.getMinutes();
|
||||
const seconds = date_time.getSeconds();
|
||||
return({year, month, day, hours, minutes, seconds})
|
||||
};
|
||||
};
|
||||
export default getTime;
|
10
src/log.ts
10
src/log.ts
|
@ -7,7 +7,11 @@ const startTime = getTime();
|
|||
time = startTime;
|
||||
const name = `${time.year}.${time.month}.${time.day}.${time.hours}.${time.minutes}.${time.seconds}.log`;
|
||||
|
||||
export default (string?: string) => {
|
||||
/**
|
||||
*
|
||||
* @param string to log
|
||||
*/
|
||||
function log (string?: string) {
|
||||
if (!existsSync('./logs')) mkdir('./logs', { recursive: true });
|
||||
|
||||
appendFile(`./logs/${name}`, string+'\n', (err: any) => {
|
||||
|
@ -15,4 +19,6 @@ export default (string?: string) => {
|
|||
throw err
|
||||
}
|
||||
})
|
||||
};
|
||||
};
|
||||
|
||||
export default log;
|
6
test.js
6
test.js
|
@ -1,6 +0,0 @@
|
|||
import thunder from './build/index.js';
|
||||
|
||||
let cout = new thunder.cout(0, true)
|
||||
cout.cout(thunder.getTime());
|
||||
|
||||
cout.cout('ciao', 0)
|
Loading…
Reference in a new issue