lettras 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -0
- package/engine/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,6 +7,8 @@ kept as one cell each. Runs locally (WebAssembly): no network, no API key. Libra
|
|
|
7
7
|
npm install lettras
|
|
8
8
|
```
|
|
9
9
|
|
|
10
|
+
[npm package](https://www.npmjs.com/package/lettras) · [source and docs](https://github.com/Artificialss/lettras-sdk)
|
|
11
|
+
|
|
10
12
|
```js
|
|
11
13
|
import { generate, render } from 'lettras';
|
|
12
14
|
|
|
@@ -46,12 +48,63 @@ npx lettras --words gato,perro,piña --rows 9 --cols 12 --position mixed --rando
|
|
|
46
48
|
language's letter frequency, `accents: false` limits them to A-Z, and without a `seed` every call is different. Passing the
|
|
47
49
|
puzzle (instead of a bare matrix) also protects its words from accidental extra copies. CLI: `--random` and `--accents on|off`.
|
|
48
50
|
|
|
51
|
+
**Example.** The same puzzle before and after `fill` (Spanish, seed 5):
|
|
52
|
+
|
|
53
|
+
```js
|
|
54
|
+
const puzzle = generate({ words: ['gato', 'perro', 'piña', 'mono', 'cebra'], rows: 8, cols: 10, position: 'mixed', seed: 8 });
|
|
55
|
+
const done = fill(puzzle, { lang: 'es', accents: true, seed: 5 });
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
`puzzle.grid` has `-` in every empty cell; `done.grid` replaces them (58 cells here):
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
C E B R A - O - - -
|
|
62
|
+
- - - - - - - T O -
|
|
63
|
+
- - - - M - - R A -
|
|
64
|
+
- - - O - - R - - G
|
|
65
|
+
- - N - - E - - - -
|
|
66
|
+
- O - - P - - - - -
|
|
67
|
+
- - - - - - - - - -
|
|
68
|
+
- - - - - - A Ñ I P
|
|
69
|
+
```
|
|
70
|
+
```
|
|
71
|
+
C E B R A R O G G J
|
|
72
|
+
D R A E E R C T O D
|
|
73
|
+
B Ó E E M Í M R A Ñ
|
|
74
|
+
T S C O N R R A E G
|
|
75
|
+
T R N E A E R O E M
|
|
76
|
+
I O O E P S N P A O
|
|
77
|
+
O C O O A P P A U A
|
|
78
|
+
I R E A A S A Ñ I P
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
With `accents: false` the filler uses plain A-Z only (the one `Ñ` left is the hidden word *piña*, which keeps its spelling):
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
C E B R A R O G G I
|
|
85
|
+
D Q A E E P C T O D
|
|
86
|
+
B Y E E M X M R A N
|
|
87
|
+
S R C O N R R A E G
|
|
88
|
+
S R N E A E R O E M
|
|
89
|
+
I O O E P S N O A O
|
|
90
|
+
O B O O A P O A T A
|
|
91
|
+
H R E A A S A Ñ I P
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Same grid, language, accents and `seed` always give the same filler on every platform. Without a `seed` the wrappers
|
|
95
|
+
pick a random one, so every call gives different letters.
|
|
96
|
+
|
|
49
97
|
CLI flags mirror these: `--words a,b,c --rows N --cols N --position P --difficulty N --clustering N --seed N --lang xx
|
|
50
98
|
--classic --fill C`, plus `--json`, `--solution` and `--stdin`.
|
|
51
99
|
|
|
52
100
|
`generate` throws on invalid input (for example zero rows). Words that cannot be placed are listed in `unplaced`;
|
|
53
101
|
words that are refused (spaces, digits, duplicates) are listed in `rejected` with a reason.
|
|
54
102
|
|
|
103
|
+
## Module format
|
|
104
|
+
|
|
105
|
+
The package is ESM only: use `import { generate, fill } from 'lettras'`. From CommonJS use `const { generate } = await import('lettras')`.
|
|
106
|
+
It needs Node 20 or newer (or any modern browser bundler) and ships its own TypeScript types.
|
|
107
|
+
|
|
55
108
|
## License
|
|
56
109
|
|
|
57
110
|
Wrapper, CLI and types: MIT. The compiled engine in `engine/` is proprietary: use it unmodified through this package;
|