Giter Site home page Giter Site logo

josh-tracey / exprimo Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 88 KB

Exprimo is a JavaScript expression evaluator written in Rust.

Home Page: https://crates.io/crates/exprimo

License: MIT License

Rust 99.40% Shell 0.35% JavaScript 0.25%
expression-evaluator rust memory-safety javascript-expressions blazingly-fast rust-javascript-eval

exprimo's Introduction

Exprimo

CAUTION: Beware of Sneaky Bugs in the Early Project Stages! There will be bug, probably alot at first :D

Exprimo is a JavaScript evaluator written in Rust, inspired by the functionality of angular-expressions. Designed to be simple and blazingly fast.

Description

Exprimo parses and evaluates JavaScript expressions efficiently and securely. It utilizes the power of Rust and its excellent memory safety guarantees to provide a reliable and fast JavaScript expression evaluator.

Installation

Before you can use Exprimo, you need to have Rust installed on your system. If you don't have it installed, you can download Rust from the official website here.

Once Rust is installed, you can install Exprimo by running:

cargo add exprimo

Trace logging to console can be added to the package, it is by default disabled as probably don't need it unless working on it, or need to debug AST error if required.

This will install Scribe Rust and will need LOG_LEVEL=TRACE in environment variables for logs to output.

exprimo = { version = "*", features = ["logging"]

Usage

First, you need to import Exprimo and create an instance of Evaluator:

use exprimo::Evaluator;
use std::collections::HashMap;

let mut context = HashMap::new();
context.insert("a".to_string(), serde_json::Value::Bool(true));        
context.insert("b".to_string(), serde_json::Value::Bool(false));

let evaluator = Evaluator::new(context);

Then, you can evaluate JavaScript expressions:

let result = evaluator.evaluate("a && b").unwrap();
println!("The result is {}", result);

//--outputs
// >The result is false

Examples

Running examples

LOG_LEVEL=TRACE cargo run --features "logging" --example basic

Contributing

Contributions to Exprimo are welcome! Please submit a pull request on GitHub.

License

Exprimo is licensed under the MIT license. Please see the LICENSE file in the GitHub repository for more information.

exprimo's People

Contributors

josh-tracey avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.