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

funxion

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

funxion

Safely execute arbitrary user defined logical expressions.

  • 0.0.9
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Funxion

Safely execute arbitrary user defined logical expressions.

Usage

Before you can execute an expression, it must be parsed. This will tell you if the expression is valid and inform you of errors if applicable.

The result is a parsed version of your expression ready for execution.

NOTE: Calling parse with an invalid expression will result in an error being thrown.

const add = Funxion.parse("a + b");

To execute this expression, parse the result of the parser to the exec function, along with any context variables you want to use:

const result = Funxion.exec(add, { a: 2, b: 3 });

Variables

Pass a key value context that can be accessed in your expressions:

const example = Funxion.parse("foo * 5");
Funxion.exec(example, { foo: 2 });
// => 10

Functions

If

If accepts a boolean as its first argument, returning the second argument if it is true, and the third argument if it is false.

if(true, "Hooray!", "Awwwhh!")
// => "Hooray!"

Join

Join a set of strings together

join("Hello, ", "World!")
// => "Hello, World!"

Mean

Calculate the mean of a set of numbers

mean(2, 5, 11, 23)
// => 10.25

FAQs

Package last updated on 15 Jul 2021

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