Skip to content

Commit

Permalink
docs: (README.md) Update with new ID lengths
Browse files Browse the repository at this point in the history
  • Loading branch information
dperuo committed Mar 22, 2024
1 parent 9bd2bcc commit 37d0e0c
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,62 +36,63 @@ deno run https://deno.land/x/sweetid/cli.ts

## Details

We use [Nano ID](https://github.com/ai/nanoid) under the hood to guarantee
high-quality, cryptographically secure IDs.
We use [Nano ID](https://github.com/ai/nanoid) under the hood to guarantee high-quality, cryptographically secure IDs.

Sweet IDs are alphanumeric and always start with a letter.

## ID Length

The `sweetid()` function generates IDs with a length 6, 12, 24, or 48
characters. IDs are 6 characters long by default.
The `sweetid()` function generates IDs with a length 6, 12, 24, 48, or 96 characters. IDs are 6 characters long by default.

Pass in an optional [`SweetIdSize`](./src/const.ts) as the first argument to set
the output size of the ID.
Pass in an optional [`SweetIdSize`](./src/const.ts) as the first argument to set the output size of the ID.

```ts
sweetid("short" || "s");
sweetid("xshort" || "xs");
// => MkSofu

sweetid("medium" || "m");
sweetid("short" || "s");
// => bzAuoVKRo1rJ

sweetid("long" || "l");
sweetid("medium" || "m");
// => XGPCQUqrEVMzMyaU4V52u1LQ

sweetid("xlong" | "xl");
sweetid("long" || "l");
// => dRjFNY7TrZFqizgKLBwWXAQSErCk51gheMFlBNVAZFM5DuLr

sweetid("xlong" || "xl");
// => wMoHhg2g2YXqYelDScehIMirOQrEzTPvOI0xqSUXmChqNwHjZQ5kIDTW1f4vjwFIbNt8X6Bzmmz6gEYUQtPuKb9y6u2B4ODE
```

Use the `--size <SweetIdSize>` (`-s <SweetIdSize>`) flag on the command line to
set the output size.
Use the `--size <SweetIdSize>` (`-s <SweetIdSize>`) flag on the command line to set the output size.

```zsh
deno run https://deno.land/x/sweetid/cli.ts -s s
deno run https://deno.land/x/sweetid/cli.ts -s xs
# HrcZ9u

deno run https://deno.land/x/sweetid/cli.ts -s m
deno run https://deno.land/x/sweetid/cli.ts -s s
# s75rHr14EJYJ

deno run https://deno.land/x/sweetid/cli.ts -s l
deno run https://deno.land/x/sweetid/cli.ts -s m
# rCJLcqqHW4yuvsSeGPH4INok

deno run https://deno.land/x/sweetid/cli.ts -s xl
deno run https://deno.land/x/sweetid/cli.ts -s l
# hMASSfdHZDbpZFHL2UZFWEduk6Ltt5OcxaidVcxXU1K0cyyD

deno run https://deno.land/x/sweetid/cli.ts -s xl
# Pzw55DDYGgHE3fGAzGUK7X9MUYizwaGA0vcqVbaYKOce5ij1aRBediwgc1OnRZNjR5u5RKLi7vuonxU1adiAIc2yETrLOyn6
```

## Generate Multiple IDs

Use the `--count <NUMBER>` (`-c <NUMBER>`) flag on the command line to generate
multiple IDs of the same length.
Use the `--count <NUMBER>` (`-c <NUMBER>`) flag on the command line to generate multiple IDs of the same length.

```zsh
deno run https://deno.land/x/sweetid/cli.ts -c 3
# B4a6Xc
# uRYkkT
# NJZtjW

deno run https://deno.land/x/sweetid/cli.ts -s l -c 3
deno run https://deno.land/x/sweetid/cli.ts -s m -c 3
# hxzRSWPX5TDcQieHk2B7fPkA
# LXaAyksi6d3HgCAyw2Y4EKM8
# sZhCDNUjQRJzptbNqGco1HdL
Expand Down

0 comments on commit 37d0e0c

Please sign in to comment.