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

js-to-json-logic

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-to-json-logic - npm Package Compare versions

Comparing version 0.0.3 to 0.0.4

43

lib/index.js
const { parse } = require('@babel/parser')
const { default: traverse } = require('@babel/traverse')

@@ -42,2 +41,16 @@ const processOp = (operator) => {

switch (node.type) {
case 'File': {
return processNode(node.program)
}
case 'Program': {
if (node.directives.length > 0) {
return node.directives.length > 1
? processError(node, 'Only one expression statement allowed.')
: processNode(node.directives[0])
}
return node.body.length > 1
? processError(node, 'Block statements can only have one expression statement.')
: processNode(node.body[0])
}
case 'TemplateLiteral': {

@@ -246,29 +259,3 @@ const nodes = []

try {
let result
traverse(
parse(
code,
{
strictMode: true
}
),
{
Program (path) {
if (path.node.directives.length > 0) {
result = path.node.directives.length > 1
? processError(path.node, 'Only one expression statement allowed.')
: processNode(path.node.directives[0])
return
}
result = path.node.body.length > 1
? processError(path.node, 'Block statements can only have one expression statement.')
: processNode(path.node.body[0])
}
}
)
return result
return processNode(parse(code, { strictMode: true }))
} catch (e) {

@@ -275,0 +262,0 @@ return processError({

{
"name": "js-to-json-logic",
"version": "0.0.3",
"version": "0.0.4",
"description": "Generate JSON Logic objects using JavaScript syntax.",

@@ -18,5 +18,3 @@ "main": "lib/index.js",

"dependencies": {
"@babel/parser": "^7.7.7",
"@babel/traverse": "^7.7.4",
"json-logic-js": "^1.2.2"
"@babel/parser": "^7.7.7"
},

@@ -23,0 +21,0 @@ "devDependencies": {

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