Socket
Socket
Sign inDemoInstall

short-uuid

Package Overview
Dependencies
2
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    short-uuid

Create and translate standard UUIDs with shorter formats.


Version published
Weekly downloads
278K
increased by0.08%
Maintainers
1
Install size
76.3 kB
Created
Weekly downloads
 

Package description

What is short-uuid?

The short-uuid npm package is a utility for generating and working with short, URL-friendly UUIDs. It provides a way to encode and decode UUIDs into shorter formats, making them more suitable for use in URLs, database keys, and other contexts where a shorter identifier is beneficial.

What are short-uuid's main functionalities?

Generate Short UUID

This feature allows you to generate a new short UUID. The `short()` function creates a new translator instance, and `translator.new()` generates a new short UUID.

const short = require('short-uuid');
const translator = short();
const shortUUID = translator.new();
console.log(shortUUID);

Translate UUID to Short UUID

This feature allows you to convert a standard UUID to a short UUID. The `translator.fromUUID(uuid)` method takes a standard UUID and returns its shorter version.

const short = require('short-uuid');
const translator = short();
const uuid = '123e4567-e89b-12d3-a456-426614174000';
const shortUUID = translator.fromUUID(uuid);
console.log(shortUUID);

Translate Short UUID to UUID

This feature allows you to convert a short UUID back to a standard UUID. The `translator.toUUID(shortUUID)` method takes a short UUID and returns the original standard UUID.

const short = require('short-uuid');
const translator = short();
const shortUUID = 'SOME_SHORT_UUID';
const uuid = translator.toUUID(shortUUID);
console.log(uuid);

Custom Alphabet

This feature allows you to create a translator with a custom alphabet. The `short('0123456789abcdef')` function creates a new translator instance that uses the specified alphabet for encoding.

const short = require('short-uuid');
const customTranslator = short('0123456789abcdef');
const shortUUID = customTranslator.new();
console.log(shortUUID);

Other packages similar to short-uuid

Changelog

Source

[2.1.0] - 2016-11-06

Added

  • Add browser support with Browserify as proposed by voronianski
  • Include grunt-mkdir to support build process
  • Include grunt-browserify to support build process
  • Include grunt-contrib-uglify to support build process
  • Add example/index.html for Browserify demo
  • Add various dotfiles for CodeClimate configs

Changed

  • Add to [gruntfile.js] for new modules
  • Add to [package.json] for build command
  • Add dist folder to [.gitignore]
  • Update [revisions.md]
  • Update [README.md] with Browserify details

Readme

Source

short-uuid

Build Status Code Climate Test Coverage Dependencies

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

v2.1.0

2.1 adds Browserify config to support client-side use. 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.

Keywords

FAQs

Last updated on 06 Nov 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc