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

minirule

v1.0.1

Published

Simple, readable business rule language for easy definition and interpretation.

Downloads

140

Readme

Minirule

Simple, readable business rule language for easy definition and interpretation.

Features

  • Readable Syntax: Minirule uses a human-friendly syntax that makes it easy to define business rules. This allows non-technical stakeholders to understand and contribute to the rule definitions.

  • Dynamic Business Terms: The library supports dynamic business terms, enabling you to define rules with terms like DISCOUNT, BONUS, and more. This flexibility allows you to adapt to changing business needs without modifying the core logic.

  • Validation and Interpretation: Minirule provides built-in validation and interpretation capabilities. You can ensure that your rules are syntactically correct and interpret them to derive actionable insights.

Getting Started

Installation

To use Minirule in your project, install it via npm:

npm install minirule
# or
yarn add minirule

Usage

Here's a quick example of how you can define and interpret a business rule using Minirule:

import { interpreter } from "minirule";

const rule = `
rule "New Customer Welcome"
when
  customer.registrationDate is between "2023-01-01" and "2023-12-31"
  and customer.orderCount < 3
  and order.total > 100
then
  apply 15% discount to order.total
end
`;

try {
  const result = interpreter.interpret(rule);
  console.log("Interpreted Rule:", result);
} catch (error) {
  console.error("Error interpreting rule:", error);
}

Playground

For a hands-on experience, visit our Minirule Playground where you can write, validate, and interpret your business rules in real-time. The playground provides an interactive environment to experiment with Minirule without any setup.

Benefits

  • No Programming Required: Minirule is designed for business users. You don't need to be a programmer to define and manage your business rules.

  • Collaboration: The readable syntax allows for easy sharing and discussion of rules among team members, even in non-technical channels like Slack.

  • Adaptability: Easily adapt to new business requirements by defining new terms and rules without changing the underlying code.

Contributing

We welcome contributions to the Minirule library! If you have ideas for improvements or new features, feel free to open an issue or submit a pull request.

Coming Soon

We will add more capability as the following:

rule "Loyal Customer Reward"

# Define reusable conditions
define long_time_customer as
  customer.registration_date < "2020-01-01"
  and customer.total_purchases > 5000

when
  long_time_customer
  and (
    customer.last_purchase not recently (3 months)
    or customer.cart_total > 1000
  )
  and customer.status in ["gold", "platinum"]
  and not customer has used promotion "COMEBACK2023"

then
  apply 20% discount to cart.total
  add 500 points to customer.loyalty_account
  send email "loyal_customer_offer" to customer.email
  mark customer as used promotion "COMEBACK2023"

end

License

Minirule is open-source software licensed under the MIT License.