New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

filtrex

Package Overview
Dependencies
Maintainers
2
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

filtrex

A simple, safe, JavaScript Filter Expression compiler for end-users

  • 3.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
215K
increased by16.75%
Maintainers
2
Weekly downloads
 
Created

What is filtrex?

Filtrex is a simple, safe, JavaScript expression engine for end-user programming. It allows you to evaluate expressions in a safe and controlled manner, making it useful for filtering, sorting, and evaluating data based on user-defined criteria.

What are filtrex's main functionalities?

Basic Expression Evaluation

Filtrex can evaluate basic mathematical expressions. In this example, it evaluates the expression '2 + 2' and returns the result.

const filtrex = require('filtrex');
const expression = filtrex('2 + 2');
console.log(expression()); // Outputs: 4

Filtering Data

Filtrex can be used to filter data based on user-defined criteria. In this example, it filters an array of objects to include only those where the age is greater than 28.

const filtrex = require('filtrex');
const data = [{name: 'Alice', age: 30}, {name: 'Bob', age: 25}];
const filter = filtrex('age > 28');
const filteredData = data.filter(filter);
console.log(filteredData); // Outputs: [{name: 'Alice', age: 30}]

Custom Functions

Filtrex allows you to define custom functions that can be used in expressions. In this example, a custom function 'isEven' is defined to check if a number is even, and it is used to filter the data.

const filtrex = require('filtrex');
const customFunctions = { isEven: (x) => x % 2 === 0 };
const expression = filtrex('isEven(age)', customFunctions);
const data = [{name: 'Alice', age: 30}, {name: 'Bob', age: 25}];
const filteredData = data.filter(expression);
console.log(filteredData); // Outputs: [{name: 'Alice', age: 30}]

Other packages similar to filtrex

FAQs

Package last updated on 14 Oct 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