Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

shift-parser

Package Overview
Dependencies
Maintainers
4
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shift-parser - npm Package Compare versions

Comparing version 5.0.7 to 5.2.0

52

dist/index.js

@@ -10,2 +10,4 @@ 'use strict';

var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
var _tokenizer = require('./tokenizer');

@@ -36,2 +38,4 @@

var _utils = require('./utils');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -68,2 +72,3 @@

_this.locations = new WeakMap();
_this.comments = [];
return _this;

@@ -92,2 +97,47 @@ }

}
}, {
key: 'skipSingleLineComment',
value: function skipSingleLineComment(offset) {
// We're actually extending the *tokenizer*, here.
var start = {
line: this.line + 1,
column: this.index - this.lineStart,
offset: this.index
};
var c = this.source[this.index];
var type = c === '/' ? 'SingleLine' : c === '<' ? 'HTMLOpen' : 'HTMLClose';
_get(ParserWithLocation.prototype.__proto__ || Object.getPrototypeOf(ParserWithLocation.prototype), 'skipSingleLineComment', this).call(this, offset);
var end = {
line: this.line + 1,
column: this.index - this.lineStart,
offset: this.index
};
var trailingLineTerminatorCharacters = this.source[this.index - 2] === '\r' ? 2 : (0, _utils.isLineTerminator)(this.source.charCodeAt(this.index - 1)) ? 1 : 0;
var text = this.source.substring(start.offset + offset, end.offset - trailingLineTerminatorCharacters);
this.comments.push({ text: text, type: type, start: start, end: end });
}
}, {
key: 'skipMultiLineComment',
value: function skipMultiLineComment() {
var start = {
line: this.line + 1,
column: this.index - this.lineStart,
offset: this.index
};
var type = 'MultiLine';
_get(ParserWithLocation.prototype.__proto__ || Object.getPrototypeOf(ParserWithLocation.prototype), 'skipMultiLineComment', this).call(this);
var end = {
line: this.line + 1,
column: this.index - this.lineStart,
offset: this.index
};
var text = this.source.substring(start.offset + 2, end.offset - 2);
this.comments.push({ text: text, type: type, start: start, end: end });
}
}]);

@@ -144,3 +194,3 @@

}
return { tree: tree, locations: parser.locations };
return { tree: tree, locations: parser.locations, comments: parser.comments };
};

@@ -147,0 +197,0 @@ }

4

package.json
{
"name": "shift-parser",
"version": "5.0.7",
"version": "5.2.0",
"description": "ECMAScript parser that produces a Shift format AST",
"author": "Shape Security Labs",
"author": "Shape Security",
"homepage": "https://github.com/shapesecurity/shift-parser-js",

@@ -7,0 +7,0 @@ "repository": {

@@ -50,5 +50,6 @@ Shift Parser

let {parseScriptWithLocation, parseModuleWithLocation} = require("shift-parser");
let {tree, locations} = parseScriptWithLocation("2 + 3");
let {tree, locations, commentSpans} = parseScriptWithLocation("2 + 3 /* = 5 */");
let threeNode = tree.statements[0].expression.right;
locations.get(threeNode); // { start: { line: 1, column: 4, offset: 4 }, end: { line: 1, column: 5, offset: 5 } }
commentSpans; // [ [ { line: 1, column: 6, offset: 6 }, { line: 1, column: 15, offset: 15 } ] ]
```

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