wordle_logic
A typesafe deno/npm package to facilitate a game of wordle using nanostores
Why?
I plan on building a minimal adless version of wordle and wanted to open source the logic.
Getting started
This module exports a single wordle()
function which exports
nanostores and an attempt()
function to test words.
word
: a nanostore which holds the current game’s wordattempts
: a nanostore which holds the current game’s guessesattempt()
: a function which takes in a single string and returns an object with aerror?: 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):
"max_attempts_reached"
: the game is already over since the number of attempts has reachedoptions?.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 theoptions?.validateAttempt()
function
Tasks
Task | Description |
---|---|
test |
run all tests once |
dev |
run all tests in watch mode |
npm |
compile npm package using dnt |