Skip to main content

Function: model2js

model2js(model, params?, log?): Promise<string | undefined>

Converts a model into equivalent JavaScript code. The result is human readable.


NameTypeDefault valueDescription
modelModelundefinedThe model to be exported.
params?ParametersundefinedThe parameters to pass to the solver (they are mostly unused).
logundefined | WritableStreamprocess.stdoutThe stream to which the solver output should be redirected.


Promise<string | undefined>

A string containing the model in JavaScript format.


This function is experimental and the result is not guaranteed to be valid.

The result of this function can be stored in a file and executed using Node.js. It is meant as a way to export a model to a format that is executable, human readable, editable and independent of other libraries.

In case of an error this function returns a rejected promise.