genepi
genepi copied to clipboard
feature idea: GENEPI_ENUM
Unless an issue is discovered, it seems valid to represent a c++ enum in JS as Object<string, number>. This may accord well with genepi's higher level abstraction over node-addon-api.
I have created a macro for this purpose, which could be used like:
enum Color { red, green, blue };
GENEPI_ENUM(Color, red, green, blue);
NAMED_GENEPI_ENUM(Color, COOLER, red, green, blue);
const { Color, COOLER } = require(binding)
Color.blue // => 2
COOLER.blue // => 2
I am sharing this here in case it is of interest as a future feature of genepi.