I have another question.
How to import a js module?
An "ReferenceError: could not load module" error occurred,when i execute
hello_module.js which is in QuickJS source code examples folder. I don't
how to import a js module.
hello_module.js :
1. import { fib } from "./fib_module.js";
2. console.log("Hello World");
3. console.log("fib(10)=", fib(10));
fib_module.js :
1. export function fib(n)
2. {
3. if (n <= 0)
4. return 0;
5. else if (n == 1)
6. return 1;
7. else
8. return fib(n - 1) + fib(n - 2);
9. }
I execute hello_module.js with JS_EVAL_TYPE_MODULE
Sam Chang <dmarc-noreply@xxxxxxxxxxxxx> 于2019年8月1日周四 下午12:10写道:
I think you are looking for JS_Call
Implementation 1:
https://github.com/quickjs-ios/quickjs-ios/blob/464b2501e37dd749f6c1db16af73b9d2e36e7bee/QuickJS-iOS/Classes/QJSContext.m#L127
TestCase 1:
https://github.com/quickjs-ios/quickjs-ios/blob/464b2501e37dd749f6c1db16af73b9d2e36e7bee/QuickJS-iOSTests/QuickJS_iOSTests.m#L194
Implementation 2:
https://github.com/quickjs-ios/quickjs-ios/blob/464b2501e37dd749f6c1db16af73b9d2e36e7bee/QuickJS-iOS/Classes/QJSContext.m#L220
TestCase 2:
https://github.com/quickjs-ios/quickjs-ios/blob/464b2501e37dd749f6c1db16af73b9d2e36e7bee/QuickJS-iOSTests/QuickJS_iOSTests.m#L243
On Aug 1, 2019, at 12:00 PM, wenyang wu <wenyoung.wu@xxxxxxxxx> wrote:
Hi,
JS:
let func = new Function ([arg1, arg2, ...argN], functionBody);
I want to use QuickJS C API to new a Function with js script code.
But I don't know which API is suitable
Regards,
Young