Package Exports
- short-uuid
- short-uuid/dist/short-uuid
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (short-uuid) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
short-uuid
Generate and translate standard UUIDs into shorter - or just different - formats and back.
v3.0.0
short-uuid provides RFC4122 v4-compliant UUIDs,
thanks to uuid.
3.0.0 drops support for Node 0.10 and 0.12, as nested dependencies were updated and it breaks the build. There are no functional changes in 3.0.0 from 2.3.4.
It includes Browserify support for client-side use as proposed by voronianski,
with compiled browser-ready files in the npm package for convenience. The library is exposed as ShortUUID.
TypeScript definitions are included, thanks to alexturek.
var short = require('short-uuid');
var translator = short(); // Defaults to flickrBase58
var decimalTranslator = short("0123456789"); // Provide a specific alphabet for translation
var cookieTranslator = short(short.constants.cookieBase90); // Use a constant for translation
// Generate a shortened v4 UUID
translator.new();
// Generate plain UUIDs
short.uuid(); // From the constructor without creating a translator
translator.uuid(); // Each translator provides the uuid.v4() function
// Translate UUIDs
translator.toUUID(shortId);
translator.fromUUID(regularUUID);
// See the alphabet used by a translator
translator.alphabet;
// View the constants
short.constants.flickrBase58; // Avoids similar characters (0/O, 1/I/l, etc.)
short.constants.cookieBase90; // Safe for HTTP cookie values for smaller IDs. short-uuid is under 1K when compressed. Using Browserify, the library and dependencies are ~3.5K.
Recent Release Notes
2.3.3 fixes missing /dist folder from the npm module.
2.3.4 corrects the behavior for UUIDs with uppercase letters.
3.0.0 updates dependencies, includes a refactor for CodeClimate, and drops Node 0.x support.
Prior to 2.3.4, passing a UUID with capital letters would cause an incorrect conversion.
All UUIDs are now converted to lowercase before translation.
UUIDs generated by the uuid library were always lowercase. This was a test case miss.
Please see Revisions for information on previous versions.