Socket
Socket
Sign inDemoInstall

unique-slug

Package Overview
Dependencies
1
Maintainers
5
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Protect your apps from supply chain attacks

Install

unique-slug

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

    4.0.0latest
    GitHub
    npm

Version published
Maintainers
5
Weekly downloads
20,590,977
increased by3.65%

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

Changelog

Source

4.0.0 (2022-10-10)

⚠️ BREAKING CHANGES

  • unique-slug is now compatible with the following semver range for node: ^14.17.0 || ^16.13.0 || >=18.0.0

Features

  • 81375b9 #29 postinstall for dependabot template-oss PR (@lukekarrys)

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 installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the 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