Skip to content

Commit

Permalink
refactor: rename words to dictionary
Browse files Browse the repository at this point in the history
  • Loading branch information
TimMikeladze committed Aug 11, 2023
1 parent c410b8b commit 88d8fd4
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 14 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ spaceSlug([
| Function | Type |
| ---------- | ---------- |
| `digits` | `(count?: number) => (options: SpaceSlugOptions) => string` |
| `digits` | `(count?: number, noConsecutive?: boolean) => (options: SpaceSlugOptions) => string` |
### :gear: cleanString
Expand All @@ -153,7 +153,7 @@ spaceSlug([
## :wrench: Constants
- [defaultWords](#gear-defaultwords)
- [spaceSlugDefaultDictionary](#gear-spaceslugdefaultdictionary)
- [spaceSlugDefaultOptions](#gear-spaceslugdefaultoptions)
- [noun](#gear-noun)
- [adjective](#gear-adjective)
Expand All @@ -164,11 +164,11 @@ spaceSlug([
- [animal](#gear-animal)
- [cosmos](#gear-cosmos)
### :gear: defaultWords
### :gear: spaceSlugDefaultDictionary
| Constant | Type |
| ---------- | ---------- |
| `defaultWords` | `Record<string, Partial<{ [key: string]: string[]; adjectives: string[]; animals: string[]; colors: string[]; cosmos: string[]; emojis: string[]; nouns: string[]; seasons: string[]; verbs: string[]; }>>` |
| `spaceSlugDefaultDictionary` | `Record<string, Partial<{ [key: string]: string[]; adjectives: string[]; animals: string[]; colors: string[]; cosmos: string[]; emojis: string[]; nouns: string[]; seasons: string[]; verbs: string[]; }>>` |
### :gear: spaceSlugDefaultOptions
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import {
animals,
verbs,
cosmos as cosmosWords,
} from './data/en';
} from './dictionary/en';

import { emojis } from './data/emojis';
import { emojis } from './dictionary/emojis';

export * from './data/emojis';
export * from './data/en';
export * from './dictionary/emojis';
export * from './dictionary/en';

export const defaultWords: Record<string, SpaceSlugDictionary> = {
export const spaceSlugDefaultDictionary: Record<string, SpaceSlugDictionary> = {
en: {
seasons,
emojis,
Expand All @@ -29,7 +29,7 @@ export const defaultWords: Record<string, SpaceSlugDictionary> = {
export const spaceSlugDefaultOptions: Partial<SpaceSlugOptions> = {
locale: 'en',
separator: '-',
dictionary: defaultWords,
dictionary: spaceSlugDefaultDictionary,
};

export type SpaceSlugDictionary = Partial<{
Expand Down
14 changes: 10 additions & 4 deletions tests/spaceSlug.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, it, expect } from 'vitest';
import {
spaceSlug,
animal,
defaultWords,
spaceSlugDefaultDictionary,
digits,
noun,
word,
Expand Down Expand Up @@ -85,11 +85,17 @@ describe('spaceSlug', () => {

expect(parts).toHaveLength(4);

expect(defaultWords.en.nouns!.includes(parts[0])).toBeTruthy();
expect(
spaceSlugDefaultDictionary.en.nouns!.includes(parts[0])
).toBeTruthy();

expect(defaultWords.en.nouns!.includes(parts[1])).toBeTruthy();
expect(
spaceSlugDefaultDictionary.en.nouns!.includes(parts[1])
).toBeTruthy();

expect(defaultWords.en.animals!.includes(parts[2])).toBeTruthy();
expect(
spaceSlugDefaultDictionary.en.animals!.includes(parts[2])
).toBeTruthy();

expect(parts[3]).toHaveLength(3);
});
Expand Down

0 comments on commit 88d8fd4

Please sign in to comment.