Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass function as a parameter #17

Open
Wansmer opened this issue Oct 30, 2021 · 1 comment
Open

Pass function as a parameter #17

Wansmer opened this issue Oct 30, 2021 · 1 comment

Comments

@Wansmer
Copy link
Contributor

Wansmer commented Oct 30, 2021

Is your feature request related to a problem? Please describe.

Now methods of modules can work with with primitives and objects only, bun no with a functions.

Code below throw Error, because postMessage no work with function:

(async () => {
  const res = await module1.method1(x => x ** x);
  console.log({ res });
})();

Describe the solution you'd like

There an idea of implementation with vm: https://github.com/Wansmer/noroutine/pull/1

But there is open questions:

  1. Is a good approach to create new sandbox for every higher order function?
  2. Is need disable modules like os and fs for safety or user must make decision himself? (set flags in options or generate and pass own context, for example);
  3. If 'dangerous' code not expected (from end user), maybe eval in this case will be better and lighter solution instead vm.Script?
@vk0novalov
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants