@babel/highlight
Advanced tools
Comparing version 7.0.0-beta.46 to 7.0.0-beta.47
@@ -11,3 +11,3 @@ "use strict"; | ||
function _jsTokens() { | ||
var data = _interopRequireWildcard(require("js-tokens")); | ||
const data = _interopRequireWildcard(require("js-tokens")); | ||
@@ -22,3 +22,3 @@ _jsTokens = function _jsTokens() { | ||
function _esutils() { | ||
var data = _interopRequireDefault(require("esutils")); | ||
const data = _interopRequireDefault(require("esutils")); | ||
@@ -33,3 +33,3 @@ _esutils = function _esutils() { | ||
function _chalk() { | ||
var data = _interopRequireDefault(require("chalk")); | ||
const data = _interopRequireDefault(require("chalk")); | ||
@@ -61,12 +61,12 @@ _chalk = function _chalk() { | ||
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 _match$slice = match.slice(-2), | ||
offset = _match$slice[0], | ||
text = _match$slice[1]; | ||
var token = (0, _jsTokens().matchToToken)(match); | ||
const token = (0, _jsTokens().matchToToken)(match); | ||
@@ -99,14 +99,8 @@ if (token.type === "name") { | ||
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 { | ||
@@ -123,3 +117,3 @@ return args[0]; | ||
function getChalk(options) { | ||
var chalk = _chalk().default; | ||
let chalk = _chalk().default; | ||
@@ -136,10 +130,6 @@ if (options.forceColor) { | ||
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); | ||
@@ -146,0 +136,0 @@ } else { |
{ | ||
"name": "@babel/highlight", | ||
"version": "7.0.0-beta.46", | ||
"version": "7.0.0-beta.47", | ||
"description": "Syntax highlight JavaScript strings for output in terminals.", | ||
@@ -5,0 +5,0 @@ "author": "suchipi <me@suchipi.com>", |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
4453
103