Yeast is a unique id generator. It has been primarily designed to generate a
unique id which can be used for cache busting. A common practice for this is
to use a timestamp, but there are couple of downsides when using timestamps.
The timestamp is already 13 chars long. This might not matter for 1 request
but if you make hundreds of them this quickly adds up in bandwidth and
It's not unique enough. If you generate two stamps right after each other,
they would be identical because the timing accuracy is limited to
Yeast solves both of these issues by:
Compressing the generated timestamp using a custom encode() function that
returns a string representation of the number.
Seeding the id in case of collision (when the id is identical to the previous
To keep the strings unique it will use the . char to separate the generated
stamp from the seed.
The module is intended to be used in browsers as well as in Node.js and is
therefore released in the npm registry and can be installed using:
npm install--save yeast
All the examples assume that this library is initialized as follow: