Skip to content
David Nolen edited this page Jul 22, 2014 · 33 revisions

Which JavaScript environments does transit-js support?

transit-js supports any ECMAScript-262 Edition 3 or later implementation provided it supplies a JSON module with JSON.parse and JSON.stringify methods. With shims like JSON3 transit-js supports most web browsers released in the last 14 years. transit-js also works just fine in environments like Rhino and Nashorn on the JDK. If you encounter issues in a ECMAScript-262 Edition 3 compliant implementation please open an issue.

What kinds of values does transit-js return on read?

Where possible transit-js returns plain JavaScript values. transit-js also returns a variety of custom value types such as arbitrary precision numbers, URIs, and UUIDs - refer to this table for a full listing. In the case of map-like values, transit-js returns hash maps that largely follow the proposed ES6 Map type.

Many popular server side programming languages that need to communicate with JavaScript can represent richer forms of data than JSON can encode. By returning richer values clients and servers can coordinate without ad-hoc application code. For example, 64 bit integer ids are quite common in server applications yet many of these ids cannot be represented in JavaScript as the language only supports integer values between -2^53 and 2^53. With Transit these values may be marshalled without ad-hoc application logic and they may be used to index values in JavaScript in the same way they are in server side application code.

What are the performance characteristics of transit-js maps and sets?

Existing ES6 Map and Set shims perform poorly for lookup, update, and iteration. For many operations transit-js maps and sets are more than an order of magnitude faster than the alternatives. In some cases transit-js maps and sets approach or surpass the performance of pending native implementations. In addition the lookup semantics of transit-js maps and sets are based on value not reference which greatly generalizes their applicability.

How large of a JavaScript dependency is transit-js?

transit-js uses the Google Closure Compiler to generate the final production source. Code written for the Google Closure Compiler benefits from far more aggressive compression than is currently possible with alternatives such as Uglify. The production version of transit-js is currently 8.9K gzipped, using a tool like Uglify to compress the final source almost doubles the payload.