Socket
Socket
Sign inDemoInstall

compar

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    compar

An easy way to decouple rules from code, and it is ideal for creating custom engines for experiments, feature flags, tutorials, etc.


Version published
Maintainers
1
Install size
127 kB
Created

Readme

Source

Compar

Extensible declarative rule matching engine

Compar provides an easy way to decouple rules from code, and it is ideal for creating custom engines for experiments, feature flags, tutorials, etc. Compar is written in TypeScript and it runs in the browser, or on the server using node.js.

Setup

yarn add compar

or

npm install --save compar

Usage

Before you start import the library

import { create } from "compar";
Basic usage
const match = create();

match(
  [
    "&",
    [".", "environment", ["|", ["=", "stage"], ["=", "production"]]],
    [
      ".",
      "userId",
      [
        "|",
        ["=", "45654800-7a3a-4273-b1cb-4eace4086cce"],
        ["=", "5137c85d-a4d0-4d6c-8d85-0a74a24007c8"],
      ],
    ],
  ],
  {
    environment: "stage",
    userId: "45654800-7a3a-4273-b1cb-4eace4086cce",
  },
);

License

MIT

Keywords

FAQs

Last updated on 29 Jun 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc