Gathering detailed insights and metrics for space-slug
Gathering detailed insights and metrics for space-slug
Gathering detailed insights and metrics for space-slug
Gathering detailed insights and metrics for space-slug
dashify
Convert a camelcase or space-separated string to a dash-separated string. ~12 sloc, fast, supports diacritics.
simple-slug
slug lib to replace punctuation marks that browsers could not translate nicely, such as space
url-slug-match
Convert a dot/underscore/space separated string to string with hyphen and lower case. Good for SEO.
slugification
Transform string into slug. Replaces spaces and special characters.
🐌 Generate unique slugs like `wonderful-jabba` or `hyperspace-4812` using a customizable api with zero dependencies.
npm install space-slug
Typescript
Module System
Min. Node Version
Node Version
NPM Version
70.5
Supply Chain
98.7
Quality
76.7
Maintenance
100
Vulnerability
100
License
TypeScript (91.01%)
JavaScript (8.31%)
Shell (0.68%)
Total Downloads
16,320
Last Day
6
Last Week
192
Last Month
1,011
Last Year
12,897
MIT License
9 Stars
48 Commits
1 Forks
3 Watchers
11 Branches
2 Contributors
Updated on Oct 01, 2024
Latest Version
2.1.0
Package Id
space-slug@2.1.0
Unpacked Size
102.53 kB
Size
33.50 kB
File Count
7
NPM Version
10.7.0
Node Version
20.14.0
Published on
Oct 01, 2024
Cumulative downloads
Total Downloads
Last Day
20%
6
Compared to previous day
Last Week
-14.3%
192
Compared to previous week
Last Month
11.5%
1,011
Compared to previous month
Last Year
276.8%
12,897
Compared to previous year
56
Get a unique string that looks like this wonderful-jabba
or this hyperspace-4812
.
Generate unique slugs, usernames, numbers, custom words, and more using an intuitive api with zero dependencies.
1const { spaceSlug } from 'space-slug'; 2 3const slug = spaceSlug(); 4// Returns: joyful-illusion-30
1npm install space-slug 2 3yarn add space-slug 4 5pnpm add space-slug
👋 Hello there! Follow me @linesofcode or visit linesofcode.dev for more cool projects like this one.
1const { spaceSlug, adjective, color, digits, noun } from 'space-slug'; 2 3const slug = spaceSlug([color(), adjective(), noun(1), digits(3)], { 4 separator: '_' 5}); 6// Returns: blue_celestial_labyrinth_718
1const { spaceSlug, word, SpaceSlugDictionary } from 'space-slug'; 2 3const dictionary: SpaceSlugDictionary = { 4 en: { 5 starwars: ['jabba', 'ezra'], 6 }, 7}; 8 9const slug = spaceSlug([word('starwars')(2), digits(2)], { 10 dictionary, 11 locale: 'en', 12}); 13/// Returns: jabba-ezra-39
1const { uniqueSpaceSlug, color, digits } from 'space-slug'; 2 3const slug = await uniqueSpaceSlug([ 4 color(1), 5 digits(4), 6], { 7 usedSlugs: ['orange-3918'] 8}); 9// Returns: a slug that is not orange-3918
1const { uniqueSpaceSlug } from 'space-slug';
2
3await uniqueSpaceSlug([], {
4 maxAttempts: 10, // default is 10 attempts before throwing an error
5 isUnique: async (slug) => {
6 // check database to see if slug is unique
7 return true;
8 }
9});
10// Returns: a slug that you have verified is unique
1await uniqueSpaceSlug(['jabba'], { 2 isUnique: async (slug) => { 3 // a db lookup to see if slug is unique 4 return false; 5 }, 6 makeUnique: async (slug) => { 7 // somehow make the slug unique 8 return slug + '-hutt'; 9 } 10});
1const { spaceSlug } from 'space-slug'; 2 3await spaceSlug([], { 4 transform: (x) => x.toUpperCase() 5}); 6// Returns: QUAINT-HORIZON-1293
1const { spaceSlug, color, digits } from 'space-slug'; 2 3spaceSlug([ 4 'jabba', 5 digits(), 6]; 7// Returns: jabba-1293 8 9spaceSlug([ 10 color(), 11 ['jabba', 'hutt'], 12 digits(), 13]; 14// Returns: red-jabba-hutt-3979
Function | Type |
---|---|
word | (type: string) => (count?: number or undefined, _words?: string[] or undefined) => (options: SpaceSlugOptions) => Set<string> |
Function | Type |
---|---|
digits | (count?: number or undefined, noConsecutive?: boolean or undefined) => (options: SpaceSlugOptions) => string |
Function | Type |
---|---|
cleanString | (inputString: string, separator: string) => string |
Function | Type |
---|---|
uniqueSpaceSlug | (spaceSlugFn: SpaceSlugInput[], options?: SpaceSlugOptions and UniqueSpaceSlugOptions) => Promise<string> |
Function | Type |
---|---|
spaceSlug | (spaceSlugInputs?: SpaceSlugInput[] or undefined, options?: SpaceSlugOptions) => string |
Constant | Type |
---|---|
spaceSlugDefaultDictionary | SpaceSlugDictionary |
Constant | Type |
---|---|
spaceSlugDefaultOptions | Partial<SpaceSlugOptions> |
Constant | Type |
---|---|
noun | (count?: number or undefined, _words?: string[] or undefined) => (options: SpaceSlugOptions) => Set<string> |
Constant | Type |
---|---|
adjective | (count?: number or undefined, _words?: string[] or undefined) => (options: SpaceSlugOptions) => Set<string> |
Constant | Type |
---|---|
color | (count?: number or undefined, _words?: string[] or undefined) => (options: SpaceSlugOptions) => Set<string> |
Constant | Type |
---|---|
season | (count?: number or undefined, _words?: string[] or undefined) => (options: SpaceSlugOptions) => Set<string> |
Constant | Type |
---|---|
emoji | (count?: number or undefined, _words?: string[] or undefined) => (options: SpaceSlugOptions) => Set<string> |
Constant | Type |
---|---|
verb | (count?: number or undefined, _words?: string[] or undefined) => (options: SpaceSlugOptions) => Set<string> |
Constant | Type |
---|---|
animal | (count?: number or undefined, _words?: string[] or undefined) => (options: SpaceSlugOptions) => Set<string> |
Constant | Type |
---|---|
cosmos | (count?: number or undefined, _words?: string[] or undefined) => (options: SpaceSlugOptions) => Set<string> |
No vulnerabilities found.
No security vulnerabilities found.