Skip to content

Commit 59c2ff2

Browse files
authored
docs: add basic README
1 parent ec4af89 commit 59c2ff2

1 file changed

Lines changed: 63 additions & 0 deletions

File tree

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Patcode
2+
3+
Patcode is a generator of short, memorable, human-friendly numeric codes based on structured patterns.
4+
Perfect for **OTP**, **SMS verification**, **2FA**, **PIN codes**, onboarding steps, and any UX-friendly confirmation flows.
5+
6+
---
7+
8+
## Features
9+
10+
- Generates **4-digit** and **6-digit** human-friendly codes
11+
- Pattern-based generation: **AABB**, **ABAB**, **ABBA**, **AAAB**, **ABBB**, **AABC**, **ABBC**,
12+
plus **ABABAB**, **AABBCC**, **AAABBB**, **ABBABB**, **ABCABC**, **ABCCBA**
13+
- Filters out simple sequences (`1234`, `9876`) and repeated digits (`0000`)
14+
- Fully customizable strategies (your own generator logic)
15+
- Optional custom RNG (for cryptographic random or deterministic tests)
16+
17+
---
18+
19+
## Installation
20+
21+
```bash
22+
npm install patcode
23+
# or
24+
yarn add patcode
25+
# or
26+
pnpm add patcode
27+
```
28+
29+
---
30+
31+
## Usage
32+
33+
### Basic
34+
35+
```ts
36+
import { generateCode } from "patcode";
37+
38+
generateCode(); // "535353" (6-digit, mixed patterns)
39+
```
40+
41+
### 4-digit code
42+
43+
```ts
44+
generateCode({ length: 4 }); // "5566"
45+
```
46+
47+
## Custom Strategy
48+
49+
```ts
50+
generateCode({
51+
length: 6,
52+
strategy: "custom",
53+
customStrategy(ctx) {
54+
// example: code starting with 9, then ABAB
55+
const [A, B] = ctx.pickTwoDifferentDigits();
56+
return ctx.fromDigits(["9", A, B, A, B, A]);
57+
}
58+
});
59+
```
60+
61+
## 📝 License
62+
63+
This project is licensed under the [**MIT License**](./LICENSE).

0 commit comments

Comments
 (0)