Huge News!Announcing our $40M Series B led by Abstract Ventures.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 22.5.12 to 22.5.13

dist/util/notNull.d.ts

1

dist/ext/coffee-script.js

@@ -12,3 +12,2 @@ "use strict";

exports.patchCoffeeScript = patchCoffeeScript;
// tslint:disable-next-line no-any
function invert() {

@@ -15,0 +14,0 @@ this.inverted = !this.inverted;

@@ -16,5 +16,3 @@ "use strict";

// sub-traversals. This is taken from the walkBody implementation.
var hasProtoAssignChild = node.expressions.some(function (child) {
return child instanceof nodes_1.Value && child.isObject(true);
});
var hasProtoAssignChild = node.expressions.some(function (child) { return child instanceof nodes_1.Value && child.isObject(true); });
if (hasProtoAssignChild) {

@@ -25,5 +23,11 @@ childContext = childContext.updateState(function (s) { return s.dropCurrentClass(); });

var _a = getLocation_1["default"](context, node), line = _a.line, column = _a.column, start = _a.start, end = _a.end, raw = _a.raw;
var previousTokenIndex = context.sourceTokens.indexOfTokenNearSourceIndex(start).previous();
var previousToken = previousTokenIndex ? context.sourceTokens.tokenAtIndex(previousTokenIndex) : null;
var inline = previousToken ? previousToken.type !== coffee_lex_1.SourceType.NEWLINE : false;
var previousTokenIndex = context.sourceTokens
.indexOfTokenNearSourceIndex(start)
.previous();
var previousToken = previousTokenIndex
? context.sourceTokens.tokenAtIndex(previousTokenIndex)
: null;
var inline = previousToken
? previousToken.type !== coffee_lex_1.SourceType.NEWLINE
: false;
return new nodes_2.Block(line, column, start, end, raw, node.expressions

@@ -36,3 +40,5 @@ .filter(function (expression) { return !isCommentOnlyNode_1["default"](expression); })

function mapChild(blockContext, childContext, node) {
if (blockContext.parseState.isInClassBody() && node instanceof nodes_1.Value && node.isObject(true)) {
if (blockContext.parseState.isInClassBody() &&
node instanceof nodes_1.Value &&
node.isObject(true)) {
var obj = node.base;

@@ -56,3 +62,4 @@ if (!(obj instanceof nodes_1.Obj)) {

}
else if (key instanceof nodes_2.MemberAccessOp && key.expression instanceof nodes_2.This) {
else if (key instanceof nodes_2.MemberAccessOp &&
key.expression instanceof nodes_2.This) {
Node_1 = nodes_2.AssignOp;

@@ -59,0 +66,0 @@ }

@@ -22,3 +22,4 @@ "use strict";

var firstArg = node.args[0];
if (!(firstArg instanceof nodes_1.Value) || !(firstArg.base instanceof nodes_1.StringWithInterpolations)) {
if (!(firstArg instanceof nodes_1.Value) ||
!(firstArg.base instanceof nodes_1.StringWithInterpolations)) {
throw new Error('Expected a valid first heregex arg in the AST.');

@@ -30,3 +31,4 @@ }

var secondArg = node.args[1];
if (!(secondArg instanceof nodes_1.Value) || !(secondArg.base instanceof nodes_1.Literal)) {
if (!(secondArg instanceof nodes_1.Value) ||
!(secondArg.base instanceof nodes_1.Literal)) {
throw new Error('Expected a string flags value in the heregex AST.');

@@ -113,5 +115,7 @@ }

// arg with the same value and location.
if (arg instanceof nodes_2.Identifier && param instanceof nodes_2.Identifier &&
if (arg instanceof nodes_2.Identifier &&
param instanceof nodes_2.Identifier &&
arg.data === param.data &&
arg.start === param.start && arg.end === param.end) {
arg.start === param.start &&
arg.end === param.end) {
return param;

@@ -118,0 +122,0 @@ }

@@ -7,5 +7,4 @@ "use strict";

// fake the type here for now.
// tslint:disable-next-line no-any
return mapAny_1["default"](context, node.value);
}
exports["default"] = mapComputedPropertyName;

@@ -70,3 +70,5 @@ "use strict";

var unmappedExpressions = getTemplateLiteralComponents_1["default"](context, childInterpolatedString).unmappedExpressions;
return unmappedExpressions.map(function (child) { return child ? mapAny_1["default"](context, child) : null; });
return unmappedExpressions.map(function (child) {
return child ? mapAny_1["default"](context, child) : null;
});
}

@@ -28,4 +28,7 @@ "use strict";

if (left && right) {
isUnless = context.sourceTokens.indexOfTokenMatchingPredicate(function (token) { return (token.type === coffee_lex_1.SourceType.IF &&
context.source.slice(token.start, token.end) === 'unless'); }, left, right) !== null;
isUnless =
context.sourceTokens.indexOfTokenMatchingPredicate(function (token) {
return token.type === coffee_lex_1.SourceType.IF &&
context.source.slice(token.start, token.end) === 'unless';
}, left, right) !== null;
}

@@ -32,0 +35,0 @@ return new nodes_1.Conditional(line, column, start, end, raw, condition, consequent, alternate, isUnless);

@@ -20,3 +20,4 @@ "use strict";

if (relationToken) {
isNot = context.source.slice(relationToken.start, relationToken.end) !== 'in';
isNot =
context.source.slice(relationToken.start, relationToken.end) !== 'in';
return new nodes_1.InOp(line, column, start, end, raw, left, right, isNot);

@@ -23,0 +24,0 @@ }

@@ -25,3 +25,4 @@ "use strict";

}
else if (node instanceof nodes_1.IdentifierLiteral || node instanceof nodes_1.PropertyName) {
else if (node instanceof nodes_1.IdentifierLiteral ||
node instanceof nodes_1.PropertyName) {
// Sometimes the CoffeeScript AST contains a string object instead of a

@@ -28,0 +29,0 @@ // string primitive. Convert to string primitive if necessary.

import { ModuleDeclaration } from 'decaffeinate-coffeescript2/lib/coffeescript/nodes';
import { Node } from '../nodes';
import * as nodes from '../nodes';
import ParseContext from '../util/ParseContext';
export default function mapModuleDeclaration(context: ParseContext, node: ModuleDeclaration): Node;
export default function mapModuleDeclaration(context: ParseContext, node: ModuleDeclaration): nodes.Node;
"use strict";
exports.__esModule = true;
var nodes_1 = require("decaffeinate-coffeescript2/lib/coffeescript/nodes");
var nodes_2 = require("../nodes");
var nodes = require("../nodes");
var getLocation_1 = require("../util/getLocation");

@@ -9,2 +9,3 @@ var UnsupportedNodeError_1 = require("../util/UnsupportedNodeError");

var mapLiteral_1 = require("./mapLiteral");
var notNull_1 = require("../util/notNull");
function mapModuleDeclaration(context, node) {

@@ -18,3 +19,5 @@ var _a = getLocation_1["default"](context, node), line = _a.line, column = _a.column, start = _a.start, end = _a.end, raw = _a.raw;

if (clause) {
defaultBinding = clause.defaultBinding && mapIdentifierSpecifier(context, clause.defaultBinding);
defaultBinding =
clause.defaultBinding &&
mapIdentifierSpecifier(context, clause.defaultBinding);
if (clause.namedImports instanceof nodes_1.ImportNamespaceSpecifier) {

@@ -24,3 +27,5 @@ namespaceImport = mapStarSpecifier(context, clause.namedImports);

else if (clause.namedImports instanceof nodes_1.ImportSpecifierList) {
namedImports = clause.namedImports.specifiers.map(function (specifier) { return mapSpecifier(context, specifier); });
namedImports = clause.namedImports.specifiers.map(function (specifier) {
return mapSpecifier(context, specifier);
});
}

@@ -32,18 +37,20 @@ }

var source = mapSource(context, node.source);
return new nodes_2.ImportDeclaration(line, column, start, end, raw, defaultBinding, namespaceImport, namedImports, source);
return new nodes.ImportDeclaration(line, column, start, end, raw, defaultBinding, namespaceImport, namedImports, source);
}
else if (node instanceof nodes_1.ExportNamedDeclaration) {
if (node.clause instanceof nodes_1.ExportSpecifierList) {
var namedExports = node.clause.specifiers.map(function (specifier) { return mapSpecifier(context, specifier); });
var namedExports = node.clause.specifiers.map(function (specifier) {
return mapSpecifier(context, specifier);
});
var source = node.source ? mapSource(context, node.source) : null;
return new nodes_2.ExportBindingsDeclaration(line, column, start, end, raw, namedExports, source);
return new nodes.ExportBindingsDeclaration(line, column, start, end, raw, namedExports, source);
}
else {
var expression = mapAny_1["default"](context, node.clause);
return new nodes_2.ExportNamedDeclaration(line, column, start, end, raw, expression);
var expression = mapAny_1["default"](context, notNull_1["default"](node.clause));
return new nodes.ExportNamedDeclaration(line, column, start, end, raw, expression);
}
}
else if (node instanceof nodes_1.ExportDefaultDeclaration) {
var expression = mapAny_1["default"](context, node.clause);
return new nodes_2.ExportDefaultDeclaration(line, column, start, end, raw, expression);
var expression = mapAny_1["default"](context, notNull_1["default"](node.clause));
return new nodes.ExportDefaultDeclaration(line, column, start, end, raw, expression);
}

@@ -55,3 +62,3 @@ else if (node instanceof nodes_1.ExportAllDeclaration) {

var source = mapSource(context, node.source);
return new nodes_2.ExportAllDeclaration(line, column, start, end, raw, source);
return new nodes.ExportAllDeclaration(line, column, start, end, raw, source);
}

@@ -65,3 +72,3 @@ else {

var source = mapLiteral_1["default"](context, coffeeSource);
if (!(source instanceof nodes_2.String)) {
if (!(source instanceof nodes.String)) {
throw new Error('Expected string literal as import source.');

@@ -89,4 +96,6 @@ }

var original = mapLiteralToIdentifier(context, specifier.original);
var alias = specifier.alias ? mapLiteralToIdentifier(context, specifier.alias) : null;
return new nodes_2.ModuleSpecifier(line, column, start, end, raw, original, alias);
var alias = specifier.alias
? mapLiteralToIdentifier(context, specifier.alias)
: null;
return new nodes.ModuleSpecifier(line, column, start, end, raw, original, alias);
}

@@ -99,3 +108,3 @@ function mapLiteralToIdentifier(context, literal) {

var _a = getLocation_1["default"](context, literal), line = _a.line, column = _a.column, start = _a.start, end = _a.end, raw = _a.raw;
return new nodes_2.Identifier(line, column, start, end, raw, literal.value);
return new nodes.Identifier(line, column, start, end, raw, literal.value);
}

@@ -102,0 +111,0 @@ else {

@@ -152,5 +152,5 @@ "use strict";

function isBareYield(node) {
return node.first instanceof nodes_1.Value &&
return (node.first instanceof nodes_1.Value &&
node.first.base instanceof nodes_1.Literal &&
node.first.base.value === '';
node.first.base.value === '');
}

@@ -190,3 +190,3 @@ function mapBinaryOp(context, node, Op) {

function tokenStartsWith(prefix, context, token) {
return context.source.slice(token.start, token.start + prefix.length) === prefix;
return (context.source.slice(token.start, token.start + prefix.length) === prefix);
}

@@ -201,4 +201,8 @@ function mapNegateableBinaryOp(context, node, Op) {

var token = context.sourceTokens.tokenAtIndex(i);
if (token && (token.type === coffee_lex_1.SourceType.OPERATOR || token.type === coffee_lex_1.SourceType.RELATION)) {
isNot = tokenStartsWith('not', context, token) || tokenStartsWith('!', context, token);
if (token &&
(token.type === coffee_lex_1.SourceType.OPERATOR ||
token.type === coffee_lex_1.SourceType.RELATION)) {
isNot =
tokenStartsWith('not', context, token) ||
tokenStartsWith('!', context, token);
break;

@@ -205,0 +209,0 @@ }

@@ -16,3 +16,5 @@ "use strict";

}
var switchConditions = conditions.map(function (condition) { return mapAny_1["default"](context, condition); });
var switchConditions = conditions.map(function (condition) {
return mapAny_1["default"](context, condition);
});
var consequent = mapPossiblyEmptyBlock_1["default"](context, body);

@@ -19,0 +21,0 @@ var whenToken = getWhenTokenBeforeOffset(context, switchConditions[0].start, start);

@@ -28,3 +28,4 @@ "use strict";

startTokenIndex = startTokenIndex && startTokenIndex.next();
startToken = startTokenIndex && context.sourceTokens.tokenAtIndex(startTokenIndex);
startToken =
startTokenIndex && context.sourceTokens.tokenAtIndex(startTokenIndex);
}

@@ -43,3 +44,5 @@ if (!startToken) {

if (isPrototypeAccess) {
var AccessOp = property.soak ? nodes_2.SoakedProtoMemberAccessOp : nodes_2.ProtoMemberAccessOp;
var AccessOp = property.soak
? nodes_2.SoakedProtoMemberAccessOp
: nodes_2.ProtoMemberAccessOp;
return new AccessOp(location.line, location.column, location.start, last + 1, context.source.slice(location.start, last + 1), reduced);

@@ -57,3 +60,5 @@ }

else if (property instanceof nodes_1.Index) {
var NodeClass = property.soak ? nodes_2.SoakedDynamicMemberAccessOp : nodes_2.DynamicMemberAccessOp;
var NodeClass = property.soak
? nodes_2.SoakedDynamicMemberAccessOp
: nodes_2.DynamicMemberAccessOp;
var last = context.linesAndColumns.indexForLocation({

@@ -60,0 +65,0 @@ line: property.locationData.last_line,

@@ -233,3 +233,5 @@ "use strict";

__extends(TaggedTemplateLiteral, _super);
function TaggedTemplateLiteral(line, column, start, end, raw, tag, template) {
function TaggedTemplateLiteral(line, column, start, end, raw, tag,
// eslint-disable-next-line @typescript-eslint/ban-types
template) {
var _this = _super.call(this, 'TaggedTemplateLiteral', line, column, start, end, raw) || this;

@@ -1399,3 +1401,5 @@ _this.tag = tag;

__extends(ImportDeclaration, _super);
function ImportDeclaration(line, column, start, end, raw, defaultBinding, namespaceImport, namedImports, source) {
function ImportDeclaration(line, column, start, end, raw, defaultBinding, namespaceImport, namedImports,
// eslint-disable-next-line @typescript-eslint/ban-types
source) {
var _this = _super.call(this, 'ImportDeclaration', line, column, start, end, raw) || this;

@@ -1431,3 +1435,5 @@ _this.defaultBinding = defaultBinding;

__extends(ExportBindingsDeclaration, _super);
function ExportBindingsDeclaration(line, column, start, end, raw, namedExports, source) {
function ExportBindingsDeclaration(line, column, start, end, raw, namedExports,
// eslint-disable-next-line @typescript-eslint/ban-types
source) {
var _this = _super.call(this, 'ExportBindingsDeclaration', line, column, start, end, raw) || this;

@@ -1459,3 +1465,5 @@ _this.namedExports = namedExports;

__extends(ExportAllDeclaration, _super);
function ExportAllDeclaration(line, column, start, end, raw, source) {
function ExportAllDeclaration(line, column, start, end, raw,
// eslint-disable-next-line @typescript-eslint/ban-types
source) {
var _this = _super.call(this, 'ExportAllDeclaration', line, column, start, end, raw) || this;

@@ -1462,0 +1470,0 @@ _this.source = source;

@@ -94,5 +94,6 @@ "use strict";

var value = node[key];
if (Array.isArray(value) && value.length > 0 && value[0] instanceof nodes_1.Base) {
result[key] = value
.map(function (child) { return convertCS1NodeToCS2(child); });
if (Array.isArray(value) &&
value.length > 0 &&
value[0] instanceof nodes_1.Base) {
result[key] = value.map(function (child) { return convertCS1NodeToCS2(child); });
}

@@ -105,3 +106,5 @@ else if (key === 'cases') {

return [
switchCaseCondition.map(function (condition) { return convertCS1NodeToCS2(condition); }),
switchCaseCondition.map(function (condition) {
return convertCS1NodeToCS2(condition);
}),
convertCS1NodeToCS2(block)

@@ -111,3 +114,6 @@ ];

else {
return [convertCS1NodeToCS2(switchCaseCondition), convertCS1NodeToCS2(block)];
return [
convertCS1NodeToCS2(switchCaseCondition),
convertCS1NodeToCS2(block)
];
}

@@ -114,0 +120,0 @@ });

@@ -17,3 +17,5 @@ "use strict";

var parse = options.useCS2 ? parseCS2_1["default"] : parseCS1AsCS2_1["default"];
var sourceLex = function (s) { return coffee_lex_1["default"](s, { useCS2: options.useCS2 }); };
var sourceLex = function (s) {
return coffee_lex_1["default"](s, { useCS2: options.useCS2 });
};
var context = ParseContext_1["default"].fromSource(source, sourceLex, parse);

@@ -20,0 +22,0 @@ fixLocations_1["default"](context, context.ast);

@@ -6,5 +6,3 @@ #!/usr/bin/env node -r ts-node/register -r babel-register

var path_1 = require("path");
// TODO: Change to an import when parser is TypeScript.
// tslint:disable-next-line:no-var-requires
var parse = require('../src/parser').parse;
var parser_1 = require("../src/parser");
for (var i = 2; i < process.argv.length; i++) {

@@ -25,3 +23,3 @@ processPath(process.argv[i]);

try {
parse(content);
parser_1.parse(content);
console.log("OK " + path);

@@ -32,3 +30,6 @@ }

console.log(" " + ex.message);
console.log(ex.stack.split('\n').map(function (line) { return " " + line; }).join('\n'));
console.log(ex.stack
.split('\n')
.map(function (line) { return " " + line; })
.join('\n'));
}

@@ -35,0 +36,0 @@ }

@@ -9,2 +9,3 @@ "use strict";

var sourceRange = sourceRangeFromLocationData_1["default"](context, locationData);
// eslint-disable-next-line no-constant-condition
while (true) {

@@ -11,0 +12,0 @@ var tokens = getSurroundingParens(context, sourceRange);

"use strict";
/* eslint-disable @typescript-eslint/camelcase */
var __assign = (this && this.__assign) || function () {

@@ -19,3 +20,6 @@ __assign = Object.assign || function(t) {

var last_line = locationData.last_line, last_column = locationData.last_column;
var indexForLocation = linesAndColumns.indexForLocation({ line: last_line, column: last_column });
var indexForLocation = linesAndColumns.indexForLocation({
line: last_line,
column: last_column
});
if (indexForLocation !== null) {

@@ -27,3 +31,6 @@ return locationData;

for (;;) {
var index = linesAndColumns.indexForLocation({ line: last_line, column: last_column - offset });
var index = linesAndColumns.indexForLocation({
line: last_line,
column: last_column - offset
});
offset++;

@@ -42,3 +49,3 @@ if (index !== null) {

}
return __assign({}, locationData, { last_line: last_line,
return __assign(__assign({}, locationData), { last_line: last_line,
last_column: last_column });

@@ -45,0 +52,0 @@ }

"use strict";
/* eslint-disable @typescript-eslint/camelcase */
var __assign = (this && this.__assign) || function () {

@@ -69,7 +70,13 @@ __assign = Object.assign || function(t) {

var loc = node.locationData;
var start = linesAndColumns.indexForLocation({ line: loc.first_line, column: loc.first_column });
var start = linesAndColumns.indexForLocation({
line: loc.first_line,
column: loc.first_column
});
if (start === null) {
throw new Error('Expected to find a start index for object.');
}
var end = linesAndColumns.indexForLocation({ line: loc.last_line, column: loc.last_column });
var end = linesAndColumns.indexForLocation({
line: loc.last_line,
column: loc.last_column
});
if (end === null) {

@@ -131,3 +138,6 @@ throw new Error('Expected to find an end index for object.');

var sourceRange = sourceRangeFromLocationData_1["default"](context, node.locationData);
node.locationData = locationDataFromSourceRange_1["default"](context, { start: sourceRange.end, end: sourceRange.end });
node.locationData = locationDataFromSourceRange_1["default"](context, {
start: sourceRange.end,
end: sourceRange.end
});
}

@@ -209,3 +219,3 @@ // Blocks can sometimes end one index before their terminating semicolon

if (location) {
node.locationData = __assign({}, node.locationData, { last_line: location.line, last_column: location.column });
node.locationData = __assign(__assign({}, node.locationData), { last_line: location.line, last_column: location.column });
}

@@ -212,0 +222,0 @@ }

@@ -7,4 +7,10 @@ "use strict";

var loc = node.locationData;
var start = context.linesAndColumns.indexForLocation({ line: loc.first_line, column: loc.first_column });
var last = context.linesAndColumns.indexForLocation({ line: loc.last_line, column: loc.last_column });
var start = context.linesAndColumns.indexForLocation({
line: loc.first_line,
column: loc.first_column
});
var last = context.linesAndColumns.indexForLocation({
line: loc.last_line,
column: loc.last_column
});
if (start === null || last === null) {

@@ -37,3 +43,5 @@ throw new Error("unable to determine range for location: " + util_1.inspect(loc) + "}");

}, context.sourceTokens.indexOfTokenNearSourceIndex(index));
return tokenIndex === null ? null : context.sourceTokens.tokenAtIndex(tokenIndex);
return tokenIndex === null
? null
: context.sourceTokens.tokenAtIndex(tokenIndex);
}

@@ -47,3 +55,5 @@ exports.firstSemanticTokenAfter = firstSemanticTokenAfter;

}, context.sourceTokens.indexOfTokenNearSourceIndex(index));
return tokenIndex === null ? null : context.sourceTokens.tokenAtIndex(tokenIndex);
return tokenIndex === null
? null
: context.sourceTokens.tokenAtIndex(tokenIndex);
}

@@ -50,0 +60,0 @@ exports.firstSemanticTokenBefore = firstSemanticTokenBefore;

@@ -16,3 +16,5 @@ "use strict";

}
var operatorIndex = context.sourceTokens.indexOfTokenMatchingPredicate(function (token) { return token.type !== SourceType_1["default"].LPAREN && token.type !== SourceType_1["default"].RPAREN; }, startIndex.next(), endIndex);
var operatorIndex = context.sourceTokens.indexOfTokenMatchingPredicate(function (token) {
return token.type !== SourceType_1["default"].LPAREN && token.type !== SourceType_1["default"].RPAREN;
}, startIndex.next(), endIndex);
var operatorToken = operatorIndex && context.sourceTokens.tokenAtIndex(operatorIndex);

@@ -19,0 +21,0 @@ if (!operatorToken) {

"use strict";
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
exports.__esModule = true;

@@ -67,3 +74,3 @@ var SourceType_1 = require("coffee-lex/dist/SourceType");

}
return getElements(node.first, context).concat(getElements(node.second, context));
return __spreadArrays(getElements(node.first, context), getElements(node.second, context));
}

@@ -119,3 +126,5 @@ return [node];

}
else if (element instanceof nodes_1.Value && element.properties.length === 0 && element.base instanceof nodes_1.Literal) {
else if (element instanceof nodes_1.Value &&
element.properties.length === 0 &&
element.base instanceof nodes_1.Literal) {
literal = element.base;

@@ -152,3 +161,3 @@ }

function isTemplateLiteralStart(token) {
return [
return ([
SourceType_1["default"].DSTRING_START,

@@ -159,7 +168,7 @@ SourceType_1["default"].SSTRING_START,

SourceType_1["default"].HEREGEXP_START,
SourceType_1["default"].CSX_OPEN_TAG_END,
].indexOf(token.type) >= 0;
SourceType_1["default"].CSX_OPEN_TAG_END
].indexOf(token.type) >= 0);
}
function isTemplateLiteralEnd(token) {
return [
return ([
SourceType_1["default"].DSTRING_END,

@@ -170,4 +179,4 @@ SourceType_1["default"].SSTRING_END,

SourceType_1["default"].HEREGEXP_END,
SourceType_1["default"].CSX_CLOSE_TAG_START,
].indexOf(token.type) >= 0;
SourceType_1["default"].CSX_CLOSE_TAG_START
].indexOf(token.type) >= 0);
}

@@ -7,3 +7,4 @@ "use strict";

if (node instanceof nodes_1.Op && isComparisonOperator_1["default"](node)) {
return isComparisonOperator_1["default"](node.first) || (node.second ? isComparisonOperator_1["default"](node.second) : false);
return (isComparisonOperator_1["default"](node.first) ||
(node.second ? isComparisonOperator_1["default"](node.second) : false));
}

@@ -10,0 +11,0 @@ else {

@@ -5,4 +5,6 @@ "use strict";

function isCommentOnlyNode(base) {
return base instanceof nodes_1.Value && base.base instanceof nodes_1.PassthroughLiteral && base.base.value === '';
return (base instanceof nodes_1.Value &&
base.base instanceof nodes_1.PassthroughLiteral &&
base.base.value === '');
}
exports["default"] = isCommentOnlyNode;

@@ -19,3 +19,6 @@ "use strict";

var sourceTokens = context.sourceTokens, linesAndColumns = context.linesAndColumns;
var start = linesAndColumns.indexForLocation({ line: node.locationData.first_line, column: node.locationData.first_column });
var start = linesAndColumns.indexForLocation({
line: node.locationData.first_line,
column: node.locationData.first_column
});
if (start === null) {

@@ -22,0 +25,0 @@ return false;

@@ -28,3 +28,4 @@ "use strict";

var type = _a.type, start = _a.start, end = _a.end;
if (type === coffee_lex_1.SourceType.OPERATOR && context.source.slice(start, end) === '+') {
if (type === coffee_lex_1.SourceType.OPERATOR &&
context.source.slice(start, end) === '+') {
foundPlusToken = true;

@@ -31,0 +32,0 @@ }

"use strict";
/* eslint-disable @typescript-eslint/camelcase */
exports.__esModule = true;

@@ -3,0 +4,0 @@ function locationDataFromSourceRange(context, sourceRange) {

"use strict";
exports.__esModule = true;
function locationsEqual(first, second) {
return first.first_line === second.first_line &&
return (first.first_line === second.first_line &&
first.first_column === second.first_column &&
first.last_line === second.last_line &&
first.last_column === second.last_column;
first.last_column === second.last_column);
}
exports["default"] = locationsEqual;
"use strict";
/* eslint-disable @typescript-eslint/camelcase */
exports.__esModule = true;

@@ -3,0 +4,0 @@ function locationWithLastPosition(loc, last) {

@@ -13,4 +13,4 @@ "use strict";

var raw = context.source.slice(start, end);
return new nodes_1.Heregex(startLoc.line + 1, startLoc.column + 1, start, end, raw, quasis, unmappedExpressions.map(function (expr) { return expr ? mapAny_1["default"](context, expr) : null; }), nodes_1.RegexFlags.parse(flags));
return new nodes_1.Heregex(startLoc.line + 1, startLoc.column + 1, start, end, raw, quasis, unmappedExpressions.map(function (expr) { return (expr ? mapAny_1["default"](context, expr) : null); }), nodes_1.RegexFlags.parse(flags));
}
exports["default"] = makeHeregex;
import { Base } from 'decaffeinate-coffeescript2/lib/coffeescript/nodes';
import { String } from '../nodes';
import * as nodes from '../nodes';
import ParseContext from './ParseContext';
export default function makeString(context: ParseContext, node: Base): String;
export default function makeString(context: ParseContext, node: Base): nodes.String;
"use strict";
exports.__esModule = true;
var mapAny_1 = require("../mappers/mapAny");
var nodes_1 = require("../nodes");
var nodes = require("../nodes");
var getTemplateLiteralComponents_1 = require("./getTemplateLiteralComponents");

@@ -13,4 +13,4 @@ function makeString(context, node) {

var raw = context.source.slice(start, end);
return new nodes_1.String(startLoc.line + 1, startLoc.column + 1, start, end, raw, quasis, unmappedExpressions.map(function (expr) { return expr ? mapAny_1["default"](context, expr) : null; }));
return new nodes.String(startLoc.line + 1, startLoc.column + 1, start, end, raw, quasis, unmappedExpressions.map(function (expr) { return (expr ? mapAny_1["default"](context, expr) : null); }));
}
exports["default"] = makeString;
"use strict";
/* eslint-disable @typescript-eslint/camelcase */
exports.__esModule = true;

@@ -3,0 +4,0 @@ function mergeLocations(left, right) {

@@ -75,4 +75,10 @@ "use strict";

var locationData = locatable;
var start = this.linesAndColumns.indexForLocation({ line: locationData.first_line, column: locationData.first_column });
var end = this.linesAndColumns.indexForLocation({ line: locationData.last_line, column: locationData.last_column });
var start = this.linesAndColumns.indexForLocation({
line: locationData.first_line,
column: locationData.first_column
});
var end = this.linesAndColumns.indexForLocation({
line: locationData.last_line,
column: locationData.last_column
});
if (start === null || end === null) {

@@ -79,0 +85,0 @@ return null;

@@ -8,3 +8,4 @@ "use strict";

function parseNumber(string) {
var expressionStatement = parser_1.parse("(" + string + ")").program.body[0];
var expressionStatement = parser_1.parse("(" + string + ")").program
.body[0];
var literal = expressionStatement.expression;

@@ -11,0 +12,0 @@ return literal.value;

@@ -8,3 +8,4 @@ "use strict";

function parseRegExp(string) {
var expressionStatement = parser_1.parse("(" + string + ")").program.body[0];
var expressionStatement = parser_1.parse("(" + string + ")").program
.body[0];
var literal = expressionStatement.expression;

@@ -11,0 +12,0 @@ return literal;

@@ -8,3 +8,4 @@ "use strict";

function parseString(string) {
var expressionStatement = parser_1.parse("(" + string + ")").program.body[0];
var expressionStatement = parser_1.parse("(" + string + ")").program
.body[0];
var literal = expressionStatement.expression;

@@ -11,0 +12,0 @@ return literal.value;

"use strict";
var __spreadArrays = (this && this.__spreadArrays) || function () {
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
exports.__esModule = true;

@@ -14,7 +21,7 @@ var nodes_1 = require("decaffeinate-coffeescript2/lib/coffeescript/nodes");

}
operands = [second].concat(operands);
operands = __spreadArrays([second], operands);
link = first;
}
else {
operands = [link].concat(operands);
operands = __spreadArrays([link], operands);
break;

@@ -21,0 +28,0 @@ }

{
"name": "decaffeinate-parser",
"version": "22.5.13",
"description": "A better AST for CoffeeScript, inspired by CoffeeScriptRedux.",
"version": "22.5.12",
"main": "dist/parser.js",
"module": "dist/parser.mjs",
"types": "dist/parser.d.ts",
"scripts": {
"build": "./script/build",
"lint": "tslint --config tslint.json --project tsconfig.json",
"lint-fix": "tslint --config tslint.json --project tsconfig.json --fix",
"pretest": "yarn lint",
"test": "jest"
},
"keywords": [
"ast",
"coffeescript",
"ast",
"parse"
],
"repository": {
"type": "git",
"url": "https://github.com/decaffeinate/decaffeinate-parser.git"
},
"license": "MIT",
"author": "Brian Donovan",
"license": "MIT",
"files": [
"dist/"
],
"engines": {
"node": ">=6"
"main": "dist/parser.js",
"module": "dist/parser.mjs",
"types": "dist/parser.d.ts",
"scripts": {
"build": "./script/build",
"lint": "eslint '{src,test}/**/*.ts'",
"lint:fix": "yarn lint --fix",
"pretest": "yarn lint",
"test": "jest",
"test:ci": "jest --ci"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{ts,md,json}": [
"prettier --write",
"git add"
],
"package.json": [
"sort-package-json",
"git add"
]
},
"dependencies": {
"@babel/parser": "^7.1.6",
"coffee-lex": "^9.1.4",
"coffee-lex": "^9.1.5",
"decaffeinate-coffeescript": "1.12.7-patch.3",

@@ -44,19 +61,27 @@ "decaffeinate-coffeescript2": "2.2.1-patch.5",

"@babel/register": "^7.0.0",
"@types/jest": "^24.0.0",
"@types/node": "12.6.8",
"@types/jest": "^24.0.16",
"@types/node": "12.7.5",
"@typescript-eslint/eslint-plugin": "^2.2.0",
"@typescript-eslint/parser": "^2.2.0",
"coffee-script-redux": "^2.0.0-beta8",
"eslint": "^6.3.0",
"eslint-config-prettier": "^6.3.0",
"eslint-plugin-jest": "^22.17.0",
"eslint-plugin-prettier": "^3.1.0",
"husky": "^3.0.5",
"jest": "^24.8.0",
"lint-staged": "^9.2.5",
"prettier": "^1.18.2",
"sort-package-json": "^1.22.1",
"string-repeat": "^1.1.1",
"ts-jest": "^24.0.0",
"ts-node": "^8.0.2",
"tslint": "^5.11.0",
"typescript": "^3.0.3"
},
"engines": {
"node": ">=6"
},
"publishConfig": {
"registry": "https://registry.npmjs.org/"
},
"repository": {
"type": "git",
"url": "https://github.com/decaffeinate/decaffeinate-parser.git"
}
}

@@ -27,9 +27,9 @@ # decaffeinate-parser [![CircleCI](https://circleci.com/gh/decaffeinate/decaffeinate-parser.svg?style=svg)](https://circleci.com/gh/decaffeinate/decaffeinate-parser) [![package version](https://badge.fury.io/js/decaffeinate-parser.svg)](https://badge.fury.io/js/decaffeinate-parser)

```js
import { parse } from "decaffeinate-parser";
import { parse } from 'decaffeinate-parser';
let program = parse("add = (a, b) -> a + b");
let assignment = program.body.statements[0];
let fn = assignment.expression;
const program = parse('add = (a, b) -> a + b');
const assignment = program.body.statements[0];
const fn = assignment.expression;
console.log(fn.parameters.map(param => param.data)); // [ 'a', 'b' ]
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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