Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
4kimov committed Jul 17, 2023
1 parent 09fcf53 commit a448a9b
Showing 1 changed file with 42 additions and 2 deletions.
44 changes: 42 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,51 @@ Sqids (pronounced "squids") is a small library that lets you generate YouTube-lo

## Getting started

@todo
Install Sqids via:

```bash
yarn add sqids
```

## Examples

@todo
Simple encode & decode:

```javascript
const sqids = new Sqids()
const id = sqids.encode([1, 2, 3]) // "8QRLaD"
const numbers = sqids.decode(id) // [1, 2, 3]
```

Randomize IDs by providing a custom alphabet:

```javascript
const sqids = new Sqids({
alphabet: 'FxnXM1kBN6cuhsAvjW3Co7l2RePyY8DwaU04Tzt9fHQrqSVKdpimLGIJOgb5ZE',
})
const id = sqids.encode([1, 2, 3]) // "B5aMa3"
const numbers = sqids.decode(id) // [1, 2, 3]
```

Enforce a *minimum* length for IDs:

```javascript
const sqids = new Sqids({
minLength: 10,
})
const id = sqids.encode([1, 2, 3]) // "75JT1cd0dL"
const numbers = sqids.decode(id) // [1, 2, 3]
```

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

```javascript
const sqids = new Sqids({
blocklist: new Set(['word1', 'word2']),
})
const id = sqids.encode([1, 2, 3]) // "8QRLaD"
const numbers = sqids.decode(id) // [1, 2, 3]
```

## License

Expand Down

0 comments on commit a448a9b

Please sign in to comment.