Skip to the content

Kotoba言葉

Load only the word lists you need, mark repeated letters correctly and play a daily or seeded word game.

Kotoba is the Japanese word for words. About the name

Contents

Reference · Marking, scores and game rules

typeWordGamefunction

One key typed, now being the time in milliseconds (the first key starts the clock). A key the round does not take, or a round that is over, changes nothing.

Import it

import { typeWordGame } from "@johnmorrisdotca/kotoba";

Definition

function typeWordGame(game: WordGame, key: string, now?: number): WordGame

Parameters

NameTypeDescription
gameWordGame

The current immutable word-game state.

keystring

One accepted keyboard character.

now (optional)number

Host clock time in milliseconds.

Returns

WordGame

One key typed, now being the time in milliseconds (the first key starts the clock). A key the round does not take, or a round that is over, changes nothing.

Examples

import { startWordGame, typeWordGame } from "@johnmorrisdotca/kotoba";

const game = startWordGame("en",5,"apple");
const typed = [..."apple"].reduce((state,key)=>typeWordGame(state,key,1000),game);
console.log(typeWordGame(game,"a",1000).typed);
[ 'a' ]

What it prints (run when this page was built)

View sourceEdit on GitHubMade from the source of @johnmorrisdotca/kotoba 1.2.0.