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 🙏

© 2026 – Pkg Stats / Ryan Hefner

like2d

v2.0.1

Published

A web-native game framework inspired by Love2D

Downloads

105

Readme

LÏKE2D

A web-native 2D game framework inspired by LÖVE, built for simplicity and the modern web.

What it is

Like2D is a thin, performant wrapper around the browser's Canvas and Web Audio APIs. It provides:

  • Stateless Graphics: No more ctx.save() and ctx.restore() for colors and transforms.
  • Fire-and-forget Assets: Synchronous handles for images and audio that load in the background.
  • Unified Input: Normalized keyboard, mouse, and gamepad support with action mapping.
  • Scaling Modes: Built-in support for "fixed" resolution with pixel-perfect stretching.
  • Flexible Patterns: Use Love2D-style global callbacks or class-based scenes.

Installation

npm install like2d
# or
pnpm add like2d

Quick Start

Callback Pattern (Love2D-style)

Ideal for small games, jams, or prototyping.

import { love, graphics, input } from 'like2d/callback';

love.load = () => {
  love.setScaling({ mode: 'fixed', size: [800, 600] });
  input.map('jump', ['Space', 'ButtonBottom']);
};

love.update = (dt) => {
  if (input.justPressed('jump')) {
    console.log('Jump!');
  }
};

love.draw = () => {
  graphics.clear([0.1, 0.1, 0.1, 1]);
  graphics.circle('fill', 'dodgerblue', [400, 300], 50);
  graphics.print('white', 'Hello Like2D!', [20, 20]);
};

love.init(document.body);

Scene Pattern (Class-based)

Ideal for larger projects with menus, levels, and explicit state management.

import { SceneRunner, type Scene, Vec2 } from 'like2d/scene';

class MyScene implements Scene {
  load() {
    console.log('Scene loaded!');
  }

  update(dt: number) {
    // update logic
  }

  draw(canvas: HTMLCanvasElement) {
    // draw logic
  }
}

const runner = new SceneRunner(document.body);
await runner.start(new MyScene());

API Overview

Like2D exports pure library functions for math and geometry that work with native arrays.

  • Vec2: Vector operations using [number, number] tuples.
  • Rect: Rectangle operations using [x, y, w, h] tuples.
  • Graphics: Stateless drawing commands.
  • Audio: Simple source/playback management.
  • Input: Action-based input mapping.

See the PHILOSOPHY.md for the principles behind the design.

Quick Start Template

Get started quickly with the Like2D Starter template!

License

MIT