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

wordpuzzle

v1.0.0

Published

Generate Word Puzzle (also known as Word Search or Word Find).

Downloads

4

Readme

wordPuzzle

Kind: global class

new wordPuzzle()

Create a words puzzle game

wordPuzzle.wordList

Kind: instance property of wordPuzzle

| Param | Type | Description | | --- | --- | --- | | wordList | Array.<string> | copy and sort the words by length, inserting words into the puzzle from longest to shortest works out the best |

wordPuzzle.placeWordInPuzzle(puzzle, opts, word) ⇒ boolean

Adds the specified word to the puzzle by finding all of the possible locations where the word will fit and then randomly selecting one

Kind: instance method of wordPuzzle Returns: boolean - true if the word was successfully placed, false otherwise

| Param | Type | Description | | --- | --- | --- | | puzzle | Array.<Array> | current state of the puzzle | | opts | Object | controls whether or not word overlap should be maximized | | word | string | word to fit into the puzzle |

wordPuzzle.newPuzzle([wordList], [options]) ⇒ Array.<Array>

Kind: instance method of wordPuzzle

| Param | Type | Default | | --- | --- | --- | | [wordList] | Array.<string> | this.wordList | | [options] | Object | this.opts |

wordPuzzle.newPuzzleLax(opts)

Wrapper around newPuzzle allowing to find a solution without some words

Kind: instance method of wordPuzzle

| Param | Type | Description | | --- | --- | --- | | opts | Object | options to use for this puzzle |

wordPuzzle.solve(puzzle, words) ⇒ Array.<{x: number, y: number, orientation: string, word: string, overlap: number}>

Returns the starting location and orientation of the specified words within the puzzle. Any words that are not found are returned in the notFound array

Kind: instance method of wordPuzzle Access: public

| Param | Type | | --- | --- | | puzzle | Array.<Array> | | words | Array.<string> |

wordPuzzle.print(puzzle) ⇒ string

Outputs a puzzle to the console, useful for debugging

Kind: instance method of wordPuzzle Returns: string - formatted string representing the puzzle

| Param | Type | Description | | --- | --- | --- | | puzzle | Array.<Array> | current state of the puzzle |

wordPuzzle.drawPuzzle([domElem], [puzzle])

Draws the puzzle by inserting rows of buttons into the DOM Element

Kind: instance method of wordPuzzle

| Param | Type | Default | | --- | --- | --- | | [domElem] | HTMLElement | this.domElem | | [puzzle] | Array.<Array> | this.finalPuzzle |

wordPuzzle.setEventHandlers([domElem])

Set the event handlers that will trigger the recognition of the words

Kind: instance method of wordPuzzle

| Param | Type | Default | | --- | --- | --- | | [domElem] | HTMLElement | this.domElem |

wordPuzzle.wordPuzzle

Kind: static class of wordPuzzle

new wordPuzzle(words, domElem, [opts])

Creates an instance of wordPuzzle.

| Param | Type | Default | Description | | --- | --- | --- | --- | | words | Array.<string> | | list of words to include in the puzzle | | domElem | HTMLElement | | HTML DOM Element that will contain the game | | [opts] | Object | {} | game options | | [opts.lang] | string | | define the letters set to use, depending on the words language, must be the ISO 639-1 language code, default: EN | | [opts.heigth] | number | | desired height of the puzzle, default: smallest possible | | [opts.width] | number | | desired width of the puzzle, default: smallest possible | | [opts.orientations] | Array.<string> | allOrientations | list the authorized orientations in which the words can be formed, default: allOrientations | | [opts.fillBlanks] | boolean | true | do the game must fill the spaces not used to form a word with random letters, default: true | | [opts.allowExtraBlanks] | boolean | true | can the game add additional blanks, default: true | | [opts.maxAttempts] | number | 3 | number of tries before increasing puzzle size, default: 3 | | [opts.maxGridGrowth] | number | 10 | number of puzzle grid increases, default: 10 | | [opts.preferOverlap] | boolean | true | maximize word overlap or not, default: true | | [opts.debug] | boolean | false | wether or not to print the puzzle to the console, default: false |