diff --git a/lib/colors.js b/lib/colors.js index 59898de..1b6c240 100644 --- a/lib/colors.js +++ b/lib/colors.js @@ -2,7 +2,7 @@ The MIT License (MIT) -Original Library +Original Library - Copyright (c) Marak Squires Additional functionality @@ -33,6 +33,7 @@ module['exports'] = colors; colors.themes = {}; +var util = require('util'); var ansiStyles = colors.styles = require('./styles'); var defineProps = Object.defineProperties; @@ -87,14 +88,11 @@ var styles = (function () { var proto = defineProps(function colors() {}, styles); function applyStyle() { - var args = arguments; - var argsLen = args.length; - var str = argsLen !== 0 && String(arguments[0]); - if (argsLen > 1) { - for (var a = 1; a < argsLen; a++) { - str += ' ' + args[a]; - } - } + var args = Array.prototype.slice.call(arguments); + + var str = args.map(function(arg) { + return typeof arg === 'object' ? util.inspect(arg) : arg; + }).join(' '); if (!colors.enabled || !str) { return str; @@ -173,4 +171,4 @@ for (var map in colors.maps) { })(map) } -defineProps(colors, init()); \ No newline at end of file +defineProps(colors, init());