npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rulescribe

v0.3.6

Published

Typescript rule engine

Downloads

330

Readme

RuleScribe (Typescript rule engine)

RuleScribe is a lightweight and powerful rule engine for JavaScript and TypeScript applications. It allows you to define and execute business rules in a declarative manner, enabling agile decision-making and automation of complex logic.

Installation

You can install RuleScribe via npm:

npm install rulescribe

Usage

Define a Simple Rule

To define a simple rule using RuleScribe, follow these steps:

  1. Import the required modules:

    import { Engine, Lexer, EngineScope } from "rulescribe";
  2. Define the structure of the entity for which you're defining rules. For example, let's define a Patient type:

    type Patient = {
        name: string;
        lastVisit: number;
    }
  3. Define a method to perform an action based on the rule. For example, let's define a method to send a checkup reminder SMS to a patient:

    const sendCheckupReminderSMS = (patient: Patient) => {
        // Your business logic to send SMS goes here.
    }
  4. Write the rule:

    const rule = `
    Rule "My First Rule"
    When patient.lastVisit > 90
    Then
        sendCheckupReminderSMS(patient)
    End
    `
  5. Set up the RuleScribe engine and execute the rule:

    const scope = new EngineScope();
    scope.builtinFunction.set("sendCheckupReminderSMS", {
        func:  sendCheckupReminderSMS
    });
    
    const lexer = new Lexer(rule, scope);
    const engine = new Engine(lexer);
    
    // Define the patient
    scope.define('patient', { name: "John Doe", lastVisit: 100 });
    
    // Parse and execute the rule
    await engine.parse(scope);
    await engine.fire(scope);

This code will execute the rule "My First Rule" and send a checkup reminder SMS to the patient if their last visit was more than 90 days ago.

Documentation

For more information on how to use RuleScribe, including advanced features and usage examples, refer to the RuleScribe Wiki. Please first review the disclaimer.

Contributing

Contributions are welcome! If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request.

Support RuleScribe Development

RuleScribe is an open-source project driven by a community of passionate developers and contributors. Your support can help ensure the continued growth and improvement of RuleScribe, enabling us to deliver innovative features, maintain compatibility with the latest technologies, and provide ongoing support to users.

How You Can Help:

  1. Financial Contributions: Consider making a financial contribution to support RuleScribe development. Your donations help cover expenses such as server hosting, development tools, and community outreach efforts.

  2. Sponsorship Opportunities: Explore sponsorship opportunities to showcase your organization's commitment to open-source software and innovation. Sponsorship packages may include recognition on our website, social media shoutouts, and other promotional benefits.

  3. Contributions and Feedback: Get involved in the RuleScribe community by contributing code, reporting bugs, and providing feedback on features and enhancements. Your input helps shape the future direction of the project.

Get in Touch:

To learn more about how you can support RuleScribe development or inquire about sponsorship opportunities, please contact us at [email protected]. We appreciate your support and look forward to collaborating with you to make RuleScribe even better!

License

This project is licensed under the MIT License.