William Chargin abbc024cbf
util: add uuid module (#1914)
Summary:
A new utility module defines an opaque UUID type. Clients can generate
random UUIDs and convert them to and from strings.

We roll our own module here rather than using the `uuid` NPM module
because that module only exposes the 32-character hyphen-separated
string form of UUID, which takes up nearly 50% more space. The usual
approach these days is to use fixed-length base64 strings without
padding. For instance, [YouTube video IDs are of this form][yt].

This module takes care not to generate IDs that might confuse
command-line argument parsers, and tries not to generate IDs that might
contain English curse words. The implementation uses isomorphic
libraries for RNG and base64 conversion because the relevant Node and
browser APIs are not aligned.

[yt]: https://webapps.stackexchange.com/a/101153

Test Plan:
Unit tests included, with full coverage.

wchargin-branch: util-uuid
2020-07-02 12:29:27 -07:00
..
2020-07-02 12:29:27 -07:00