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

nearley

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nearley - npm Package Compare versions

Comparing version 2.7.8 to 2.7.9

www/quick-compiler.html

5

lib/nearley.js

@@ -72,4 +72,5 @@ (function () {

if (!(this.data === Parser.fail)) {
var findLeo;
// LEO THE LION SAYS GER
function findLeo(idx, rulename, finalData) {
findLeo = function findLeo(idx, rulename, finalData) {
// performance optimization, avoid high order functions(map/filter) in hotspot code.

@@ -101,3 +102,3 @@ var items = [];

}
}
};

@@ -104,0 +105,0 @@ var leo = findLeo(this.reference, this.rule.name, this.data);

2

package.json
{
"name": "nearley",
"version": "2.7.8",
"version": "2.7.9",
"description": "Simple, fast, powerful parser toolkit for JavaScript.",

@@ -5,0 +5,0 @@ "main": "lib/nearley.js",

window.addEventListener("load", function() {
var grammarInput = document.getElementById("grammar-input");
var testInput = document.getElementById("test-input");
var compileInput = document.getElementById("compile-grammar");

@@ -10,69 +9,7 @@ compileInput.addEventListener("click", function() {

var result = parser.results[0];
visualizeAST(result);
var compiled = Compile(result);
var compiled = Compile(result, {});
var js = generate(compiled);
window.open("data:text/javascript;charset=utf-8,"+encodeURIComponent(js));
console.log(js);
}, false);
function uniquegen() {
return "$" + uniquegen.$++;
}
uniquegen.$ = 0;
function buildAST(cy, obj) {
var id = uniquegen();
cy.add({
group: 'nodes',
data: {id: id, val: typeof(obj) === 'object' ? '' : JSON.stringify(obj)}
});
if (typeof(obj) === 'object') {
for (var i in obj) {
if (obj.hasOwnProperty(i)) {
var o = obj[i];
var n = buildAST(cy, o);
cy.add({
group: 'edges',
data: {source: id, target: n, val: i}
});
}
}
}
return id;
}
var oldcy = null;
function visualizeAST(AST) {
if (oldcy) {
oldcy.destroy();
}
var container = document.createElement("div");
container.style.height = "700px";
document.getElementById("cy-viz").appendChild(container);
oldcy = cytoscape({
container: container,
elements: {
nodes: [
],
edges: [
]
},
layout: {
name: 'breadthfirst'
},
style: [{
selector: 'node',
css: {
'content': 'data(val)'
}
}, {
selector: 'edge',
css: {
'target-arrow-shape': 'triangle',
'content': 'data(val)'
}
}]
});
buildAST(oldcy, AST);
}
}, false);
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