Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ucast/js

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ucast/js

git@github.com:stalniy/ucast.git

  • 3.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
569K
increased by10.11%
Maintainers
1
Weekly downloads
 
Created

What is @ucast/js?

@ucast/js is a JavaScript library for defining and evaluating conditions or rules. It is particularly useful for implementing access control, filtering data, and other scenarios where you need to evaluate conditions dynamically.

What are @ucast/js's main functionalities?

Define Conditions

This feature allows you to define conditions using a simple syntax. In this example, a condition is created to check if the 'age' field is greater than or equal to 18.

const { createCondition } = require('@ucast/js');

const condition = createCondition({
  field: 'age',
  operator: 'gte',
  value: 18
});

console.log(condition);

Evaluate Conditions

This feature allows you to evaluate conditions against data. In this example, the condition checks if the 'age' field in the data object is greater than or equal to 18, which returns true.

const { createCondition, evaluate } = require('@ucast/js');

const condition = createCondition({
  field: 'age',
  operator: 'gte',
  value: 18
});

const data = { age: 20 };
const result = evaluate(condition, data);

console.log(result); // true

Combine Conditions

This feature allows you to combine multiple conditions using logical operators like 'and' or 'or'. In this example, two conditions are combined to check if 'age' is greater than or equal to 18 and 'status' is 'active'.

const { createCondition, combineConditions, evaluate } = require('@ucast/js');

const condition1 = createCondition({
  field: 'age',
  operator: 'gte',
  value: 18
});

const condition2 = createCondition({
  field: 'status',
  operator: 'eq',
  value: 'active'
});

const combinedCondition = combineConditions('and', [condition1, condition2]);

const data = { age: 20, status: 'active' };
const result = evaluate(combinedCondition, data);

console.log(result); // true

Other packages similar to @ucast/js

Keywords

FAQs

Package last updated on 31 Jan 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc