Writing this as a proof of concept to get some feedback. (my take on #44)
This approach is intended to be backward compatible with existing system.
When dealing with int64* family, it checks whether the option jstype is set.
If set to JS_STRING, it returns a string and parses a string.
If set to JS_NUMBER, it returns a BigInt and parses a BigInt.
API wise, if we don't want to introduce BigInt in the index.js (to maintain compatibility with older browser without the need to ship polyfills), we could:
Move the newly added logic from index.js to a separate file (jstype.js), and have that file inject the functions to Pbf. The user would need to import 'pbf' and 'pbf/jstype' for this to work.
Alternatively, we could write the code that inject the functions to Pbf in the generated file, if it uses the feature.
Let me know if you're ok with this approach / feature, so that I can polish it / write tests.
Writing this as a proof of concept to get some feedback. (my take on #44)
This approach is intended to be backward compatible with existing system. When dealing with int64* family, it checks whether the option jstype is set. If set to JS_STRING, it returns a string and parses a string. If set to JS_NUMBER, it returns a BigInt and parses a BigInt.
API wise, if we don't want to introduce BigInt in the index.js (to maintain compatibility with older browser without the need to ship polyfills), we could:
Let me know if you're ok with this approach / feature, so that I can polish it / write tests.