Questions tagged [jint]
Jint is a JavaScript interpreter for .NET.
117
questions
0
votes
0
answers
80
views
How to get a local variable value (inside a function) with Jint?
In C# and using Jint, how can I get value of a local defined variable in a JavaScript function?
For example, I have the following JavaScript code in the string "testStr".
And I can't modify ...
0
votes
0
answers
99
views
Create chart on canvas in JINT in c#
Thanks in advance..
I am creating a pdf from html using iText7 and in that html I am creating a chart on canvas with chart.js. All these are in memory in c# service where I can not use Chrome or any ...
1
vote
0
answers
69
views
Dynamically create JavaScript source code using Jint in C#
I am working on a project where it requires to parse large numbers of .js files and programmatically update JavaScript code and save it to the same location from where it is loaded.
Is this possible ...
0
votes
0
answers
69
views
programmatically create JavaScript and save it to .js file using Jint in C#
I am working on a project where it requires to parse large numbers of .js files and programmatically update JavaScript code and save it to the same location from where it is loaded.
Is this possible ...
0
votes
0
answers
168
views
Pausing execution of a Jint engine without using multithreading
I have several Jint engines running different scripts. Sometimes I need to pause their execution and resume it later. My solution at the moment is to run each engine in its own thread and then use ...
5
votes
1
answer
120
views
RavenDB ETL to SQL, how to store entire document ('this') in jsonb column?
In RavenDB 5.4+, I want to configure a SQL ETL task that offloads data to a PostgreSQL database, using Npgsql built-in factory for Raven. The issue I have is that I want the entire document (this) ...
0
votes
1
answer
438
views
Is there a Valid way to run node modules from C# Class
Is there a Valid way to run node modules from C# Class ?
There are some options which I know
Use JS/TS to execute node module and host it in node API. Call that node API from c#.
Use command prompt/...
2
votes
3
answers
237
views
Deserializing embedded array/list to array in c# as expandoobject
I have JSON objects having embedded arrays - with no predefined strongly typed class to deserialize to. ExpandoObject deserialization with Json.Net works, but the array is deserialized to list, which ...
0
votes
0
answers
36
views
Converting ES6 code to ES5 with Webpack and Babel to use it with Jint [duplicate]
I want to convert and pack ES6 javascript code to ES5 with Webpack and Babel to use it with Jint.
This is my example ES6 code (index.js) :
const hello = () => {
return "Hello from JS ES6 ...
0
votes
1
answer
137
views
Can source generators be used instead of JINT?
We are exploring JINT and we were able to map a runtime custom javascript with C# methods. However, I was just being curious, can this same be achieved using a .net 6 source generators ? For instance, ...
1
vote
0
answers
123
views
Executing user's supplied Javascript code with two-way callbacks between .NET and Javascript in MAUI
I have an old Winforms app that loads a user's Javascript file with predefined function names and then calls those functions from C# code at specific events. Also, there are some Javascript methods ...
0
votes
1
answer
523
views
Pass js object to C# function
I'm trying out Jint and want to implement the fetch api to use from js. The second argument is a nested js object that is passed in:
fetch('https://example.com', {
method: 'post',
headers : {
...
4
votes
3
answers
895
views
How do I return a value from a C# function using jint?
I'm currently using Jint (https://github.com/sebastienros/jint) to process JavaScript.
I would like to be able to use a custom function in JavaScript that will execute a function created in C# and ...
0
votes
1
answer
267
views
Implementing require in the absence of node
Modules generally start something like this
(function(root, factory)
{
/* globals define */
if (typeof define === 'function' && define.amd)
{
// AMD. Register as an ...
0
votes
1
answer
128
views
Editing .js with Jint
I am trying to edit the below javascript with jint. I really only want to edit var antiCapthaPredefinedApiKey = ''; and set the proxy settings in defaultConfig while at runtime. I have a winforms, I ...
0
votes
1
answer
747
views
Jint. How to set property of class, or invoke method, of class?
With Jint how can I set a property (or invoke a method) of an instance of a javascript class?
e.g. if I do:
var o = new Jint.Engine().Evaluate(@"
class MyClass {
constructor() {
this....
1
vote
0
answers
216
views
XMLHttpRequest (XHR) for Jint
I am working on a program (C# with .Net Core 3.1) that needs to be extended with javascript. These javascripts need to be able to send web requests.
Since I like the implementation of Jint (https://...
1
vote
0
answers
156
views
What is the range of classes included in AllowClr()?
I have set "AllowClr()" to access classes in a .NET assembly, but I cannot access some classes.
What is the range of classes included in "AllowClr()" ?
static void TestA()
{
...
3
votes
1
answer
2k
views
Pass an object to a function in jint and return a value
I'm attempting to pass an object to a javascript function via jint and return a value. But it doesn't seem to work. Here is what I have tried so far -
Error -
Jint.Runtime.JavaScriptException: 'obj is ...
2
votes
0
answers
1k
views
JINT performance is significantly worse when an application is run as a 64bit application
The application requires JS support (the program is written in C#) and JINT is being used as the interpreter. I have noticed how performance significantly degrades when the application is run as a ...
0
votes
1
answer
628
views
Parsing and evaluating complex objects using JInt
I have a requirement to evaluate certain expressions, and based on the evaluation choose the next steps.
I am trying to use JInt javscript interpreter for this.
For basic evaluations from json, it is ...
1
vote
0
answers
282
views
Accessing JSON array items from Javascript returned from C# using Jint
I am trying to communicate back and forth between C# and Javascript, using Jint. Mostly smooth sailing, however I am unable to access items in arrays returned from C# within my JS scripts. Accessing ...
0
votes
1
answer
500
views
Jint: using CLR object 's properties in Javascript functions
I have been testing the jint library and hit a snag. Given this class in C#:
public class Foo
{
public string Name { get; } = "Bar";
}
And this code:
Engine engine = new Engine(x => ...
2
votes
2
answers
519
views
C# non-static class inside static class JINT
Hi trying to make a class inside a static class to use in JINT but when it's referenced I get an error
C# code
namespace Hi {
public static class Ok {
public class Wowa {
...
-1
votes
1
answer
78
views
GetCompletionValue with IIFE trigger errors
I get a exception if I try to use GetCompletionValue with Invoker.
How can i execute the run function with IIFE lexical scope?
Javascript:
(function(){
function run() {
logger('teste logger');
...
1
vote
1
answer
462
views
Jint (.NET javascript parser) always returns ExpandoObject
I try to write a mod for a game. This is totally new territory for me, so I might be on the wrong track here.
The game is written in Unity and you are able to add a .script file to your mod. The ....
0
votes
0
answers
274
views
How to evaluate datetime expression in JSON File?
I have Json File like below:
{
"Country": "QAT",
"Rules": "if(BO.SenderCountryId == 'QAT' && BO.SenderIdExpiryDate < DateTime.Today....
0
votes
0
answers
223
views
Jint.Parser.JavaScriptParser: Distinguishing top-level identifiers
I am trying to detect all global variables referenced by a JavaScript code snippet using Jint.Parser.JavaScriptParser. I'm doing this by following the code example from this issue to retrieve a list ...
2
votes
0
answers
357
views
C# - Jint Generic Methods
I am new to using Jint (the Javascript Interpreter for .NET) and am trying to gain a better understanding of the complete functionality. Looking at the documentation, I see support of Generic types ...
1
vote
0
answers
171
views
Using moment.js with jint
I would like to use moment.js with jint. I have tried several alternatives, but always end up with this error:
Self referencing loop detected for property 'Engine' with type 'Jint.Engine'. Path '...
1
vote
0
answers
730
views
Serialize "JsValue" in Jint
At the moment, I'm trying to figure out how to save a Jint.NET JavaScript environment to file, so I can load it again later.
However, I'm having major trouble trying to serialize/deserialize the Jint....
0
votes
1
answer
382
views
Is there a way to switch environments while using Jint.NET?
I'm currently using the Jint.NET JavaScript console engine for C#, and I'm attempting to emulate separate JavaScript environments that the user can switch between.
However, I don't want to create an ...
0
votes
2
answers
356
views
Convert std:set<int> into jintArray
I'm provided a std::set<int> object that I need to convert/copy into a jintArray to return to an Android app. I tried the code below, but it seems to be crashing my app with only this as a clue:...
2
votes
1
answer
207
views
Attach VSCode Debugger for Typescript/Javascript Debugging to a C# Winforms Application
In my C# WinForms application I execute javascript with jint. The javascript code is the result code of my transpiled typescript file. I use inline source mapping.
Now I want to give the users of my ...
6
votes
0
answers
270
views
IActiveScriptParse32::ParseScriptText Memory Leak
Has anybody ever faced a memory leak problem with IActiveScriptParse32::ParseScriptText when using it in C#?
I need a ScriptEngine that is able to parse JavaScript-Code. (Everything works fine, except ...
2
votes
0
answers
414
views
Using a delegate to handle a Javascript callback in JINT
In the following code using JINT, the call to the Setup1 method works and the call to Setup2 method does not. The call to Setup2 raises the error: Jint.Runtime.JavaScriptException: 'No public methods ...
0
votes
0
answers
623
views
JINT convert Dictionary<String, Object> to JSON string
I'm using PowerUI and Unity (+Jint built in to powerUI) to attempt to read JSON data coming in from the JavaScript code side, on the C# side. For example, I have some JavaScript code (coming into ...
0
votes
0
answers
109
views
Is there a way to select a task that is not currently running from a list of tasks?
I have some code currently that is calling a method on an object in excess of 1,000,000 times. This code section currently takes about 2minutes to run. This method also has a lock within it that ...
0
votes
0
answers
160
views
Is there a way in Jint to store a function to a Func?
I am using Jint to dynamically run functions for my C# code. It works perfectly for running the functions. However the execution time is linear per execution
var engine = new Jint.Engine();
var rule =...
-1
votes
1
answer
103
views
Add multiple formula arguments
I have a Javascript formula saved in Database as a string and want to calculate it using JINT in C#.
The formula has multiple variables and need to set them with their values.
int height = 10
int ...
0
votes
1
answer
568
views
How do I print complete element arrays in Jint - like you can with Javascript?
I'm trying to access a Javascript array through Jint. We're basically accepting custom javascript code in an application that works across a variety of platforms and are using Jint for .NET. We need ...
0
votes
1
answer
373
views
Jint "unexpected reserved word"
I am using the Jint interpreter for C# Jint
I want to run the following JavaScript code.
class User {
constructor(name) { this.name = name; }
sayHi() { alert(this.name); }
}
...
But I always ...
2
votes
0
answers
225
views
Is it possible to clone or save/restore engine state in Jint?
I've got relatively long initial code and then I use the engine to execute a single statement which can affect engine state. I would like to speed things up by not re-executing initial code all the ...
0
votes
1
answer
1k
views
Reading JSON objects from javascript file using JINT
I've been supplied with a javascript file containing two JSON objects such as this.
var languages = {"Languages":["English","Cymraeg","Deutsch"]};
var labels = [{"$JOB":["Job","Orchwyl","Auftrag",]},{...
3
votes
0
answers
209
views
How do I serialize/deserialize Jint engine into string/file
Would it be possible to serialize Jint JS engine into a string or a file, and deserialize and load it at a later point? if this is not possible with Jint, is it possible with any other .NET JavaScript ...
0
votes
1
answer
457
views
How can I use underscore functions in Jint
I'm using Jint for executing javascript in my c# project and I need to access functions like map, filter, reduce etc on an Array.
From what I've been able to find here, the native array functions are ...
5
votes
1
answer
2k
views
JInt require another js file
I am looking a way to include another js file natively in JInt (javascript interpreter for C# Unity). I understand that I can simple concatenate all my js files to one string and run it via normal way....
0
votes
1
answer
2k
views
JINT-How to catch exception in CatchClrExceptions in JINT?
I want to catch the clr exceptions thrown from javascript. Below things i have tried.
var registerScript = new Engine(c => c.AllowClr(typeof(Manager).Assembly ).CatchClrExceptions(ExceptionHandler(...
2
votes
1
answer
726
views
Getting "document is not defined" error when checking for valid jQuery code though JInt?
Is it possible to check if a JQuery string has a valid syntax? I've tried Jint because of this Determine whether a string contains valid javascript code. Unfortunately, it seems as if this is meant ...
0
votes
1
answer
858
views
Reading a value from a List<Employee> in Jint
A general question first: Is there somewhere a documentation about jint? I was not able to find anything apart from the examples on the github page.
I'm trying to do something like the sample below ...