/ live.thehmm.nl / back / node_modules / @ucast / core /

[ICO]NameLast modifiedSizeDescription
[PARENTDIR]Parent Directory  -  
[DIR]dist/2 years ago -  
[   ]LICENSE40 years ago9.9K 
[   ]NOTICE40 years ago584  
[TXT]README.md40 years ago2.5Kd7c1522 post receive test [كارل مبارك]
[   ]package.json2 years ago3.5K 
README.md

Universal Conditions AST

@ucast/core NPM version UCAST join the chat

This package contains classes and functions that helps to create parsers, conditions AST, interpreters and translators.

Installation

npm i @ucast/core
# or
yarn add @ucast/core
# or
pnpm add @ucast/core

Getting Started

Parser

Parser is a function that translates conditions from any language into conditions AST. For example, MongoQueryParser parses MongoQuery into AST which then can be interpreted by JavaScriptInterpreter that returns a boolean value based on passed in object.

Conditions AST

Abstract Syntax Tree of any condition. What is condition? x > 4 is a condition, x === 4 is a condition as well, { x: { $eq: 4 } } is a MongoQuery condition.

There are few types of AST nodes that allow us to represent any condition:

Interpreter

An interpreter is a function that interprets conditions AST in a specific way. For example, it can:

Translator

Combines Parser and Interpreter and returns a factory function:

const parse = (query) => /* to conditions AST */
const interpreter = createInterpreter({ /* condition interpreters */ });
const translate = (query, ...args) => interpreter.bind(null, parse(query));

Want to help?

Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on guidelines for contributing

License

Apache License, Version 2.0

Apache/2.4.38 (Debian) Server at www.karls.computer Port 80