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

htdp-universe-js

v1.0.4

Published

A port of Racket's htdp/universe library to JavaScript

Downloads

10

Readme

htdp/universe JavaScript Wrapper

MIT licensed RacketScript

An experimental wrapper written for RacketScript's htdp/universe and htdp/image modules, so that they can be used in vanilla JavaScript. :)

Quick Install and Setup

Set up an environment using Vite.js

First, set up a development environment using vite.js and install the htdp-universe-js package from npm.

# Set up a JS project using Vite.js
npx create-vite@latest htdp-universe-test --template vanilla
cd htdp-universe-test
npm install

# Install htdp-universe-js package from npm
npm install htdp-universe-js

Next, paste this code into main.js in the /htdp-universe-test directory.


// Basic clicker example

import {
  bigBang,
  toDraw,
  onMouse,
  emptyScene,
  text,
  overlay
} from "htdp-universe-js";

const INIT_STATE = 0;
const FONT_SIZE = 30;
const TEXT_COLOR = "black";
const WIDTH = 1000;
const HEIGHT = 1000;

const draw = toDraw((ws) => {
  return overlay(
    text(`${ws}`, FONT_SIZE, TEXT_COLOR),
    emptyScene(WIDTH, HEIGHT, "gray"),
  );
  });

const handleMouse = onMouse((ws, xPos, yPos, eventType) => {
  if (eventType === 'button-down') {
    return ws + 1;
  } else{
    return ws;
  }
})

bigBang(INIT_STATE, draw, handleMouse);

Now run the vite dev server by pasting this command into the terminal.

# Run the vite.js dev server
npm run dev

Finally, open a browser window to http://localhost:5173 to see the example running!

Other Information

An example implementation of Snake using this library can be found here!

View the package on the npm registry