Compact, portable, nearly complete implementation of ECMAScript 2020
Questions tagged [quickjs]
14 questions
2
votes
0 answers
Quickjs -- Running code on Promise completion or rejection
I am using quickjs js engine. As a part of my requirments, I wanted to create a Promise and do certain actions when its resolved or rejected. (Basically do set then and catch functions).
I know promise is created as such:
JSValue…

Anurag Vohra
- 1,781
- 12
- 28
1
vote
2 answers
registering callback functions in embedded quickjs project
so I've had a look online and can't really find much. I was hoping someone might have experience setting up a .registerCallback() method in an embedded quickjs project.
the type of use would be like this in the script:
import {Class} from…

sh93
- 11
- 2
1
vote
1 answer
How to turn off the garbage collection in QuickJS?
I want to implement a new garbage collector (mark & sweep), but there are too many dup/free bits and pieces all over the code。I think I should turn off first then think about other things. This is my first time working in this field and…

rosty
- 11
- 1
1
vote
1 answer
In Quickjs what is proper way to capture a string in a struct
I have struct like this:
struct EventState{
std::string type;
};
I set this structure in constrctor of a class like this
eventState->type=JS_ToCString(ctx, argv[0]);
This line seems to cause memoery loss issues, as my valgrind complains 6 bytes…

Anurag Vohra
- 1,781
- 12
- 28
1
vote
0 answers
Is it possible to call JavaScript functions from C using QuickJS?
Let's say I have a JavaScript file containing multiple functions like this:
function a(input){
return [input,input*2]
}
function b(input){
return {
message:`Hello, ${input}!`
}
}
Is it possible to use QuickJS to call these…

Daveman
- 1,075
- 9
- 26
1
vote
1 answer
QuickJS -- Getting segfault when trying to run script
I'm new to QuickJS, and I'm trying to make a basic program that loads and runs a script.
Here's the snippet of code that loads and runs the script:
auto jsr = shared_ptr(JS_NewRuntime(), JS_FreeRuntime);
for (auto &f :…

JvJ
- 112
- 3
1
vote
1 answer
Translate javascript modules
I was trying to run some NodeJS code using QickJS and NectarJS, and I stumble in an old question I have, how to import modules.
In special, qjs -m loads ES6 modules, and expect import export statements,, instead of require, and writing…

Bob
- 13,867
- 1
- 5
- 27
1
vote
1 answer
Use QuickJS to modify preferences and global variables
I am interested in using QuickJS to modify preferences in a C++ app. So, there is a preference variable called
int myPref = 0
I want to expose this as a JS variable called
jsPref
Then the user can modify this directly via JS using
jsPref = 1
This…

moi
- 467
- 4
- 19
0
votes
1 answer
QuickJS Translate a Module Created with JS to C and Use it as a Builtin Module
I read this article: Writing native modules in C for QuickJS engine
.
But I can write the module faster and easier with JS. After creating the module, I can use import:
import myModule from "./myModule.js";
But I don't want to move the module…

Cemal Gönültaş
- 21
- 1
- 6
0
votes
0 answers
Why does JSString use JSRefcountHeader instead of JSGCObjectHeader as a field in QuickJS?
Please, this is very important for me to understand the memory management aspect.
I want to change the structure of the JSString to fit other objects, but I don't know what effect this will have, or precisely what method to use to determine if it…

rosty
- 11
- 1
0
votes
0 answers
Is it possible to call CommonJS module functions from C using QuickJS?
Note, this is different than this question, which only concerns functions and not module functions.
I have a module I have built by converting a NodeJS script to a CommonJS module using esbuild. I'd like to access the functions within that module…

ijustlovemath
- 703
- 10
- 21
0
votes
1 answer
`unsigned __int128` for Visual Studio 2019
I am trying to compile QuickJS, which is normally developed under linux and gcc has no problem with such code. However, I have troubles to compile this on Visual Studio 2019:
typedef unsigned __int128 uint128_t;
Does anyone know a trick to make…

kungfooman
- 4,473
- 1
- 44
- 33
0
votes
1 answer
QuickJS: Possible memory leak due to modifying function prototype
I've encountered what seems like a bug in the QuickJS JavaScript engine. I've submitted a GitHub issue, but am also asking here to see if it might be user error, and/or to find out if others have encountered similar issues.
The following test…

scg
- 449
- 1
- 3
- 11
-1
votes
1 answer
quickJS documentation and/or well commented projects
I am porting an in-house system from Duktape to quickJS to take advantage of the support for ES6 features and good module support (including dynamic imports).
Have ported some simple class libraries to be imported as shared object modules. But…

CyberFonic
- 3,957
- 1
- 21
- 21