https://github.com/jacob-shuman/wordle-logic
A typesafe deno/node package to facilitate a game of wordle using nanostores
https://github.com/jacob-shuman/wordle-logic
deno dnt nanostores node typescript wordle
Last synced: about 2 months ago
JSON representation
A typesafe deno/node package to facilitate a game of wordle using nanostores
- Host: GitHub
- URL: https://github.com/jacob-shuman/wordle-logic
- Owner: jacob-shuman
- License: mit
- Created: 2023-12-24T01:55:54.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-04T22:49:29.000Z (over 2 years ago)
- Last Synced: 2024-02-04T23:42:05.230Z (over 2 years ago)
- Topics: deno, dnt, nanostores, node, typescript, wordle
- Language: TypeScript
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# wordle_logic
[](https://deno.land/x/wordle_logic)
[](https://www.npmjs.com/package/wordle-logic)
[](https://github.com/jacob-shuman/wordle-logic/blob/main/LICENSE)
> A typesafe deno/npm package to facilitate a game of wordle using nanostores
## Why?
I plan on building a minimal adless version of
[wordle](https://en.wikipedia.org/wiki/Wordle) and wanted to open source the
logic.
## Getting started
This module exports a single `wordle()` function which exports
[nanostores](https://github.com/nanostores/nanostores) and an `attempt()`
function to test words.
- `word`: a nanostore which holds the current game's word
- `attempts`: a nanostore which holds the current game's guesses
- `attempt()`: a function which takes in a single string and returns an object
with a `error?: WordleError` property.
## Errors
The `attempt()` function will return an object with an `error?: WordleError`
property if the attempt failed for any reason. Common errors are (for an
exhaustive list see [mod.ts](./mod.ts)):
- `"max_attempts_reached"`: the game is already over since the number of
attempts has reached `options?.maxAttempts` (6 by default)
- `"too_few_characters"`: the attempted word has less characters then the
current word
- `"too_many_characters"`: the attempted word has more characters then the
current word
- `"invalid_attempt"`: the attempt did not pass the `options?.validateAttempt()`
function
## Tasks
| Task | Description |
| ------ | ---------------------------------------------------------------- |
| `test` | run all tests once |
| `dev` | run all tests in watch mode |
| `npm` | compile npm package using [dnt](https://github.com/denoland/dnt) |