[quickjs-devel] Re: Fw: Retrieving an exported function

  • From: Petter Strandmark <petter.strandmark@xxxxxxxxx>
  • To: quickjs-devel@xxxxxxxxxxxxx
  • Date: Mon, 27 Jan 2020 14:44:05 +0100

Thanks!

Yes, I meant retrieving and calling the function via the C API. I should
have been clearer about this.

Cheers,
Petter

On Mon, Jan 27, 2020 at 8:27 AM Guido Grassel <guido.grassel@xxxxxxxxxx>
wrote:


Hi!


Since QJS can not mix modules with 'global' JS (see the mode param of
JS_Eval) see earlier emails about this topic), your other JS would need to
be a module as well. Hence, you will simply import f to your other module:


import f from './myModule.js'


Having said this, I would still want QJS to gain this feature.


Regards

- Guido




------------------------------
*From:* quickjs-devel-bounce@xxxxxxxxxxxxx <
quickjs-devel-bounce@xxxxxxxxxxxxx> on behalf of Petter Strandmark <
petter.strandmark@xxxxxxxxx>
*Sent:* 26 January 2020 21:23
*To:* quickjs-devel@xxxxxxxxxxxxx
*Subject:* [quickjs-devel] Retrieving an exported function

Hi all,

If I run the following code as a module in a context:


export function f() { return 42; }


how can I later retrieve and call f? If I do this it works:

export function f() { return 42; }

globalThis.f = f;

but is there any other way?

Cheers,
Petter Strandmark

Other related posts: