Socket
Socket
Sign inDemoInstall

babel-code-frame

Package Overview
Dependencies
Maintainers
6
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-code-frame - npm Package Compare versions

Comparing version 6.8.0 to 6.11.0

61

lib/index.js

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

/*istanbul ignore next*/"use strict";
"use strict";

@@ -6,7 +6,7 @@ exports.__esModule = true;

exports.default = function (rawLines, lineNumber, colNumber) {
/*istanbul ignore next*/var opts = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
var opts = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3];
colNumber = Math.max(colNumber, 0);
var highlighted = opts.highlightCode && /*istanbul ignore next*/_chalk2.default.supportsColor;
var highlighted = opts.highlightCode && _chalk2.default.supportsColor;
if (highlighted) rawLines = highlight(rawLines);

@@ -27,4 +27,4 @@

var number = start + 1 + index;
var paddedNumber = /*istanbul ignore next*/(" " + number).slice(-numberMaxWidth);
var gutter = /*istanbul ignore next*/" " + paddedNumber + " | ";
var paddedNumber = (" " + number).slice(-numberMaxWidth);
var gutter = " " + paddedNumber + " | ";
if (number === lineNumber) {

@@ -34,9 +34,7 @@ var markerLine = "";

var markerSpacing = line.slice(0, colNumber - 1).replace(/[^\t]/g, " ");
markerLine = /*istanbul ignore next*/"\n " + gutter.replace(/\d/g, " ") + markerSpacing + "^";
markerLine = "\n " + gutter.replace(/\d/g, " ") + markerSpacing + "^";
}
return (/*istanbul ignore next*/">" + gutter + line + markerLine
);
return ">" + gutter + line + markerLine;
} else {
return (/*istanbul ignore next*/" " + gutter + line
);
return " " + gutter + line;
}

@@ -46,4 +44,3 @@ }).join("\n");

if (highlighted) {
return (/*istanbul ignore next*/_chalk2.default.reset(frame)
);
return _chalk2.default.reset(frame);
} else {

@@ -54,15 +51,12 @@ return frame;

var /*istanbul ignore next*/_jsTokens = require("js-tokens");
var _jsTokens = require("js-tokens");
/*istanbul ignore next*/
var _jsTokens2 = _interopRequireDefault(_jsTokens);
var /*istanbul ignore next*/_esutils = require("esutils");
var _esutils = require("esutils");
/*istanbul ignore next*/
var _esutils2 = _interopRequireDefault(_esutils);
var /*istanbul ignore next*/_chalk = require("chalk");
var _chalk = require("chalk");
/*istanbul ignore next*/
var _chalk2 = _interopRequireDefault(_chalk);

@@ -77,12 +71,12 @@

var defs = {
string: /*istanbul ignore next*/_chalk2.default.red,
punctuator: /*istanbul ignore next*/_chalk2.default.bold,
curly: /*istanbul ignore next*/_chalk2.default.green,
parens: /*istanbul ignore next*/_chalk2.default.blue.bold,
square: /*istanbul ignore next*/_chalk2.default.yellow,
keyword: /*istanbul ignore next*/_chalk2.default.cyan,
number: /*istanbul ignore next*/_chalk2.default.magenta,
regex: /*istanbul ignore next*/_chalk2.default.magenta,
comment: /*istanbul ignore next*/_chalk2.default.grey,
invalid: /*istanbul ignore next*/_chalk2.default.inverse
string: _chalk2.default.red,
punctuator: _chalk2.default.bold,
curly: _chalk2.default.green,
parens: _chalk2.default.blue.bold,
square: _chalk2.default.yellow,
keyword: _chalk2.default.cyan,
number: _chalk2.default.magenta,
regex: _chalk2.default.magenta,
comment: _chalk2.default.grey,
invalid: _chalk2.default.inverse
};

@@ -101,4 +95,4 @@

function getTokenType(match) {
var token = /*istanbul ignore next*/_jsTokens2.default.matchToToken(match);
if (token.type === "name" && /*istanbul ignore next*/_esutils2.default.keyword.isReservedWordES6(token.value)) {
var token = _jsTokens2.default.matchToToken(match);
if (token.type === "name" && _esutils2.default.keyword.isReservedWordES6(token.value)) {
return "keyword";

@@ -129,4 +123,3 @@ }

function highlight(text) {
return text.replace( /*istanbul ignore next*/_jsTokens2.default, function () {
/*istanbul ignore next*/
return text.replace(_jsTokens2.default, function () {
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {

@@ -139,3 +132,3 @@ args[_key] = arguments[_key];

if (colorize) {
return args[0].split(NEWLINE).map(function (str) /*istanbul ignore next*/{
return args[0].split(NEWLINE).map(function (str) {
return colorize(str);

@@ -153,2 +146,2 @@ }).join("\n");

/*istanbul ignore next*/module.exports = exports["default"];
module.exports = exports["default"];
{
"name": "babel-code-frame",
"version": "6.8.0",
"version": "6.11.0",
"description": "Generate errors that contain a code frame that point to source locations.",

@@ -14,4 +14,4 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>",

"esutils": "^2.0.2",
"js-tokens": "^1.0.2"
"js-tokens": "^2.0.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