fundefstr

0.0.2 • Public • Published

fundefstr

Function Definition String

Usage

import { compile } from 'fundefstr';

const exec = compile({
  func_1(params, next, back){
    return [params[0], params[1]]; // as same as: next([params[0], params[1]])
  },

  func_2([ value, counter ], next, back){
    if (counter < 10)
      back([value, counter + 1]);
    else
      next([value, counter]);
  },

  func_3(params, next, back){
    return params;
  }
});

const str = 'func_1,func_2,func_3:param_1,param_2';
const rel = await exec(str, { param_1: 'This is a param', param_2: 0 });

console.log(rel); // ['This is a param', 10]

Package Sidebar

Install

npm i fundefstr

Weekly Downloads

0

Version

0.0.2

License

MIT

Unpacked Size

4.96 kB

Total Files

6

Last publish

Collaborators

  • anhhao.me
  • haova