Object consisting of:
args.language
- (Optional) Pick language for wordlib. Can either be sv
or en
.args.customDictionary
- (Optional) A custom dictionary as an array of strings.const enWords = new WordLib({language: "en"});
const customWords = new WordLib({customDictionary: ["custom", "dictionary"]})
Private
dictionaryFinds any anagrams of specified word.
Word to find anagrams of.
Optional
customDictionary: CustomDictionaryObject consisting of:
args.customDictionary
- (Optional) A custom dictionary as an array of strings.An array of anagrams of specified word.
const enWords = new WordLib({language: "en"});
const res = enWords.anagramsOf("orange");
//=> ["onager"]
Returns an array of words that can be formed using the supplied letters.
Letters to form words from.
Optional
args: LengthCustomDictionaryArgsObject consisting of:
args.length
- (Optional) Only returns words of length n.args.customDictionary
- (Optional) A custom dictionary as an array of strings.An array of words, made from supplied letters.
const enWords = new WordLib({customDictionary: ["test", "set", "testing"]});
const res = enWords.containing("estt");
//=> ["test", "set"]
Returns an array of words, all ending with specified word.
String which all words should end with.
Optional
args: LengthCustomDictionaryArgsconst words = new WordLib({customDictionary: ["sword", "words"]});
const res = words.endsWith("word");
//=> ["sword"]
number
args.length - (Optional) The length of something.
string[]
args.customDictionary - (Optional) A custom dictionary as an array of strings.
Returns all words in dictionary.
An array of words.
const words = new WordLib({customDictionary: ["a", "custom", "dictionary"]});
const res = words.getDictionaryWords();
//=> ["a", "custom", "dictionary"]
Returns words that can be created from known characters and allowed characters. Questionmark (?) is used as a wildcard.
String
Optional
args: AllowedCharactersCustomDictionaryArgsObject consisting of:
CustomDictionary
- (Optional) A custom dictionary as an array of strings.AllowedCharacters
- (Optional) An array of characters which are allowed to fill in the unknown characters.An array of possible words.
const words = new WordLib({language: "en"});
const res = words.getPossibleWords("h?ll?", {allowedCharacters: ["e", "l", "a", "o"]});
//=> [ "hollo", "hallo", "hello", "holla" ]
Returns words that can be created from a string of characters including wildcards (Marked as '?').
Letters including wildcards which to form words from.
Optional
args: LengthCustomDictionaryArgsObject consisting of:
args.length
- (Optional) Only return words of length.args.customDictionary
- (Optional) Return words from a custom dictionary.An array of words that can be formed from characters including wildcards.
const words = new WordLib({language: "en"});
const res = words.getWildcardWords("te???rgrab", { length: 10 });
//=> [ "ratbaggery", "begartered", "gubernator", "regretably", "bergmaster", "boragewort", "grubstaker", "tunaburger", "aberrating", "arbitrages", "regretable", "arbitrager" ]
Returns a boolean value depending on if a word exists in dictionary.
Word to look up.
Optional
customDictionary: CustomDictionaryTrue if word exists in dictionary, otherwise false.
const enWords = new WordLib({language: "en"});
const res = enWords.isWord("word")
//=> true
Returns all words of specified length.
Optional
customDictionary: CustomDictionaryObject consisting of:
args.customDictionary
- (Optional) A custom dictionary as an array of strings.An array of words of length specified.
const enWord = new WordLib({language: "en"});
const res = enWord.ofLength(31);
//=> ["dichlorodiphenyltrichloroethane"]
Returns all palindromes in dictiobary.
Optional
args: LengthCustomDictionaryArgsObject consisting of:
An array of palindromes.
const words = new WordLib({customDictionary: ["kinnikinnik", "sms", "orange"]});
const res = words.palindromes(10);
//=> ["kinnikinnik"]
number args.length
- (Optional) Only return palindromes of length specified.
string[] args.customDictionary
- (Optional) A custom dictionary as an array of strings.
Returns a random word from dictionary.
Optional
args: LengthCustomDictionaryArgsnumber args.length
- (Optional) The desired length of the random word.
args.customDictionary
- (Optional) A custom dictionary as an array of strings.A randomly chosen word.
const enWords = new WordLib({language: "en"});
const res = enWords.random();
//=> "quiddle"
Returns words that are similar (according to its levenshtein distance) to specified word.
Word to find similar words to.
Optional
customDictionary: CustomDictionaryObject consisting of:
args.customDictionary
- (Optional) A custom dictionary as an array of strings.An array of words which levenshtein distance is <= 2.
const enWords = new WordLib({language: "en"});
const res = enWords.similarTo("typescript");
//=> [ 'telescript', 'typoscript', 'typescripts']
Returns an array of words, all starting with specified word.
String that all words should start with.
Optional
args: LengthCustomDictionaryArgsObject consisting of:
args.length
- (Optional) The length of words returned.args.customDictionary
- (Optional) A custom dictionary as an array of strings.An array of words, starting with specified word.
const words = new WordLib({customDictionary: ["sword", "words"]});
const res = words.startsWith("word");
//=> ["words"]
Generated using TypeDoc
Constructor for creating a new WordLib object. If a custom dictionary is supplied, language property will be ignored. Defaults to english if no argument is passed.