Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sbj42/word-search-generator

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sbj42/word-search-generator

A program to generate word search puzzles

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-40%
Maintainers
1
Weekly downloads
 
Created
Source

word-search-generator

A word search generator

usage

var generator = require('@sbj42/word-search-generator');
var puzzle = generator();
console.info(puzzle.toString());
console.info(puzzle.words.join(','));

That might print:

H T E S A D A N W O
A O W O R T R U N K
R E A D I O M P I G
D T O W D L Y D A M
L G I S E D H C A E
Y N O N D R R O C K
D C U D U A I Y N L
K T A T O D Y C E O
J U D G E O O T H U
E H T O B P R G W D

add,army,both,day,dog,door,dry,each,god,hardly,judge,let,loud,
mad,old,own,pet,pig,read,rich,ride,rock,row,sad,set,sock,the,
toe,trunk,tune,unit,when,win,wind

options

The generator function takes an optional options object, with these options:

diagonals (boolean)

Defaults to true. Determines whether words can be placed diagonally on the puzzle.

width and height (integer)

Defaults to 10x10. Sets the size of the puzzle.

minLength and maxLength (integer)

Useful for making sure the words aren't too short or too long. The default for minLength is 3, and for maxLength is undefined.

words (array of strings)

Words will be chosen randomly from this list. If this is not provided, it uses a built-in set of around 2,000 words.

puzzle api

The object returned from the generator function has the following properties:

width and height (integer)

The size of the puzzle.

grid (array of string)

The letters in the puzzle. For row R and column C, the letter can be found at grid[R * width + C].

words (array of string)

The words placed in the puzzle, in alphabetical order.

get(C, R)

A helper function to fetch the letter at row R and column C.

toString()

Prints the puzzle to a string, for testing or command-line output.

Keywords

FAQs

Package last updated on 27 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc