string-to-function

Package for convert string to function without use eval

Usage no npm install needed!

<script type="module">
  import stringToFunction from 'https://cdn.skypack.dev/string-to-function';
</script>

README

This package was created for avoid to use "eval" in javascript when you need to convert function string to in-memory function.

Use example:

var stringToFunction = require('string-to-function');
var sum = stringToFunction('function sum(a, b){ return a+b; }');
var result = sum(1, 1);
// result === 2