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.19 to 1.2.20

66

dist/decaffeinate-parser.es6.js
import * as CoffeeScript from 'coffee-script';
import binarySearch from 'binary-search';
import lex, { HERECOMMENT, COMMENT, NEWLINE } from 'coffee-lex';
import lex, { HERECOMMENT, COMMENT, NEWLINE, RELATION, IF } from 'coffee-lex';
import { inspect } from 'util';

@@ -1375,14 +1375,41 @@

case 'If':
var conditional = makeNode('Conditional', node.locationData, {
isUnless: Boolean(node.condition.inverted || node.condition.negated),
condition: convertChild(node.condition),
consequent: convertChild(node.body),
alternate: convertChild(node.elseBody)
});
if (conditional.consequent) {
if (conditional.condition.range[0] > conditional.consequent.range[0]) {
conditional.consequent.inline = true;
{
var condition = convertChild(node.condition);
var consequent = convertChild(node.body);
var alternate = convertChild(node.elseBody);
var isUnless = false;
if (consequent && consequent.range[0] < condition.range[0]) {
// POST-if, so look for tokens between the consequent and the condition
consequent.inline = true;
var lastConsequentTokenIndex = context.sourceTokens.indexOfTokenEndingAtSourceIndex(consequent.range[1]);
var firstConditionTokenIndex = context.sourceTokens.indexOfTokenStartingAtSourceIndex(condition.range[0]);
for (var _i = lastConsequentTokenIndex; _i !== firstConditionTokenIndex; _i = _i.next()) {
var token = context.sourceTokens.tokenAtIndex(_i);
if (token.type === IF) {
isUnless = source.slice(token.start, token.end) === 'unless';
break;
}
}
} else {
// Regular `if`, so look at the start of the node.
var _firstConditionTokenIndex = context.sourceTokens.indexOfTokenStartingAtSourceIndex(condition.range[0]);
for (var _i2 = _firstConditionTokenIndex; _i2 !== null; _i2 = _i2.previous()) {
var _token = context.sourceTokens.tokenAtIndex(_i2);
if (_token.type === IF) {
isUnless = source.slice(_token.start, _token.end) === 'unless';
break;
}
}
}
return makeNode('Conditional', node.locationData, {
isUnless: isUnless,
condition: condition,
consequent: consequent,
alternate: alternate
});
}
return conditional;

@@ -1419,4 +1446,4 @@ case 'Code':

block.inline = false;
for (var _i = block.range[0] - 1; _i >= 0; _i--) {
var char = source[_i];
for (var _i3 = block.range[0] - 1; _i3 >= 0; _i3--) {
var char = source[_i3];
if (char === '\n') {

@@ -1608,5 +1635,14 @@ break;

var right = convertChild(node.array);
var operatorSource = source.slice(_left.range[1], right.range[0]);
var isNot = /^\s*not\s+in\s*/.test(operatorSource);
var isNot = false;
var lastTokenIndexOfLeft = context.sourceTokens.indexOfTokenEndingAtSourceIndex(_left.range[1]);
var firstTokenIndexOfRight = context.sourceTokens.indexOfTokenStartingAtSourceIndex(right.range[0]);
for (var _i4 = lastTokenIndexOfLeft.next(); _i4 !== firstTokenIndexOfRight; _i4 = _i4.next()) {
var _token2 = context.sourceTokens.tokenAtIndex(_i4);
if (_token2.type === RELATION) {
isNot = source.slice(_token2.start, _token2.end) !== 'in';
}
}
return makeNode('InOp', node.locationData, {

@@ -1613,0 +1649,0 @@ left: _left,

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

@@ -5,0 +5,0 @@ "main": "dist/decaffeinate-parser.umd.js",

Sorry, the diff of this file is too big to display

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