Skip to content

Commit

Permalink
Merge pull request #29 from ArkhamCookie/fix-examples
Browse files Browse the repository at this point in the history
Fix examples
  • Loading branch information
ArkhamCookie authored Aug 22, 2023
2 parents faafdb8 + a4a8e60 commit a1a9c43
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
14 changes: 6 additions & 8 deletions lib/word/scrabbleScore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
* ```
*/
16 changes: 7 additions & 9 deletions lib/words/random.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,17 @@ 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'
* const response = await randomWord()
* 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
}

0 comments on commit a1a9c43

Please sign in to comment.