Amatino JS 0.0.13 Released

A new version of the Amatino Node.js library is now available. 0.0.13 addresses a big issue that has plagued previous Amatino JS versions, and fixes one other nasty bug:

  • Decode large integers as BigInt rather than hacking them into String
  • Encode Date month properly (previously the previous month was encoded)

When it comes to large integers, JavaScript is a bit of a minefield. Until BigInt came along, JS had no native way of dealing with integers larger than 53 bits.

Internally, the Amatino API only thinks in 64-bit integers and arbitrary-precision numbers. Floats & lower-width integers are absent.

These 64-bit integers flow out into the public domain as IDs of various objects. For example, Session IDs and User IDs are random 64-bit integers. If your Entity is extremely large, you might also encounter them as IDs for Transactions.

It is therefore critical that any Amatino client library be able to understand 64-bit integers. So what to do with JavaScript, whose native number type is 53 bits wide? At first, Amatino JS translated them to String, and sent them back to the API as JSON Strings. This was a huge, awful hack involving a flakey Regular Expression.

Surprise surprise, this caused problems for customers. We are very sorry for that. 0.0.13 solves the problem by taking advantage of the “new” native BigInt type. BigInts arrived in Google V8 version 6.7, have been available in Node since version 10.4.

Consequently, Node.js 10.4 is now the minimum required version for a project that includes Amatino JS.

Because JavaScript wants to be a constant barrel of laughs, the native JSON library cannot serialise or deserialise BigInt. We therefore owe big thanks to Andrey Sidorov, whose MIT licensed json-bigint project we adapted to handle the relevant JSON operations.

Installation & Usage

You can install Amatino JS via NPM. For more information about NPM, check out npmjs.com.

$ npm install amatino

Amatino classes may then be accessed by requiring Amatino:

const Amatino = require('Amatino'); Amatino.Transaction.create(...);

If you already have Amatino JS installed, you can update it by executing:

$ npm update Amatino

Take care – This operation may not update the Amatino version number in package.json. You may need to change that manually.