New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

decaffeinate-parser

Package Overview
Dependencies
Maintainers
1
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

decaffeinate-parser - npm Package Compare versions

Comparing version 1.2.7 to 1.2.8

55

dist/decaffeinate-parser.es6.js

@@ -424,5 +424,44 @@ import * as CoffeeScript from 'coffee-script';

* @param {Object} node
* @param {Array<Object>} ancestors
* @param {ParseContext} context
* @returns boolean
*/
function isInterpolatedString(node, context) {
function isInterpolatedString(node, ancestors, context) {
var range = rangeOfInterpolatedStringForNode(node, context);
if (!range) {
return false;
}
var parentOp = void 0;
for (var i = ancestors.length - 1; i >= 0; i--) {
if (type(ancestors[i]) === 'Op') {
parentOp = ancestors[i];
break;
}
}
if (!parentOp) {
// `node` is in an interpolated string but there is no containing
// operator, so it must be a root.
return true;
}
var parentRange = rangeOfInterpolatedStringForNode(parentOp, context);
if (!parentRange) {
// There's a containing operator, but there's no interpolated string.
return true;
}
// There's a string interpolation containing the parent operator, but is it
// the same one? If not, then this node is the root of an interpolated string.
return parentRange[0] !== range[0] || parentRange[1] !== range[1];
}
function rangeOfInterpolatedStringForNode(node, context) {
if (node.operator !== '+' || !node.second) {
return null;
}
var range = context.getRange(node);

@@ -434,3 +473,3 @@ var tokens = context.sourceTokens;

}
return tokens.rangeOfInterpolatedStringTokensContainingTokenIndex(startTokenIndex) !== null;
return tokens.rangeOfInterpolatedStringTokensContainingTokenIndex(startTokenIndex);
}

@@ -1238,12 +1277,4 @@

var op = convertOperator(node);
if (op.type === 'PlusOp') {
if (isInterpolatedString(node, context)) {
op.type = 'ConcatOp';
var parentOp = ancestors.reduce(function (memo, ancestor) {
return type(ancestor) === 'Op' ? ancestor : memo;
}, null);
if (!parentOp || !isInterpolatedString(parentOp, context)) {
return createTemplateLiteral(op);
}
}
if (isInterpolatedString(node, ancestors, context)) {
return createTemplateLiteral(op);
}

@@ -1250,0 +1281,0 @@ if (isChainedComparison(node) && !isChainedComparison(ancestors[ancestors.length - 1])) {

@@ -428,5 +428,44 @@ (function (global, factory) {

* @param {Object} node
* @param {Array<Object>} ancestors
* @param {ParseContext} context
* @returns boolean
*/
function isInterpolatedString(node, context) {
function isInterpolatedString(node, ancestors, context) {
var range = rangeOfInterpolatedStringForNode(node, context);
if (!range) {
return false;
}
var parentOp = void 0;
for (var i = ancestors.length - 1; i >= 0; i--) {
if (type(ancestors[i]) === 'Op') {
parentOp = ancestors[i];
break;
}
}
if (!parentOp) {
// `node` is in an interpolated string but there is no containing
// operator, so it must be a root.
return true;
}
var parentRange = rangeOfInterpolatedStringForNode(parentOp, context);
if (!parentRange) {
// There's a containing operator, but there's no interpolated string.
return true;
}
// There's a string interpolation containing the parent operator, but is it
// the same one? If not, then this node is the root of an interpolated string.
return parentRange[0] !== range[0] || parentRange[1] !== range[1];
}
function rangeOfInterpolatedStringForNode(node, context) {
if (node.operator !== '+' || !node.second) {
return null;
}
var range = context.getRange(node);

@@ -438,3 +477,3 @@ var tokens = context.sourceTokens;

}
return tokens.rangeOfInterpolatedStringTokensContainingTokenIndex(startTokenIndex) !== null;
return tokens.rangeOfInterpolatedStringTokensContainingTokenIndex(startTokenIndex);
}

@@ -1242,12 +1281,4 @@

var op = convertOperator(node);
if (op.type === 'PlusOp') {
if (isInterpolatedString(node, context)) {
op.type = 'ConcatOp';
var parentOp = ancestors.reduce(function (memo, ancestor) {
return type(ancestor) === 'Op' ? ancestor : memo;
}, null);
if (!parentOp || !isInterpolatedString(parentOp, context)) {
return createTemplateLiteral(op);
}
}
if (isInterpolatedString(node, ancestors, context)) {
return createTemplateLiteral(op);
}

@@ -1254,0 +1285,0 @@ if (isChainedComparison(node) && !isChainedComparison(ancestors[ancestors.length - 1])) {

{
"name": "decaffeinate-parser",
"version": "1.2.7",
"version": "1.2.8",
"description": "A better AST for CoffeeScript, inspired by CoffeeScriptRedux.",

@@ -24,14 +24,14 @@ "main": "dist/decaffeinate-parser.umd.js",

"binary-search": "^1.2.0",
"coffee-lex": "^1.3.4",
"coffee-lex": "^1.3.5",
"coffee-script": "^1.10.0"
},
"devDependencies": {
"babel": "^6.3.26",
"babel-preset-es2015": "^6.3.13",
"babel": "^6.5.2",
"babel-preset-es2015": "^6.6.0",
"babel-preset-es2015-rollup": "^1.1.1",
"babel-register": "^6.4.3",
"babel-register": "^6.7.2",
"coffee-script-redux": "^2.0.0-beta8",
"mocha": "^2.3.4",
"rollup": "^0.25.0",
"rollup-plugin-babel": "^2.3.9",
"mocha": "^2.4.5",
"rollup": "^0.25.4",
"rollup-plugin-babel": "^2.4.0",
"string-repeat": "^1.1.1"

@@ -38,0 +38,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