New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

clarity-pattern-parser

Package Overview
Dependencies
Maintainers
1
Versions
190
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clarity-pattern-parser - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

lib/tests/FilterNodes.js

18

lib/ast/CompositeNode.js

@@ -58,2 +58,20 @@ "use strict";

}, {
key: "filter",
value: function filter(isMatch) {
var context = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
var childrenContext = context.slice();
childrenContext.push(this);
Object.freeze(childrenContext);
var matches = this.children.reduce(function (acc, child) {
return acc.concat(child.filter(isMatch, childrenContext));
}, []);
var match = isMatch(this, context);
if (match) {
matches.push(this);
}
return matches;
}
}, {
key: "toString",

@@ -60,0 +78,0 @@ value: function toString() {

@@ -31,2 +31,7 @@ "use strict";

_createClass(Node, [{
key: "filter",
value: function filter() {
throw new Error("Not Implemented Exception: expected subclass to override this method.");
}
}, {
key: "clone",

@@ -36,2 +41,7 @@ value: function clone() {

}
}, {
key: "toString",
value: function toString() {
throw new Error("Not Implemented Exception: expected subclass to override this method.");
}
}]);

@@ -38,0 +48,0 @@

@@ -55,2 +55,13 @@ "use strict";

}, {
key: "filter",
value: function filter(isMatch, context) {
var match = isMatch(this, context);
if (match) {
return [this];
}
return [];
}
}, {
key: "toString",

@@ -57,0 +68,0 @@ value: function toString() {

2

package.json
{
"name": "clarity-pattern-parser",
"type": "module",
"version": "2.0.3",
"version": "2.0.4",
"description": "",

@@ -6,0 +6,0 @@ "main": "./lib/index.js",

@@ -10,3 +10,8 @@ import Node from "./Node.js";

clone() {
const node = new CompositeNode(this.type, this.name, this.startIndex, this.endIndex);
const node = new CompositeNode(
this.type,
this.name,
this.startIndex,
this.endIndex
);
node.children = this.children.map(child => {

@@ -19,5 +24,24 @@ return child.clone();

toString(){
return this.children.map(child=>child.toString()).join("");
filter(isMatch, context = []) {
const childrenContext = context.slice();
childrenContext.push(this);
Object.freeze(childrenContext);
const matches = this.children.reduce((acc, child) => {
return acc.concat(child.filter(isMatch, childrenContext));
}, []);
const match = isMatch(this, context);
if (match) {
matches.push(this);
}
return matches;
}
toString() {
return this.children.map(child => child.toString()).join("");
}
}

@@ -18,2 +18,6 @@ export default class Node {

filter(){
throw new Error("Not Implemented Exception: expected subclass to override this method.");
}
clone() {

@@ -24,2 +28,8 @@ throw new Error(

}
toString() {
throw new Error(
"Not Implemented Exception: expected subclass to override this method."
);
}
}

@@ -13,2 +13,12 @@ import Node from "./Node.js";

filter(isMatch, context){
const match = isMatch(this, context);
if (match){
return [this];
}
return [];
}
toString(){

@@ -15,0 +25,0 @@ return this.value;

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

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