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

@flatfile/expression-lang

v0.0.3

Published

This package defines a set of functions that represent an expression language for validations. These functions allow you to create complex validation rules by combining simpler expressions.

Downloads

60

Readme

@flatfile/expression-lang

This package defines a set of functions that represent an expression language for validations. These functions allow you to create complex validation rules by combining simpler expressions.

Functions:

Mathematical Operations:

  • Add, Subtract, Mult, Div, Mod: Perform addition, subtraction, multiplication, division, and modulo operations respectively.

Comparisons:

  • GreaterThan, GT: Check if the first argument is greater than the second.
  • LessThan, LT: Check if the first argument is less than the second.
  • GreaterThanEqual, GTE: Check if the first argument is greater than or equal to the second.
  • LessThanEqual, LTE: Check if the first argument is less than or equal to the second.
  • Equal: Check if the two arguments are equal.
  • NotEqual: Check if the two arguments are not equal.
  • Between: Check if a test value is between two values.

Mathematical Functions:

  • Abs: Calculate the absolute value of a number.
  • Min: Find the minimum value among the provided arguments.
  • Max: Find the maximum value among the provided arguments.
  • Round: Round a number to the nearest integer.

Logical Functions:

  • Not: Negate a boolean value.
  • And: Check if all the provided arguments evaluate to true.
  • Or: Check if at least one of the provided arguments evaluates to true.
  • Count: Count the number of elements in the provided arguments.
  • When: Evaluate an expression if a predicate is true.
  • Unless: Evaluate an expression unless a predicate is true.

These functions are used to construct expressions in the defined expression language for validations.

makeInterpreter

makeInterpreter creates an interpreter for a custom instruction-based language. The interpreter takes instructions in the form of nested arrays and evaluates them based on a set of predefined functions (baseFns) and additional functions (extraFns) passed as an argument to makeInterpreter.

The interpreter processes the instructions recursively, evaluates function calls, handles variables, and returns the result of the interpreted instructions. The interpret function is a convenience function that creates an interpreter with an empty set of extra functions.