From 0ab5578ec80538c9dc26610a4b24d6036df14f5d Mon Sep 17 00:00:00 2001 From: ArkhamCookie Date: Tue, 22 Aug 2023 13:22:12 -0500 Subject: [PATCH 1/2] Moved examples to the correct spot --- lib/word/scrabbleScore.js | 14 ++++++-------- lib/words/random.js | 17 ++++++++--------- 2 files changed, 14 insertions(+), 17 deletions(-) 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..c5e9525 100644 --- a/lib/words/random.js +++ b/lib/words/random.js @@ -4,6 +4,7 @@ const wordnik = new Wordnik() /** * Random Word - Return a single random word/WordObject + * * @param {boolean} [hasDictionaryDef] - Only return words dictionary definitions * @param {string} [includePartOfSpeech] - CSV part-of-speech values in include * @param {string} [excludePartOfSpeech] - CSV part-of-speech values in exclude @@ -13,15 +14,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 +22,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 +} From a4a8e6092e9e7498697fdfcc8714265dced1b4f4 Mon Sep 17 00:00:00 2001 From: ArkhamCookie Date: Tue, 22 Aug 2023 13:24:05 -0500 Subject: [PATCH 2/2] Removed extra line --- lib/words/random.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/words/random.js b/lib/words/random.js index c5e9525..02c9c03 100644 --- a/lib/words/random.js +++ b/lib/words/random.js @@ -4,7 +4,6 @@ const wordnik = new Wordnik() /** * Random Word - Return a single random word/WordObject - * * @param {boolean} [hasDictionaryDef] - Only return words dictionary definitions * @param {string} [includePartOfSpeech] - CSV part-of-speech values in include * @param {string} [excludePartOfSpeech] - CSV part-of-speech values in exclude