mirror of
https://github.com/flynx/colors.js.git
synced 2025-10-29 19:10:10 +00:00
Fix #119 - use util.inspect for logging objects
This commit is contained in:
parent
1f617ecdc5
commit
8b51cf67b5
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
|
|
||||||
Original Library
|
Original Library
|
||||||
- Copyright (c) Marak Squires
|
- Copyright (c) Marak Squires
|
||||||
|
|
||||||
Additional functionality
|
Additional functionality
|
||||||
@ -33,6 +33,7 @@ module['exports'] = colors;
|
|||||||
|
|
||||||
colors.themes = {};
|
colors.themes = {};
|
||||||
|
|
||||||
|
var util = require('util');
|
||||||
var ansiStyles = colors.styles = require('./styles');
|
var ansiStyles = colors.styles = require('./styles');
|
||||||
var defineProps = Object.defineProperties;
|
var defineProps = Object.defineProperties;
|
||||||
|
|
||||||
@ -87,14 +88,11 @@ var styles = (function () {
|
|||||||
var proto = defineProps(function colors() {}, styles);
|
var proto = defineProps(function colors() {}, styles);
|
||||||
|
|
||||||
function applyStyle() {
|
function applyStyle() {
|
||||||
var args = arguments;
|
var args = Array.prototype.slice.call(arguments);
|
||||||
var argsLen = args.length;
|
|
||||||
var str = argsLen !== 0 && String(arguments[0]);
|
var str = args.map(function(arg) {
|
||||||
if (argsLen > 1) {
|
return typeof arg === 'object' ? util.inspect(arg) : arg;
|
||||||
for (var a = 1; a < argsLen; a++) {
|
}).join(' ');
|
||||||
str += ' ' + args[a];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!colors.enabled || !str) {
|
if (!colors.enabled || !str) {
|
||||||
return str;
|
return str;
|
||||||
@ -173,4 +171,4 @@ for (var map in colors.maps) {
|
|||||||
})(map)
|
})(map)
|
||||||
}
|
}
|
||||||
|
|
||||||
defineProps(colors, init());
|
defineProps(colors, init());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user