New number here!
I'm working on binding a JavaScript Node library (let's call it Mod1) to Nim, and I'm facing an issue when trying to create a new instance of the module in Nim. In JavaScript, Mod1 is used with the new operator to create a new instance, but Nim doesn't have a direct equivalent for this. Additionally, Mod1 in JavaScript expects to receive three arguments when creating a new instance, in the form of an object like this:
In Nim:
var newMod = Mod1.Module
In JavaScript
const newMod = new Mod1.Module({
X: 1.282
Y: 2.234
Z: 1.262
})
I’ve already successfully linked Mod1.Module to nim, but im stuck as to how to actually use it like in JavaScript..? Thanks in advance?Try:
proc initModule(x, y, z: float): Module {.importJs: "new Mod1.Module({X:#, Y: #, Z: #})".}