Looks like it is not really feasible or very tricky still I’ll take a try.
How to describe a structure (Object/class) that ought to represent a fluent (non predefined) structure config node (i.e. could have properties whatever user might put here)
Still the Node representation should have under the hood custom functional implementation for standard Object handling i.e. toString
, valueOf
, toJSON
.
So could these three (and maybe some other useful stuff would be needed earlier) be implemented on some Symbols level or other non publicly enumerable properties basis so that properties would be available for the data content it self?
E.g. config structure could be available for the user to input as
configRoot:
fluentSubSection:
somProp: 12
valueOf: John Doe
toString: whatever
so that the user shouldn’t be restricted with any reserver words for properties
Still the config representation structure it self would be as well in natural way as
const config = loadConfig('...')
console.log(config.configRoot.fluentSubSection.valueOf)
// John Doe - plain content data access
Still the ConfigNode instance it self should have some custom functionality under the hood as
console.log(String(config.configRoot.fluentSubSection))
// Should switch to some functional level access for toString
// E.g. [Custom ConfigNode - somProp: 12; valueOf: John Doe]
Digging both Symbols and Proxies looks isn’t of much help here to split functional and content representation here.
Anyway please any ideas are appreciated.
Thx