Socket
Socket
Sign inDemoInstall

@babel/highlight

Package Overview
Dependencies
Maintainers
6
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/highlight - npm Package Compare versions

Comparing version 7.0.0-beta.42 to 7.0.0-beta.43

79

lib/index.js
"use strict";
exports.__esModule = true;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.shouldHighlight = shouldHighlight;

@@ -8,8 +10,32 @@ exports.getChalk = getChalk;

var _jsTokens = _interopRequireWildcard(require("js-tokens"));
function _jsTokens() {
const data = _interopRequireWildcard(require("js-tokens"));
var _esutils = _interopRequireDefault(require("esutils"));
_jsTokens = function () {
return data;
};
var _chalk = _interopRequireDefault(require("chalk"));
return data;
}
function _esutils() {
const data = _interopRequireDefault(require("esutils"));
_esutils = function () {
return data;
};
return data;
}
function _chalk() {
const data = _interopRequireDefault(require("chalk"));
_chalk = function () {
return data;
};
return data;
}
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -33,15 +59,12 @@

var NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
var JSX_TAG = /^[a-z][\w-]*$/i;
var BRACKET = /^[()[\]{}]$/;
const NEWLINE = /\r\n|[\n\r\u2028\u2029]/;
const JSX_TAG = /^[a-z][\w-]*$/i;
const BRACKET = /^[()[\]{}]$/;
function getTokenType(match) {
var _match$slice = match.slice(-2),
offset = _match$slice[0],
text = _match$slice[1];
const [offset, text] = match.slice(-2);
const token = (0, _jsTokens().matchToToken)(match);
var token = (0, _jsTokens.matchToToken)(match);
if (token.type === "name") {
if (_esutils.default.keyword.isReservedWordES6(token.value)) {
if (_esutils().default.keyword.isReservedWordES6(token.value)) {
return "keyword";

@@ -71,14 +94,8 @@ }

function highlightTokens(defs, text) {
return text.replace(_jsTokens.default, function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return text.replace(_jsTokens().default, function (...args) {
const type = getTokenType(args);
const colorize = defs[type];
var type = getTokenType(args);
var colorize = defs[type];
if (colorize) {
return args[0].split(NEWLINE).map(function (str) {
return colorize(str);
}).join("\n");
return args[0].split(NEWLINE).map(str => colorize(str)).join("\n");
} else {

@@ -91,10 +108,10 @@ return args[0];

function shouldHighlight(options) {
return _chalk.default.supportsColor || options.forceColor;
return _chalk().default.supportsColor || options.forceColor;
}
function getChalk(options) {
var chalk = _chalk.default;
let chalk = _chalk().default;
if (options.forceColor) {
chalk = new _chalk.default.constructor({
chalk = new (_chalk().default.constructor)({
enabled: true,

@@ -108,10 +125,6 @@ level: 1

function highlight(code, options) {
if (options === void 0) {
options = {};
}
function highlight(code, options = {}) {
if (shouldHighlight(options)) {
var chalk = getChalk(options);
var defs = getDefs(chalk);
const chalk = getChalk(options);
const defs = getDefs(chalk);
return highlightTokens(defs, code);

@@ -118,0 +131,0 @@ } else {

{
"name": "@babel/highlight",
"version": "7.0.0-beta.42",
"version": "7.0.0-beta.43",
"description": "Syntax highlight JavaScript strings for output in terminals.",

@@ -5,0 +5,0 @@ "author": "suchipi <me@suchipi.com>",

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