Socket
Socket
Sign inDemoInstall

cardinal

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cardinal - npm Package Compare versions

Comparing version 0.4.0 to 0.4.1

12

lib/highlight.js
var redeyed = require('redeyed')
, theme = require('../themes/default')
, colors = require('../colors')
, colorSurround = colors.brightBlack.split(':')
, colors = require('ansicolors')
, colorSurround = colors.brightBlack
;

@@ -54,9 +54,3 @@

for (var i = 0; i < linesLen; i++) {
lineno = [
colorSurround[0]
, pad(i + firstline, totalDigits)
, ': '
, colorSurround[1]
].join('');
lineno = colorSurround(pad(i + firstline, totalDigits) + ': ')
lines.push(lineno + highlightedLines[i]);

@@ -63,0 +57,0 @@ }

{
"name": "cardinal",
"version": "0.4.0",
"version": "0.4.1",
"description": "Syntax highlights JavaScript code with ANSI colors to be printed to the terminal.",

@@ -22,2 +22,3 @@ "main": "cardinal.js",

"javascript",
"json",
"terminal",

@@ -31,3 +32,4 @@ "console",

"dependencies": {
"redeyed": "~0.4.0"
"redeyed": "~0.4.0",
"ansicolors": "~0.2.1"
},

@@ -34,0 +36,0 @@ "devDependencies": {

@@ -8,3 +8,3 @@ /*jshint asi:true */

, highlighter = require('..')
, colorize = require('../colorize')
, colors = require('ansicolors')
, diffFile = path.join(__dirname, 'fixtures', 'git-diff.txt')

@@ -75,3 +75,3 @@ , diff = fs.readFileSync(diffFile, 'utf-8')

function highlightDiffInd(line, matches) {
var highlighted = colorize.brightBlue(matches[1])
var highlighted = colors.brightBlue(matches[1])
, code = matches[2];

@@ -81,4 +81,4 @@ return code ? highlighted + tryHighlight(code) : highlighted;

function colorizeAddRemove(c) {
return addRemRegex.test(c) ? colorize.yellow(c) : c;
function colorsAddRemove(c) {
return addRemRegex.test(c) ? colors.yellow(c) : c;
}

@@ -91,3 +91,3 @@

? highlightDiffInd(line, diffIndMatches)
: colorizeAddRemove(line[0]) + tryHighlight(line.slice(1));
: colorsAddRemove(line[0]) + tryHighlight(line.slice(1));
}

@@ -94,0 +94,0 @@

@@ -27,3 +27,3 @@ 'use strict';

/*test('not supplying custom theme', function (t) {
test('not supplying custom theme', function (t) {
cardinal.highlightFile(file, function (err, highlighted) {

@@ -35,5 +35,5 @@

})
})*/
})
/*test('errornous code', function (t) {
test('errornous code', function (t) {
cardinal.highlightFile(fileWithErrors, function (err, highlighted) {

@@ -43,5 +43,5 @@ t.similar(err.message, /Unable to perform highlight. The code contained syntax errors.* Line 1: Unexpected token [(]/)

})
})*/
})
/*test('non existing file', function (t) {
test('non existing file', function (t) {
cardinal.highlightFile('./not/existing', function (err, highlighted) {

@@ -51,2 +51,2 @@ t.similar(err.message, /ENOENT, .*not.existing/)

})
})*/
})

@@ -19,3 +19,3 @@ 'use strict';

t.equals(null, err, 'no error');
t.equals(highlighted, '\u001b[33m{\u001b[39m\u001b[92m"foo"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"bar"\u001b[39m\u001b[32m,\u001b[39m\u001b[92m"baz"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"quux"\u001b[39m\u001b[32m,\u001b[39m\u001b[92m"bam"\u001b[39m\u001b[93m:\u001b[39m\u001b[90mnull\u001b[39m\u001b[33m}\u001b[39m');
t.equals(highlighted, '\u001b[33m{\u001b[39m\u001b[32m"foo"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"bar"\u001b[39m\u001b[32m,\u001b[39m\u001b[32m"baz"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"quux"\u001b[39m\u001b[32m,\u001b[39m\u001b[32m"bam"\u001b[39m\u001b[93m:\u001b[39m\u001b[90mnull\u001b[39m\u001b[33m}\u001b[39m');
t.end();

@@ -22,0 +22,0 @@ });

@@ -18,3 +18,3 @@ 'use strict';

t.equals(highlighted, '\u001b[33m{\u001b[39m\u001b[92m"foo"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"bar"\u001b[39m\u001b[32m,\u001b[39m\u001b[92m"baz"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"quux"\u001b[39m\u001b[32m,\u001b[39m\u001b[92m"bam"\u001b[39m\u001b[93m:\u001b[39m\u001b[90mnull\u001b[39m\u001b[33m}\u001b[39m');
t.equals(highlighted, '\u001b[33m{\u001b[39m\u001b[32m"foo"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"bar"\u001b[39m\u001b[32m,\u001b[39m\u001b[32m"baz"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"quux"\u001b[39m\u001b[32m,\u001b[39m\u001b[32m"bam"\u001b[39m\u001b[93m:\u001b[39m\u001b[90mnull\u001b[39m\u001b[33m}\u001b[39m');
t.end();

@@ -21,0 +21,0 @@ });

@@ -30,3 +30,3 @@ 'use strict';

t.equals(highlighted, '\u001b[33m{\u001b[39m\u001b[92m"foo"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"bar"\u001b[39m\u001b[32m,\u001b[39m\u001b[92m"baz"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"quux"\u001b[39m\u001b[32m,\u001b[39m\u001b[92m"bam"\u001b[39m\u001b[93m:\u001b[39m\u001b[90mnull\u001b[39m\u001b[33m}\u001b[39m')
t.equals(highlighted, '\u001b[33m{\u001b[39m\u001b[32m"foo"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"bar"\u001b[39m\u001b[32m,\u001b[39m\u001b[32m"baz"\u001b[39m\u001b[93m:\u001b[39m\u001b[92m"quux"\u001b[39m\u001b[32m,\u001b[39m\u001b[32m"bam"\u001b[39m\u001b[93m:\u001b[39m\u001b[90mnull\u001b[39m\u001b[33m}\u001b[39m')
t.end();

@@ -33,0 +33,0 @@ });

@@ -1,2 +0,2 @@

var colors = require('../colors');
var colors = require('ansicolors');

@@ -31,3 +31,10 @@ // Change the below definitions in order to tweak the color theme.

, 'String': {
_default: colors.brightGreen
_default: function (s, info) {
var nextToken = info.tokens[info.tokenIndex + 1];
// show keys of object literals and json in different color
return (nextToken && nextToken.type === 'Punctuator' && nextToken.value === ':')
? colors.green(s)
: colors.brightGreen(s);
}
}

@@ -34,0 +41,0 @@

@@ -7,3 +7,3 @@ /*

var colors = require('../colors');
var colors = require('ansicolors');

@@ -10,0 +10,0 @@ // Change the below definitions in order to tweak the color theme.

@@ -1,2 +0,2 @@

var colors = require('../colors');
var colors = require('ansicolors');

@@ -31,3 +31,10 @@ // Change the below definitions in order to tweak the color theme.

, 'String': {
_default: colors.brightGreen
_default: function (s, info) {
var nextToken = info.tokens[info.tokenIndex + 1];
// show keys of object literals and json in different color
return (nextToken && nextToken.type === 'Punctuator' && nextToken.value === ':')
? colors.green(s)
: colors.brightGreen(s);
}
}

@@ -34,0 +41,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc