Socket
Socket
Sign inDemoInstall

console-stamp

Package Overview
Dependencies
60
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.0 to 0.2.1

53

main.js

@@ -12,3 +12,3 @@ /*jshint node:true, bitwise:false */

var merge = require( "merge" );
var colors = require( "colors" );
var chalk = require( "chalk" );
var defaults = require( "./defaults.json" );

@@ -40,5 +40,44 @@ var util = require( 'util' );

// Set the color theme
colors.setTheme( options.colors );
//SET COLOR THEME START
var noColor = function(str){ return str; }; //Default behaviour (no color)
var getColor = function(origColor)
{
//If color is a chalk function already, just return it
if(typeof origColor === 'function')
{
return origColor;
}
//If color is an string, check if a function in chalk exists
if(typeof origColor === 'string')
{
return chalk[""+origColor] ? chalk[""+origColor] : noColor;
}
//If color is an array, check the contents for color strings
if(Array.isArray(origColor))
{
if(origColor.length > 0)
{
var color = chalk;
for (var i = 0; i < origColor.length; i++) {
if(typeof origColor[i] === 'string')
{
color = color[""+origColor[i]];
}
}
return color;
}
else{
return noColor;
}
}
return noColor;
}
var colorTheme = {};
colorTheme.stamp = getColor(options.colors.stamp);
colorTheme.label = getColor(options.colors.label);
colorTheme.metadata = getColor(options.colors.metadata);
//SET COLOR THEME END
var original_functions = [];

@@ -56,3 +95,3 @@

var prefix = ("[" + dateFormat( pattern ) + "]").stamp + " ";
var prefix = colorTheme.stamp("[" + dateFormat( pattern ) + "]")+" ";
var args = slice.call( arguments );

@@ -62,3 +101,3 @@

if ( options.label ) {
prefix += ("[" + f.toUpperCase() + "]").label + " ".substr( f.length );
prefix += colorTheme.label("[" + f.toUpperCase() + "]")+" ".substr( f.length );
}

@@ -77,3 +116,3 @@

if ( metadata ) {
prefix += metadata.metadata + " ";
prefix += colorTheme.metadata(metadata) + " "; //Metadata
}

@@ -80,0 +119,0 @@

8

package.json
{
"name": "console-stamp",
"main": "main",
"version": "0.2.0",
"version": "0.2.1",
"author": {

@@ -22,2 +22,6 @@ "name": "Ståle Raknes",

"url": "https://github.com/devotis"
},
{
"name": "Leon Lucardie",
"url": "https://github.com/Gameleon12"
}

@@ -41,3 +45,3 @@ ],

"merge": "^1.2.0",
"colors": "^1.1.2"
"chalk": "^1.1.1"
},

@@ -44,0 +48,0 @@ "devDependencies": {

@@ -40,9 +40,9 @@ # console-stamp

* **options.colors** {Object}<br>An object representing a color theme. More info [here](https://www.npmjs.com/package/colors).
* **options.colors** {Object}<br>An object representing a color theme. More info [here](https://www.npmjs.com/package/chalk).
* **options.colors.stamp** {String/Array} <br>**Default:** []
* **options.colors.stamp** {String/Array<String>/Function} <br>**Default:** []
* **options.colors.label** {String/Array} <br>**Default:** []
* **options.colors.label** {String/Array<String>/Function} <br>**Default:** []
* **options.colors.metadata** {String/Array} <br>**Default:** []
* **options.colors.metadata** {String/Array<String>/Function} <br>**Default:** []

@@ -54,2 +54,11 @@ Note: To combine colors, bgColors and style, set them as an array like this:

...
Or chain Chalk functions like this:
...
stamp: require("chalk").red.bgYellow.underline;
...
Note also that by sending the parameter `--no-color` when you start your node app, will prevent any colors from console.

@@ -56,0 +65,0 @@

Sorry, the diff of this file is not supported yet

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