Closed kriskowal closed 4 years ago
cc @KeitaMoromizato for their contributions, for review.
cc @dbousque for the change to the async filesystem API necessary to facilitate alternate encodings.
If the encoding
argument to model.fs.load
is required (looks like it is), I guess we should update the documentation in the Non filesystem and asynchronous source loading
part.
Having slept on this change, I think it might make more sense to just treat all IDL as UTF-8 and not make the encoding configurable. That would avoid any possible confusion between Thrift compilers provided they converge on UTF-8, which is the only sensible direction up from ASCII today, if we have a prayer of having inter-language interoperability.
This change replaces the default encoding for Thrift IDL files to UTF-8 for parity with ThriftRW-Go. As UTF-8 is a strict superset of ASCII, this is a backward-compatible change. This change also introduces an encoding option to the Thrift constructor and Thrift.load function, and the setting applies through transitive includes.
The change has ramifications for the new asynchronous loader, Thrift.load, which requires a file system implementation that implements
readFile(path, encoding, cb)
instead ofreadFile(path, cb)
, but was not previously released. The Node.jsfs
module satisfies this contract just as well, but this change would have broken any user that provided a less sophisticated filesystem shim.Fixes #151