Socket
Book a DemoInstallSign in
Socket

@ark7/vee

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ark7/vee

VEE (Value Evaluation Expression) is a lightweight and flexible expression evaluation engine designed for JSON-based data structures. With VEE, you can define custom expressions that evaluate results by feeding in JSON values, making it easy to implement

1.0.7
latest
npmnpm
Version published
Maintainers
1
Created
Source

VEE

VEE (Value Evaluation Expression) is a lightweight and flexible expression evaluation engine designed for JSON-based data structures. With VEE, you can define custom expressions that evaluate results by feeding in JSON values, making it easy to implement dynamic logic, filtering, and data transformation within your applications.

Introduction

Number Expression

vee('{{10+20*30}}')({}) === '610';

Value Extraction

vee('{{foo.bar}}')({
  variables: { foo: { bar: 'result' } },
}) === 'result';

vee('{{foo["bar"]}}')({
  variables: { foo: { bar: 'result' } },
}) === 'result';

Function Expression

vee('{{fn("yoo","shi")}}')({
  variables: {
    fn: (...names: string[]) => 'Hello ' + names.join(', ') + '.',
  },
}) === 'Hello yoo, shi.';

Pipe Function Expression

vee('{{"yoo"|fn:"shi"}}')({
  variables: {
    fn: (...names: string[]) => 'Hello ' + names.join(', ') + '.',
  },
}) === 'Hello yoo, shi.';

Builtin Functions

upper()

It can convert the value to upper case.

vee('{{"hello"|upper}}')().should.be.equals('HELLO');
vee('{{123|upper}}')().should.be.equals('123');

Set Globals

global functions

It can set global functions for convenient.

SetupVee({
  functions: {
    globalFoo: (val: string) => `bar(${val})`,
  },
});

vee('Name {{date|globalFoo}} DONE', { log })({
  variables: { date: 'Jan 1, 2000' },
}).should.be.equals('Name bar(Jan 1, 2000) DONE');

FAQs

Package last updated on 25 Sep 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

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.