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

game-data-gen

v6.2.1

Published

A CLI code generator that creates Javascript (Typescript) data structures with zeroing functions.

Downloads

1,301

Readme

Game Data Generation

A CLI code generator that creates Javascript (Typescript) data structures with zeroing functions.

The problems

If you're making a game in Javascript then you might:

  • hit the garbage collector (GC) a bunch causing frame drops because you're creating/destroying objects every frame (particles, for example)
  • read a book about Data Oriented Design
  • notice the performance implications of OOP (especially classes and calling their methods) versus using something like Structure of Arrays
  • want to implement Structure of Arrays instead of Array of Structures (which is a list of class instances, see previous point)
  • notice that Javascript can not simply zero out data structures (resetting all data back to initial values) like languages such as C and Rust

The solution

This tool:

  • creates data structures based on Markdown file (see example below)
  • each data structure gets associated functions to zero out its memory so it can be reused

Installation

npm i -D game-data-gen

Usage

npx game-data-gen <input-file-path> <optional-output-file-path>

Types

Each block in the Markdown file starts with a heading that defines the type, followed by a list of fields.

Group

# <name> group

A set of module-level variables with individual setter and zero functions, plus a combined zero function.

| Field type | Description | | --------------- | --------------------------------------------------- | | string | A string primitive | | number | A number primitive | | boolean | A boolean primitive | | string[] | A dynamic array of strings | | number[] | A dynamic array of numbers | | boolean[] | A dynamic array of booleans | | string[] <n> | A fixed-length array of n strings | | number[] <n> | A fixed-length array of n numbers | | boolean[] <n> | A fixed-length array of n booleans | | <name> | A nested struct (must be defined before this group) | | <name>[] | A dynamic array of structs | | <name>[] <n> | A fixed-length array of n structs |

Fixed-length arrays are pre-populated on creation and their length is preserved when zeroed.

Structure of Arrays (SOA)

# <name> soa <capacity>

A set of typed arrays of fixed capacity, ideal for cache-friendly iteration over many elements.

| Field type | Typed array | | ---------- | -------------- | | int8 | Int8Array | | int16 | Int16Array | | int32 | Int32Array | | uint8 | Uint8Array | | uint16 | Uint16Array | | uint32 | Uint32Array | | float32 | Float32Array | | float64 | Float64Array |

Struct

# <name> struct

A TypeScript type with create and zero functions. Fields can be primitives, arrays, or other structs.

| Field type | Description | | --------------- | ---------------------------------------------------- | | string | A string primitive | | number | A number primitive | | boolean | A boolean primitive | | string[] | A dynamic array of strings | | number[] | A dynamic array of numbers | | boolean[] | A dynamic array of booleans | | string[] <n> | A fixed-length array of n strings | | number[] <n> | A fixed-length array of n numbers | | boolean[] <n> | A fixed-length array of n booleans | | <name> | A nested struct (must be defined before this struct) | | <name>[] | A dynamic array of structs | | <name>[] <n> | A fixed-length array of n structs |

Fixed-length arrays are pre-populated on creation and their length is preserved when zeroed.

Array of Structures (AOS)

# <name> aos <capacity> <struct>

A pre-allocated fixed-length array of struct objects.

Example

Create a Markdown file somewhere in your source code, for example src/data.md:

# game group

- score number
- isPaused boolean

# Vector struct

- x number
- y number

# Rectangle struct

- x number
- y number
- w number
- h number

# Entity struct

- name string
- health number
- position Vector
- hitbox Rectangle
- tags string[]
- isDestroyed boolean

# entities aos 64 Entity

Run the package with (consider making this a script in your package.json):

npx game-data-gen src/data.md

This will create or update the src/data.ts file. The data and functions can then be imported from this file into your code:

import { entities, zeroEntity } from "./data.ts";

for (const id in entities) {
  const e = entities[id];

  if (e.isDestroyed) {
    zeroEntity(e);
    continue;
  }
}