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

abstract-syntax-tree

Package Overview
Dependencies
Maintainers
2
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

abstract-syntax-tree - npm Package Compare versions

Comparing version 2.6.1 to 2.6.2

3

package.json
{
"name": "abstract-syntax-tree",
"version": "2.6.1",
"version": "2.6.2",
"description": "abstract syntax tree",

@@ -40,3 +40,2 @@ "main": "index.js",

"astring": "^1.3.0",
"comparify": "^0.2.0",
"esquery": "^1.0.1",

@@ -43,0 +42,0 @@ "estemplate": "^0.5.1",

@@ -1,5 +0,44 @@

const comparify = require('comparify')
function getKey (object, key) {
if (typeof object[key] !== 'undefined') return object[key]
module.exports = function equal (node1, node2) {
return comparify(node1, node2)
key = ('' + key).split('.')
for (let i = 0; i < key.length; i++) {
object = object[key[i]]
if (typeof object === 'undefined') return
}
return object
};
function isPlainObject (object) {
return Object.prototype.toString.call(object) === '[object Object]'
}
function compare (node, criterias) {
for (const key in criterias) {
if (Object.prototype.hasOwnProperty.call(criterias, key)) {
const value1 = getKey(node, key)
const value2 = getKey(criterias, key)
if ({}.toString.call(value2) === '[object RegExp]') {
if (!value2.test(value1)) return false
} else if (isPlainObject(value2)) {
if (!compare(value1, value2)) return false
} else if (Array.isArray(value2) && Array.isArray(value1)) {
for (let i = value2.length - 1; i >= 0; i--) {
if (value1.indexOf(value2[i]) < 0) return false
}
} else if (Array.isArray(value2)) {
return false
} else if (Array.isArray(value1)) {
if (value1.indexOf(value2) < 0) return false
} else {
if (value1 !== value2) return false
}
}
}
return true
};
module.exports = function equal (node, criterias) {
return compare(node, criterias)
}
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