New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@aux4/facilitator

Package Overview
Dependencies
Maintainers
0
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aux4/facilitator

Natural language as a programming language

latest
Source
npmnpm
Version
2.0.0
Version published
Maintainers
0
Created
Source

💬 facilitator

Natural language as a programming language

Installation

npm install --global facilitator

Usage

Command-line

test.txt

set "firstName" to "John"
set "lastName" to "Doe"
print "Hello {{firstName}} {{lastName}}"
facilitator execute test.txt

See all commands

Node.js

Create custom expression

import Facilitator, { install } from "facilitator";

const facilitator = new Facilitator();
install(facilitator);

facilitator.register("say hello to {firstName} {lastName}", (firstName, lastName) => {
  console.log(`Hello ${firstName} ${lastName}!`);
});

const script = `
say hello to "John" "Doe"
`;

facilitator.exec(script, { currentDate: new Date() });

Output:

Hello John Doe

Use optional variable with custom regex

To make the variable optional you can include the ? as suffix of the variable. e.g.: {count?}

By default the variables are represented by quoted text (e.g.: "value"), you can redefine the variable, the third parameter of register receives an object with the regular expression to represent the variable:

{
  count: /\d+/
}
import Facilitator, { install } from "facilitator";

const facilitator = new Facilitator();
install(facilitator);

facilitator.register("increment\\s*{count?}", (count, context) => {
  let value = context.count || parseInt(count);
  value += 1;
  context.count = value;
  console.log("increment", value);
}, {
  count: /\d+/
});

const script = `
increment 5
increment
increment
increment
increment
`;

facilitator.exec(script, {});

Output:

increment 6
increment 7
increment 8
increment 9
increment 10

Keywords

test

FAQs

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