JSPM

  • Created
  • Published
  • Downloads 407354
  • Score
    100M100P100Q182752F
  • License MIT

Create and translate standard UUIDs with shorter formats.

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

Build Status Code Climate Test Coverage Dependencies

Generate and translate standard UUIDs into shorter - or just different - formats and back.

v2.1.1

2.1.0 adds Browserify config to support client-side use as proposed by voronianski. 2.1.1 includes compiled browser-ready files in the npm package for convenience. The library is exposed as ShortUUID.

short-uuid provides RFC4122 v4-compliant UUIDs, thanks to node-uuid.

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;
short.constants.cookieBase90;

v2.1.0 is under 1K when compressed. Using Browserify, the library and dependencies are less than 5K.

Please see Revisions for information on previous versions.