diff --git a/lib/word/scrabbleScore.js b/lib/word/scrabbleScore.js index 2311c82..b91b3ee 100644 --- a/lib/word/scrabbleScore.js +++ b/lib/word/scrabbleScore.js @@ -6,6 +6,12 @@ const wordnik = new Wordnik() * Get the Scrabble score for a word * @param {string} word * @returns {integer} - score for the word + * + * @example + * ```js + * import { scrabbleScore } from 'https://deno.land/x/wordnik/mod.js' + * console.log(await scrabbleScore('cookie')) // returns cookie's score (12) + * ``` */ export async function scrabbleScore(word) { let response @@ -24,11 +30,3 @@ export async function scrabbleScore(word) { const data = JSON.parse(json) return data.value } - -/** - * @example - * ```js - * import { scrabbleScore } from 'https://deno.land/x/wordnik/mod.js' - * console.log(await scrabbleScore('cookie')) // returns cookie's score (12) - * ``` - */ diff --git a/lib/words/random.js b/lib/words/random.js index 29fd92f..02c9c03 100644 --- a/lib/words/random.js +++ b/lib/words/random.js @@ -13,15 +13,7 @@ const wordnik = new Wordnik() * @param {integer} [maxDictionaryCount] - Maximum dictionary count * @param {integer} [minLength] - Minimum word length * @param {integer} [maxLength] - Maximum word length - */ -export async function randomWord(options) { - const response = await fetch(wordnik.words('randomWord', options)) - const json = JSON.stringify(await response.json()) - const data = JSON.parse(json) - return data -} - -/** + * * @example * ```js * import { randomWord } from 'https://deno.land/x/wordnik/mod.js' @@ -29,3 +21,9 @@ export async function randomWord(options) { * console.log(response.word) // prints a random word * ``` */ +export async function randomWord(options) { + const response = await fetch(wordnik.words('randomWord', options)) + const json = JSON.stringify(await response.json()) + const data = JSON.parse(json) + return data +}