Reference · Look words up by reading, written form, English meaning, kanji or romaji
wordsOffunction
The words for a text that has been loaded, the commonest first.
A text of kana alone is a reading, and hiragana and katakana find the same words (カミ finds かみ). Any other text is a written
form. The text is made plain first (normalizeText): full-width and half-width, stray spaces and invisible characters make no
difference. With romaji: true, a text of Latin letters is read as romaji, as it must have been loaded. Nothing here waits: a
text that was not loaded is a mistake in the caller, so it throws instead of answering with no words, which would say the
dictionary has none.
Import it
import { wordsOf } from "@johnmorrisdotca/jisho/words";
Definition
function wordsOf(words: Words, text: string, options?: LookupOptions): Word[]
Parameters
| Name | Type | Description |
|---|---|---|
words | Words | What |
text | string | A reading or a written form that was loaded. |
options (optional) | LookupOptions |
|
Returns
Word[]
The words, none when the dictionary (or, for the common words, the common table) holds none, or none that the mode and the lists let through.
Examples
import { loadWords, wordsOf } from "@johnmorrisdotca/jisho/words";
const words = await loadWords(["かみ"]);
console.log(wordsOf(words, "かみ").slice(0, 3).map((one) => `${one.written} ${one.meaning}`));[
'紙 paper',
'神 god, deity, divinity; god-tier, incredible, fantastic',
'髪 hair (on the head)'
]What it prints (run when this page was built)