json-colorizer
Advanced tools
Comparing version 2.1.0 to 2.1.1
14
index.js
const colorize = require('./src/lib'); | ||
const jsonString = JSON.stringify({ foo: 'bar' }, null, 2); | ||
console.log( | ||
colorize( | ||
{ foo: 'bar' }, | ||
{ | ||
colors: { | ||
STRING_LITERAL: '#FF0000' | ||
} | ||
colorize(jsonString, { | ||
colors: { | ||
STRING_LITERAL: '#FF0000' | ||
} | ||
) | ||
}) | ||
); |
{ | ||
"name": "json-colorizer", | ||
"version": "2.1.0", | ||
"version": "2.1.1", | ||
"description": "A library to format JSON with colors for display in the console", | ||
@@ -5,0 +5,0 @@ "main": "src/lib/index.js", |
@@ -22,3 +22,3 @@ const chalk = require('chalk'); | ||
const colorKey = colors[token.type] || defaultColors[token.type]; | ||
const colorFn = colorKey[0] === '#' ? chalk.hex(colorKey) : get(chalk, colorKey); | ||
const colorFn = colorKey && colorKey[0] === '#' ? chalk.hex(colorKey) : get(chalk, colorKey); | ||
@@ -25,0 +25,0 @@ return acc + (colorFn ? colorFn(token.value) : token.value); |
@@ -25,2 +25,6 @@ const { expect } = require('chai'); | ||
describe('Colorizer', function() { | ||
it('does not throw an error when there is whitespace', function() { | ||
expect(() => colorize(getTokens(JSON.stringify(fixture, null, 2)))).to.not.throw(); | ||
}); | ||
it('colorizes with default options', function() { | ||
@@ -27,0 +31,0 @@ const tokens = getTokens(fixture); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31961
353