Socket
Socket
Sign inDemoInstall

node-cout

Package Overview
Dependencies
7
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2023.2.5 to 2023.6.19-1

build/index.d.ts

10

package.json
{
"name": "node-cout",
"version": "2023.02.05",
"version": "2023.06.19-1",
"description": "Standard output module for JavaScript / TypeScript",
"main": "build/index.js",
"types": "build/index.d.ts",
"type": "module",
"scripts": {
"install": "tsc"
"build": "tsc"
},

@@ -33,5 +34,6 @@ "repository": {

"dependencies": {
"@thundernetworkrad/logs": "^2023.2.5",
"@thundernetworkrad/time": "^2023.2.5",
"@thundernetworkrad/logs": "^2023.2.5-1",
"@thundernetworkrad/time": "^2023.2.5-2",
"@types/node": "^18.11.18",
"chalk": "^5.2.0",
"tslib": "^2.5.0",

@@ -38,0 +40,0 @@ "typescript": "^4.9.4"

20

readme.md

@@ -5,12 +5,20 @@ # COUT

Readme work in progress
## MJS or TypeScript
```js
import { createCout } from '@thundernetworkrad/std';
import { cout as cc } from 'node-cout';
let ccout = new createCout(0, true); // debugLevel, logs enabled (file) (like using log() )
cout = new cc(0, true, true); // debugLevel, logs enabled (file), emojis enabled
let cout = ccout.cout;
cout.debug('test', 0) // console.log time and the string, if the number is >= to the debugLevel
cout.log('test')
cout.error('test')
cout.warn('test')
cout.info('test')
```
cout('test', 0) // console.log day, time and the string, if the number is >= to the debugLevel
## CJS
use `await import("")`
```js
let { cout } = await import('node-cout'); // ti put in an async function
cout = new cout(); // from here equal to MJS example
```

@@ -1,36 +0,95 @@

let debug: number, logs1: boolean|undefined|null;
import { getTime } from '@thundernetworkrad/time';
import { log } from '@thundernetworkrad/logs';
import chalk from "chalk";
export 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;
debug = debugLevel;
logs1 = logs;
}
export class cout {
private debugLevel: number
private file: boolean
private emoji: boolean
/**
*
* @param string what to log?
* @param debugLevel from what debug level this will logged?
* @returns
* @param debugLevel The debug level of the logging
* @param file Do you want put the logs in a file?
* @param emoji Do you want put the logs in an emoji?
*/
cout (string: string, debugLevel?: number) {
if (!debugLevel) debugLevel = 0;
var time = getTime();
constructor(debugLevel?: number, file?: boolean, emoji?: boolean) {
this.debugLevel = debugLevel || 0;
this.file = file || false;
this.emoji = emoji || false;
}
if (debug >= debugLevel) {
console.log(`[${time.year}.${time.month}.${time.day}-${time.hours}:${time.minutes}:${time.seconds}] | ${String(string)}`);
if (logs1) {
log(`[${time.year}.${time.month}.${time.day}-${time.hours}:${time.minutes}:${time.seconds}] | ${String(string)}`);
}
private l(string: string, type: string) {
let time = `${getTime().hours}:${getTime().minutes}:${getTime().seconds}`;
type = type.toUpperCase();
let timec = chalk.blue(time), stringc: string = " ", typec: string, emoji: string, emojic: string;
switch (type) {
case "DEBUG":
stringc = chalk.grey(string);
typec = chalk.grey(type);
emoji = "📝";
emojic = "📝 ";
break;
case "LOG":
stringc = chalk.white(string);
type = " " + type;
typec = chalk.white(type);
emoji = "🪵";
emojic = "🪵 ";
break;
case "INFO":
stringc = chalk.cyan(string);
type = " " + type;
typec = chalk.cyan(type);
emoji = " ℹ️ ";
emojic = " ℹ️ ";
break;
case "WARN":
stringc = chalk.yellow(string);
type = " " + type;
typec = chalk.yellow(type);
emoji = "⚠️";
emojic = "⚠️ ";
break;
case "ERROR":
stringc = chalk.red(string);
typec = chalk.red(type);
emoji = "❌";
emojic = "❌ ";
break;
}
return;
};
if (this.file) {
string.split("\n").forEach((line) => {
log(`${this.emoji ? emoji : ""}[${time} ${type}] | ${line}`);
})
}
stringc.split("\n").forEach((line) => {
console.log(`${this.emoji ? emojic : ""}[${timec} ${typec}] | ${line}`);
})
}
debug(string: string, level?: number) {
if (this.debugLevel >= (level || 0)) {
this.l(string, "DEBUG")
}
}
log(string: string) {
this.l(string, "LOG");
}
info(string: string) {
this.l(string, "INFO");
}
warn(string: string) {
this.l(string, "WARN");
}
error(string: string) {
this.l(string, "ERROR");
}
}

@@ -28,3 +28,3 @@ {

/* Modules */
"module": "CommonJS", /* Specify what module code is generated. */
"module": "ESNext", /* Specify what module code is generated. */
"rootDir": "./src/", /* Specify the root folder within your source files. */

@@ -31,0 +31,0 @@ "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc