https://github.com/npm/unique-slug
Generate a unique character string suitible for use in files and URLs.
https://github.com/npm/unique-slug
npm-cli
Last synced: about 1 year ago
JSON representation
Generate a unique character string suitible for use in files and URLs.
- Host: GitHub
- URL: https://github.com/npm/unique-slug
- Owner: npm
- License: isc
- Created: 2015-05-07T22:25:03.000Z (about 11 years ago)
- Default Branch: main
- Last Pushed: 2025-04-28T18:58:19.000Z (about 1 year ago)
- Last Synced: 2025-05-03T07:11:50.045Z (about 1 year ago)
- Topics: npm-cli
- Language: JavaScript
- Homepage:
- Size: 217 KB
- Stars: 35
- Watchers: 12
- Forks: 10
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
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.