Socket
Socket
Sign inDemoInstall

@babel/highlight

Package Overview
Dependencies
9
Maintainers
4
Versions
63
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.21.4-esm.3 to 7.21.4-esm.4

lib/package.json

32

lib/index.js

@@ -1,12 +0,4 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = highlight;
exports.getChalk = getChalk;
exports.shouldHighlight = shouldHighlight;
var _jsTokens = require("js-tokens");
var _helperValidatorIdentifier = require("@babel/helper-validator-identifier");
var _chalk = require("chalk");
import jsTokens from "js-tokens";
import { isStrictReservedWord, isKeyword } from "@babel/helper-validator-identifier";
import Chalk from "chalk";
const sometimesKeywords = new Set(["as", "async", "from", "get", "of", "set"]);

@@ -33,3 +25,3 @@ function getDefs(chalk) {

if (token.type === "name") {
if ((0, _helperValidatorIdentifier.isKeyword)(token.value) || (0, _helperValidatorIdentifier.isStrictReservedWord)(token.value, true) || sometimesKeywords.has(token.value)) {
if (isKeyword(token.value) || isStrictReservedWord(token.value, true) || sometimesKeywords.has(token.value)) {
return "keyword";

@@ -54,4 +46,4 @@ }

let match;
while (match = _jsTokens.default.exec(text)) {
const token = _jsTokens.matchToToken(match);
while (match = jsTokens.default.exec(text)) {
const token = jsTokens.matchToToken(match);
yield {

@@ -79,12 +71,12 @@ type: getTokenType(token, match.index, text),

}
function shouldHighlight(options) {
return !!_chalk.supportsColor || options.forceColor;
export function shouldHighlight(options) {
return !!Chalk.supportsColor || options.forceColor;
}
function getChalk(options) {
return options.forceColor ? new _chalk.constructor({
export function getChalk(options) {
return options.forceColor ? new Chalk.constructor({
enabled: true,
level: 1
}) : _chalk;
}) : Chalk;
}
function highlight(code, options = {}) {
export default function highlight(code, options = {}) {
if (code !== "" && shouldHighlight(options)) {

@@ -91,0 +83,0 @@ const chalk = getChalk(options);

{
"name": "@babel/highlight",
"version": "7.21.4-esm.3",
"version": "7.21.4-esm.4",
"description": "Syntax highlight JavaScript strings for output in terminals.",

@@ -18,3 +18,3 @@ "author": "The Babel Team (https://babel.dev/team)",

"dependencies": {
"@babel/helper-validator-identifier": "7.21.4-esm.3",
"@babel/helper-validator-identifier": "7.21.4-esm.4",
"chalk": "^2.0.0",

@@ -21,0 +21,0 @@ "js-tokens": "^4.0.0"

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc