Skip to content

Commit

Permalink
bump version, fix optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerim Hudson committed Apr 12, 2024
1 parent d02054b commit c7a079e
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 6 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Kerim Hudson <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ NameTag is a simple username generator with a dictionary of safe words to use to
## How to use

```ts
<<<<<<< Updated upstream
import { nametag } from "https://deno.land/x/[email protected]/mod.ts";
=======
import { nametag } from "https://deno.land/x/[email protected]/mod.ts";
>>>>>>> Stashed changes

const friendlyName = nametag();
```
Expand All @@ -16,7 +20,11 @@ Or with a configuration:
import {
nametag,
type NametagConfig,
<<<<<<< Updated upstream
} from "https://deno.land/x/[email protected]/mod.ts";
=======
} from "https://deno.land/x/[email protected]/mod.ts";
>>>>>>> Stashed changes

const config: NametagConfig = {
words: 5,
Expand Down
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.0.1",
"version": "0.0.3",
"name": "@baosoy/nametag",
"tasks": {
"dev": "deno run --watch main.ts",
Expand Down
17 changes: 12 additions & 5 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,18 @@ export type NametagConfig = {

const CATEGORIES = ["adjectives", "animals", "food"];

const inputVal = v.object({
categories: v.optional(v.array(v.picklist(CATEGORIES)), CATEGORIES),
words: v.optional(v.number(), 3),
delimiter: v.optional(v.string(), "-"),
});
const inputVal = v.optional(
v.object({
categories: v.optional(v.array(v.picklist(CATEGORIES)), CATEGORIES),
words: v.optional(v.number(), 3),
delimiter: v.optional(v.string(), "-"),
}),
{
categories: ["animals", "food", "adjectives"],
words: 3,
delimiter: "-",
}
);

const nametag = (config?: NametagConfig) => {
const { words, categories, delimiter } = v.parse(inputVal, config);
Expand Down
7 changes: 7 additions & 0 deletions mod_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,10 @@ it(config, "can set all options at once", () => {
assertEquals(dictionary.food.includes(word), false);
});
});

const base = describe({ name: "base" });

it(base, "works with no config", () => {
const result = nametag();
assertEquals(typeof result, "string");
});

0 comments on commit c7a079e

Please sign in to comment.