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

wasm_crossword_generator

v0.0.2

Published

A WASM-based TypeScript library for generating and operating crossword puzzles.

Downloads

6

Readme

WASM Crossword Generator

WASM Crossword Generator is a TypeScript library for the generation and operation of crossword puzzles. The main functionality is written in Rust, which is compiled to WASM with TypeScript types generated from the Rust types. The end result is completely portable and well-typed.

The underlying Rust code is found in the crate directory, it's published on it's own to crates.io and documentation is available.

This directory houses the src for the NPM package wasm_crossword_generator as well as the dist which appears in the NPM package.

An example site using this library can be viewed and played online here. The source of that site is meant to act as and example / demo and is found here.

To add this library to your NPM project.

$ npm install --save wasm_crossword_generator

The most basic usage of the library would look like:

import {CrosswordClient, SolutionConf} from "wasm_crossword_generator";
const client = await CrosswordClient.initialize();

const words = [{text: "library", clue: "Not a framework"}];
const conf: SolutionConf = {
  height: 10,
  width: 10,
  max_words: 20,
  initial_placement: null,
  words,
  // A real conf would almost certainly want to pass an options object here to enable retries,
  // but because we only have one word and no acceptance criteria, we know that the puzzle will be
  // created first try.
  requirements: null,
}

// The "PerWord" puzzle only requires players to guess a word, not a word and a placement. It also
// immediately informs the user if the guess was correct.
let puzzle_container = client.generate_crossword_puzzle(conf, "PerWord");

let guess = {
  word: {
    text: "library",
    // The clue is not checked as part of a guess for any Playmode.
    clue: null,
  },
  // The placement is ignored because it is a "PerWord" puzzle, but with other Playmodes
  // this would be meaningful.
  placement { x: 0, y: 0, direction: "Horizontal" },
};

// Note the need to re-assign to puzzle_container. This technique is used to pass ownership
// back and forth with WASM.
let guess_result = null;
{puzzle_container, guess_result} = client.guess_word(puzzle, guess);

// Because there is only one word in the "puzzle", the puzzle is "Complete" after one guess.
assert(guess_result == "Complete")

The playmodes are "Classic", "PlacedWord", and "PerWord". "Classic" doesn't tell the user if the guess is correct or not and allows the user to save (and later, remove) incorrect answers. "PlacedWord" does tell the user if the guess is correct at time of the guess. "PerWord" is like placed word, but does not check the "Placement" portion of a guess.

The CrosswordClient abstraction found here contains most of the information needed to define and run puzzles. There are other functions attached to the client, like wrong_answers_and_solutions and remove_answer.

The types defined here are useful for understanding.

Full TypeScript-side documentation forthcoming, until then please reference the Rust documentation, the structures and functions are identical.

Happy puzzling!