{"library":"logic-query-parser","title":"Logic Query Parser","description":"The `logic-query-parser` package provides a JavaScript utility for parsing logic search strings into a binary tree representation. It takes a query string, supports `AND`, `OR`, parentheses, and double quotes, and can be configured with custom space characters and a default operator. Additionally, it offers a utility function to convert the binary tree into a more usable JSON query form, simplifying programmatic interpretation. This package is currently at version 0.0.5 and was last published approximately 7 years ago, indicating it is no longer actively maintained. Its primary use case is to transform human-readable logical expressions into a structured data format suitable for backend search or filtering operations.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install logic-query-parser"],"cli":null},"imports":["const parser = require('logic-query-parser');","const parser = require('logic-query-parser');\nconst binaryTree = parser.parse('hello AND world');","const parser = require('logic-query-parser');\nconst query = parser.utils.binaryTreeToQueryJson(someBinaryTree);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const parser = require('logic-query-parser');\n\n// Parse a complex logic query string into a binary tree\nconst binaryTree = parser.parse('(welcome OR bye) AND (hello OR ahoy)');\n\nconsole.log('--- Binary Tree Structure ---');\nconsole.log(JSON.stringify(binaryTree, null, 2));\n\n// Convert the binary tree to a more usable JSON query form\nconst query = parser.utils.binaryTreeToQueryJson(binaryTree);\n\nconsole.log('\\n--- Converted Query Form ---');\nconsole.log(JSON.stringify(query, null, 2));\n\n// Example with options: custom spaces and default operator\nconst customParser = require('logic-query-parser');\nconst options = {\n  spaces: [' ', '\\t', '-'], // Allow hyphen as a space character\n  defaultOperator: 'or' // Use OR by default\n};\nconst customBinaryTree = customParser.parse(options, 'apple banana -orange');\n\nconsole.log('\\n--- Custom Options Example (Binary Tree) ---');\nconsole.log(JSON.stringify(customBinaryTree, null, 2));","lang":"javascript","description":"This quickstart demonstrates parsing a complex logic query into a binary tree and then converting it to a simplified JSON query structure, also showing how to use custom parsing options.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}