swiss-army-eval

1.0.0 • Public • Published

swiss-army-eval

Evaluate code from different languages and return JS objects. More versatile and slightly gentler than JavaScript's eval.

Usage

# Command:                                            # Output:
compile('coffee', '2 + -1')                           # 1
compile("coffee", "(a, b) -> a + b")                  # function(a, b) {return a + b;}
compile("coffee", "(a, b) -> a + b")(2, -1)           # 1

compile('js', "5 - 3")                                # 2
compile("js", "function(a, b) {return a - b;}")       # function(a, b) {return a - b;}
compile("js", "function(a, b) {return a - b;}")(5, 3) # 2

compile("regex", "^[123]+$", "ig")                    # /^[123]+$/gi
compile("regex", "^[123]+$", "ig").exec('3')          # 3

About

Package Sidebar

Install

npm i swiss-army-eval

Weekly Downloads

3

Version

1.0.0

License

MIT

Last publish

Collaborators

  • justinmorgan