Socket
Socket
Sign inDemoInstall

unique-slug

Package Overview
Dependencies
1
Maintainers
5
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    unique-slug

Generate a unique character string suitible for use in files and URLs.


Version published
Weekly downloads
21M
increased by1.12%
Maintainers
5
Install size
14.1 kB
Created
Weekly downloads
 

Package description

What is unique-slug?

The unique-slug npm package is a simple utility for generating unique, random slugs that can be used for file names, URLs, unique identifiers, etc. It uses a combination of the current timestamp and a random string to ensure uniqueness.

What are unique-slug's main functionalities?

Generate a unique slug

This feature generates a unique slug that can be used where a unique string is needed, such as for a unique filename or URL component.

const uniqueSlug = require('unique-slug');
const slug = uniqueSlug();
console.log(slug);

Generate a unique slug with a prefix

This feature allows for the generation of a unique slug with a specified prefix, which can be useful for categorizing or identifying the type of resource the slug represents.

const uniqueSlug = require('unique-slug');
const prefix = 'img_';
const slugWithPrefix = uniqueSlug(prefix);
console.log(slugWithPrefix);

Other packages similar to unique-slug

Readme

Source

unique-slug

Generate a unique character string suitible for use in files and URLs.

var uniqueSlug = require('unique-slug')

var randomSlug = uniqueSlug()
var fileSlug = uniqueSlug('/etc/passwd')

uniqueSlug(str) → String (8 chars)

If str is passed in then the return value will be its murmur hash in hex.

If str is not passed in, it will be 4 randomly generated bytes converted into 8 hexadecimal characters.

FAQs

Last updated on 14 Oct 2022

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc