L
L
lockdog2021-08-12 11:17:21
JavaScript
lockdog, 2021-08-12 11:17:21

How to parse user scripts on the site?

Good afternoon,
I saw on different sites (for example, in Node-Red) such functionality that the user can write a simple js function, where it receives data, for example, from a post request, parses it according to the algorithm in this function, and then returns the result in json.
I can't google properly. Tell me, please, in which direction to dig in order to implement this?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexandroppolus, 2021-08-12
@lockdog

As I understand it, you need to turn the text entered by the user into a function.
https://learn.javascript.ru/new-function
I somehow did something like this for fun - ksp.herokuapp.com/rline (you can set the function for calculating the coordinates of each new step of the snake, see what happened and meditate). Right there through new Function

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question