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

homunculus

Package Overview
Dependencies
Maintainers
2
Versions
164
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

homunculus - npm Package Compare versions

Comparing version 0.2.5 to 0.2.6-1

32

dist/parser/es6/Parser.js

@@ -53,2 +53,3 @@ (function(factory) {

this.hasMoveLine = false;
this.module = false;
this.tree = {};

@@ -74,11 +75,6 @@ if(lexer) {

node.add(this.modulebody());
//未出现export时,此script不是一个模块
var leaves = node.leaf(0).leaves();
for(i = 0; i < leaves.length; i++) {
if(leaves[i].name() == Node.EXPORTDECL) {
return node;
}
//未出现module,import,export时,此script不是一个模块
if(!this.module) {
node.leaf(0).name(Node.SCRIPTBODY);
}
node.leaf(0).name(Node.SCRIPTBODY);
return node;
}

@@ -96,8 +92,11 @@ return node;

if(this.look.content() == 'module') {
this.module = true;
return this.moduleimport();
}
else if(this.look.content() == 'import') {
this.module = true;
return this.importdecl();
}
else if(this.look.content() == 'export') {
this.module = true;
return this.exportdecl();

@@ -117,4 +116,3 @@ }

node.add(
this.match(),
this.match(';')
this.match()
);

@@ -125,6 +123,6 @@ }

this.importcaulse(),
this.fromcaulse(),
this.match(';')
this.fromcaulse()
);
}
node.add(this.match(';'));
return node;

@@ -137,3 +135,4 @@ },

this.bindid(),
this.fromcaulse()
this.fromcaulse(),
this.match(';')
);

@@ -2010,6 +2009,3 @@ return node;

}
if(['get', 'set'].indexOf(this.look.content()) > -1) {
node.add(this.method(noIn, noOf));
}
else if(this.look.content() == '[') {
if(this.look.content() == '[') {
var cmpt = this.cmptpropt(noIn, noOf);

@@ -2038,3 +2034,3 @@ if(!this.look) {

if(!S[next.type()]) {
if(next.content() == '(') {
if([Token.KEYWORD, Token.ID].indexOf(next.type()) > -1 || next.content() == '(') {
node.add(this.method(noIn, noOf));

@@ -2041,0 +2037,0 @@ end = true;

{
"name": "homunculus",
"version": "0.2.5",
"version": "0.2.6-1",
"description": "A lexer&parser by Javascript",

@@ -5,0 +5,0 @@ "maintainers": [

@@ -45,2 +45,3 @@ var IParser = require('../Parser');

this.hasMoveLine = false;
this.module = false;
this.tree = {};

@@ -66,11 +67,6 @@ if(lexer) {

node.add(this.modulebody());
//未出现export时,此script不是一个模块
var leaves = node.leaf(0).leaves();
for(i = 0; i < leaves.length; i++) {
if(leaves[i].name() == Node.EXPORTDECL) {
return node;
}
//未出现module,import,export时,此script不是一个模块
if(!this.module) {
node.leaf(0).name(Node.SCRIPTBODY);
}
node.leaf(0).name(Node.SCRIPTBODY);
return node;
}

@@ -88,8 +84,11 @@ return node;

if(this.look.content() == 'module') {
this.module = true;
return this.moduleimport();
}
else if(this.look.content() == 'import') {
this.module = true;
return this.importdecl();
}
else if(this.look.content() == 'export') {
this.module = true;
return this.exportdecl();

@@ -109,4 +108,3 @@ }

node.add(
this.match(),
this.match(';')
this.match()
);

@@ -117,6 +115,6 @@ }

this.importcaulse(),
this.fromcaulse(),
this.match(';')
this.fromcaulse()
);
}
node.add(this.match(';'));
return node;

@@ -129,3 +127,4 @@ },

this.bindid(),
this.fromcaulse()
this.fromcaulse(),
this.match(';')
);

@@ -2002,6 +2001,3 @@ return node;

}
if(['get', 'set'].indexOf(this.look.content()) > -1) {
node.add(this.method(noIn, noOf));
}
else if(this.look.content() == '[') {
if(this.look.content() == '[') {
var cmpt = this.cmptpropt(noIn, noOf);

@@ -2030,3 +2026,3 @@ if(!this.look) {

if(!S[next.type()]) {
if(next.content() == '(') {
if([Token.KEYWORD, Token.ID].indexOf(next.type()) > -1 || next.content() == '(') {
node.add(this.method(noIn, noOf));

@@ -2033,0 +2029,0 @@ end = true;

@@ -338,2 +338,7 @@ var homunculus = require('../');

});
it('get be an property', function() {
var parser = homunculus.getParser('js');
var node = parser.parse('var o = {get:1}');
expect(tree(node)).to.eql([JsNode.PROGRAM,[JsNode.VARSTMT,["var",JsNode.VARDECL,["o",JsNode.ASSIGN,["=",JsNode.PRMREXPR,[JsNode.OBJLTR,["{",JsNode.PROPTASSIGN,["get",":",JsNode.PRMREXPR,["1"]],"}"]]]]]]]);
});
it('getter error 1', function() {

@@ -363,2 +368,8 @@ var parser = homunculus.getParser('js');

});
it('getter error 5', function() {
var parser = homunculus.getParser('js');
expect(function() {
parser.parse('var o = {get 3(){}}');
}).to.throwError();
});
it('setter', function() {

@@ -369,2 +380,7 @@ var parser = homunculus.getParser('js');

});
it('set be an property', function() {
var parser = homunculus.getParser('js');
var node = parser.parse('var o = {set:1}');
expect(tree(node)).to.eql([JsNode.PROGRAM,[JsNode.VARSTMT,["var",JsNode.VARDECL,["o",JsNode.ASSIGN,["=",JsNode.PRMREXPR,[JsNode.OBJLTR,["{",JsNode.PROPTASSIGN,["set",":",JsNode.PRMREXPR,["1"]],"}"]]]]]]]);
});
it('setter error 1', function() {

@@ -391,2 +407,8 @@ var parser = homunculus.getParser('js');

expect(function() {
parser.parse('var o = {set 4}');
}).to.throwError();
});
it('setter error 5', function() {
var parser = homunculus.getParser('js');
expect(function() {
parser.parse('var o = {set a(){}}');

@@ -393,0 +415,0 @@ }).to.throwError();

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