Skip to content

Commit

Permalink
improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerim Hudson committed Apr 11, 2024
1 parent 7ffb48b commit 315e4bd
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,24 @@ NameTag is a simple username generator with a dictionary of safe words to use to
## How to use

```ts
import { nametag } from "https://deno.land/x/[email protected]/mod.ts";

const friendlyName = nametag();
```

Or with a configuration:

```ts
import {
nametag,
type NametagConfig,
} from "https://deno.land/x/[email protected]/mod.ts";

const config: NametagConfig = {
words: 5,
delimiter: "_",
categories: ["adjectives", "food"],
};

const friendlyName = nametag(config);
```
4 changes: 2 additions & 2 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const getRandomWord = (words: string[]) => {
return words[Math.floor(Math.random() * words.length)];
};

type Config = {
export type NametagConfig = {
delimiter?: string;
words?: number;
categories?: ("animals" | "food" | "adjectives")[];
Expand All @@ -18,7 +18,7 @@ const inputVal = v.object({
delimiter: v.optional(v.string(), "-"),
});

const nametag = (config?: Config) => {
const nametag = (config?: NametagConfig) => {
const { words, categories, delimiter } = v.parse(inputVal, config);
const output = [];

Expand Down

0 comments on commit 315e4bd

Please sign in to comment.