Skip to content

Commit

Permalink
docs: Add examples and install instruction
Browse files Browse the repository at this point in the history
  • Loading branch information
mgred committed Dec 23, 2023
1 parent f079fc6 commit df1b619
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,31 @@ Not good for:

## 🚀 Getting started

In a `MODULE.bazel` file define as a new dependency:

```starlark
bazel_dep(name = "sqids_bazel")

git_override(
module_name = "sqids_bazel",
remote = "https://github.com/sqids/sqids-bazel",
commit = "<commit_hash>",
)
```

Load from the module:

```starlark
@TODO
load("@sqids_bazel//:defs.bzl", "encode", "decode")
```

## 👩‍💻 Examples

Simple encode & decode:

```starlark
@TODO
id = encode([1, 2, 3]) # "86Rf07"
numbers = decode(id) # [1, 2, 3]
```

> **Note**
Expand All @@ -47,19 +62,23 @@ Simple encode & decode:
Enforce a *minimum* length for IDs:

```starlark
@TODO
id = encode([1, 2, 3], min_length = 10) # "86Rf07xd4z"
numbers = decode(id) # [1, 2, 3]
```

Randomize IDs by providing a custom alphabet:

```starlark
@TODO
alphabet = "FxnXM1kBN6cuhsAvjW3Co7l2RePyY8DwaU04Tzt9fHQrqSVKdpimLGIJOgb5ZE"
id = encode([1, 2, 3], alphabet) # "B4aajs"
numbers = decode(id, alphabet) # [1, 2, 3]
```

Prevent specific words from appearing anywhere in the auto-generated IDs:

```starlark
@TODO
id = encode([1, 2, 3], blocklist = ["86Rf07"])
numbers = decode(id) # [1, 2, 3]
```

## 📝 License
Expand Down

0 comments on commit df1b619

Please sign in to comment.