Skip to content

Commit

Permalink
feat: split lorem to its own file
Browse files Browse the repository at this point in the history
  • Loading branch information
ST-DDT committed Jan 30, 2022
1 parent 30e13ba commit 09d13e8
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 12 deletions.
15 changes: 6 additions & 9 deletions src/definitions/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import type { HackerDefinitions } from './hacker';
import { hacker } from './hacker';
import type { InternetDefinitions } from './internet';
import { internet } from './internet';
import type { LoremDefinitions } from './lorem';
import { lorem } from './lorem';
import type { NameDefinitions } from './name';
import { name } from './name';

Expand All @@ -32,9 +34,7 @@ export interface Definitions {
finance: FinanceDefinitions;
hacker: HackerDefinitions;
internet: InternetDefinitions;
lorem: {
words;
};
lorem: LoremDefinitions;
music: {
genre;
};
Expand Down Expand Up @@ -98,10 +98,7 @@ export interface LocaleDefinition {
finance?: Partial<FinanceDefinitions>;
hacker?: Partial<HackerDefinitions>;
internet?: Partial<InternetDefinitions>;
lorem?: Partial<{
supplemental: any[];
words: any[];
}>;
lorem?: Partial<LoremDefinitions>;
music?: Partial<{
genre: any[];
}>;
Expand Down Expand Up @@ -154,9 +151,9 @@ export interface DefinitionTypes {
readonly finance: typeof finance;
readonly hacker: typeof hacker;
readonly internet: typeof internet;
readonly lorem: typeof lorem;
readonly name: typeof name;

readonly lorem: string[];
readonly phone_number: string[];
readonly system: string[];
readonly vehicle: string[];
Expand All @@ -182,7 +179,7 @@ export const definitions: DefinitionTypes = {
hacker,
internet,
name,
lorem: ['words'],
lorem,
phone_number: ['formats'],
system: ['mimeTypes', 'directoryPaths'],
vehicle: ['vehicle', 'manufacturer', 'model', 'type', 'fuel', 'vin', 'color'],
Expand Down
2 changes: 2 additions & 0 deletions src/definitions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import type {
} from './finance';
import type { HackerDefinitions, HackerPhraseDefinitions } from './hacker';
import type { InternetDefinitions } from './internet';
import type { LoremDefinitions } from './lorem';
import type { NameDefinitions, NameTitleDefinitions } from './name';
import type { Format, Formats, Texts, Values } from './utils';

Expand Down Expand Up @@ -50,6 +51,7 @@ export type {
HackerDefinitions,
HackerPhraseDefinitions,
InternetDefinitions,
LoremDefinitions,
NameDefinitions,
NameTitleDefinitions,
};
14 changes: 14 additions & 0 deletions src/definitions/lorem.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { Texts } from '.';
import { allOf } from './utils';

/**
* The possible definitions related to lorem texts.
*/
export interface LoremDefinitions {
words: Texts;
}

/**
* Internal: A list of all keys for the LoremDefinitions.
*/
export const lorem = allOf<keyof LoremDefinitions>()('words');
5 changes: 3 additions & 2 deletions src/locales/en/lorem/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { LoremDefinitions } from '../../../definitions';
import supplemental from './supplemental';
import words from './words';

const lorem: any = {
const lorem = {
supplemental,
words,
};
} as LoremDefinitions;

export default lorem;
2 changes: 1 addition & 1 deletion src/lorem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class Lorem {
*/
word(length?: number): string {
const hasRightLength = (word: string) => word.length === length;
let properLengthWords: string[];
let properLengthWords: readonly string[];
if (typeof length === 'undefined') {
properLengthWords = this.faker.definitions.lorem.words;
} else {
Expand Down

0 comments on commit 09d13e8

Please sign in to comment.