npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pf-sowpods

v1.2.1

Published

Scrabble's SOWPODS dictionary

Downloads

1,540

Readme

pf-sowpods

Scrabble's SOWPODS dictionary - The SOWPODS dictionary with related functionality.

Examples

// Require the module
const sowpods = require('pf-sowpods')

sowpods[62]    // 'ABAPICAL'
sowpods.length // 267751

// A trie structure is included, too
sowpods.trie.H.A.P.H.T.A.R.A._ // true

// Verify words
sowpods.verify('banana')  // true
sowpods.verify('asdfjkl') // false

// Find anagrams out of letters
sowpods.anagram('BCKRTO*')
// [ 'AB', 'ABO', 'ABORT', ..., 'YOK', 'YORK', 'ZO' ]

// Get similarly spelled words
sowpods.suggest('pillowy')
// [ 'BILLOW', 'BILLOWS', 'MELLOWY', ..., 'WILLOWS', 'WILLOWY', 'YELLOWY' ]

API

You can require the whole module, or just pieces of it.

require('pf-sowpods')                // Everything
require('pf-sowpods/src/dictionary') // Just the array of SOWPODS words
require('pf-sowpods/src/sowpods')    // The dictionary and a few core features

Dependency graph (left to right):

index
 ├─ sowpods ──────┐
 │   ├─ random ───┤
 │   ├─ verify    │
 │   │   └───┐    │
 │   └───── trie ─┴─ dictionary
 ├─ anagram ─┤
 ├─ suggest ─┘
 └─ (define)
     ├─ cheerio
     └─ superagent

sowpods

({Array}): An alphabetized array of the SOWPODS dictionary. All letters are capitalized.

sowpods.filter(word => word.length === 5)
// [ 'AAHED', 'AALII', ..., 'ZYMES', 'ZYMIC' ]

sowpods.trie

({Object}): A trie structure of the words where the nodes are single capitalized characters. The node <path>._ === true indicates an End-of-Word. Lodash's _.get() function may be useful here.

const _ = require('lodash')
_.get(sowpods.trie, 'A.B.C.D.E.F')
// undefined
_.get(sowpods.trie, 'DERMI'.split(''))
// {
//   C: { _: true },
//   S: { _: true,
//     E: { S: { _: true } }
//   }
// }

sowpods.verify(word)

Arguments

  1. word (String): A word to check (case-insensitive).

Returns

  • (Boolean): true if the word is in SOWPODS, false otherwise.

This function crawls the trie to determine if the word exists.

sowpods.verify('banana')  // true
sowpods.verify('asdfjkl') // false

sowpods.anagram(chars)

Arguments

  1. chars (String): The letters to anagram (case-insensitive).

Returns

  • (Array): All possible single word anagrams sorted in alphabetical order.

Characters in chars which are not alphabetic, are considered to be wildcards. This function crawls the trie as long as the next node is available in the letters provided.

sowpods.anagram('EYBTOR*')
// [ 'BOOTERY', 'BARYTE', ..., 'YU', 'ZO' ]

sowpods.random([count])

Arguments

  1. [count] (number): The number of random words to return.

Returns

  • (String|Array): Some random words.

If count is undefined, it returns a single string. Otherwise it returns an array of length count of random words.

sowpods.random()  // 'PICANINNIES'
sowpods.random(1) // [ 'IGLU' ]
sowpods.random(2) // [ 'REFRESHENS', 'EPILOGUIZING' ]

sowpods.suggest(string, [distance = 2])

Arguments

  1. string (String): The string to query (case-insensitive).
  2. [distance = 2] (number): The maximum distance to search for.

Returns

sowpods.suggest('pillowy')
// [ 'BILLOW', 'BILLOWS', 'MELLOWY', ..., 'WILLOWS', 'WILLOWY', 'YELLOWY' ]
sowpods.suggest('catfish', 1)
// [ 'BATFISH', 'CATFISH', 'CATTISH', 'RATFISH' ]