-
Notifications
You must be signed in to change notification settings - Fork 31
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.
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.
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.
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.