Hello, I’m still not familiar with ReasonML and Bucklescript. I want to bind csv-stringify library.
In Javascript:
const stringify = require(“csv-stringify”);
const fs = require(“fs”);
let data = [];
let columns = {
id: “id”,
name: “Name”
};
for (var i = 0; i < 10; i++) {
data.push([i, "Name " + i]);
}
stringify(data, { header: true, columns: columns }, (err, output) => {
if (!err) {
fs.writeFile(“my.csv”, output, err => {
if (!err) {
console.log(“ok”);
}
});
}
});
I tried to bind it like this:
[@bs.module “csv-stringify”]
external stringify: 'a => unit = “stringify”;
But it’s throwing error like this:
TypeError: CsvStringify.stringify is not a function
at Object. (/Users/silverbullet/Documents/Projects/Contracts/Landslides/Project/reason-csv-writer/src/Index.bs.js:20:14)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
Would you like to help me with binding this?