BinaryMuse / toml-node

TOML parser for Node.js and the Browser. Parses TOML v0.4.0
http://binarymuse.github.io/toml-node/
MIT License
306 stars 30 forks source link

Toml should not add a key which is protected or private #57

Closed supanadit closed 5 years ago

supanadit commented 5 years ago

test1 test2

I am using typescript, it should not appear on TOML after parse if the variable was Protected or Private

lazarljubenovic commented 5 years ago

The information about protected/private is not available at runtime. TypeScript only uses the class member modifiers to statically analyze your code at compile-time. After compilation is done, a private attribute on a class is no different than a public one.

supanadit commented 5 years ago

So it is impossible to hide unwanted key while parsing to TOML ?

lazarljubenovic commented 5 years ago

It doesn't have much to do with TOML, the exact same thing would happen if you'd want to serialize to JSON. Unless, of course, you're using static analysis to read the code (as opposed to execute the code in the browser or in Node environment).

To do it at run-time, you might want to check our decorators. For example, class-transformer utilizes them to perform serialization for sending and receiving data via the network.