diff --git a/README.md b/README.md index 99301be..cba0d9c 100644 --- a/README.md +++ b/README.md @@ -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/nametag@0.0.1/mod.ts"; +const friendlyName = nametag(); +``` + +Or with a configuration: + +```ts +import { + nametag, + type NametagConfig, +} from "https://deno.land/x/nametag@0.0.1/mod.ts"; + +const config: NametagConfig = { + words: 5, + delimiter: "_", + categories: ["adjectives", "food"], +}; + +const friendlyName = nametag(config); ``` diff --git a/mod.ts b/mod.ts index d816569..d33956e 100644 --- a/mod.ts +++ b/mod.ts @@ -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")[]; @@ -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 = [];