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

partzuf

v0.0.3

Published

partzuf

Downloads

2

Readme

Build Status

Partzuf

Simple proof-of-concept ECS in JS

Conceptually picks up where slotmap left off, but is still more like a proof of concept than a robust solution.

It's inspired by beach_map and EnTT

(and doesn't go near as far as either of those in terms of features or performance)

Results

The only way it becomes faster than native map is when the following are true:

  1. Entities are all aligned and sorted
  2. Components are mutated directly in ECS and not nativemap

If either of these are not true, then the ECS is significantly slower than using native map.

This could maybe be mitigated via groups, archetypes, etc. - but at the end of the day, JS boxes Array values and the Map iterator does some internal optimization. It's probably better to stick with C++/Rust/C for this sort of stuff

Installation

npm install --save partzuf

Usage

Docs can be generated via npm run doc, but they're not great.

  1. Initialize the ECS. Use typescript and supply every single component type here. The order will de-facto match what you use for ComponentId's later.
const ecs = init_ecs<[Label, Audio, Image]>(3);

The number is the number of component types

  1. Create consts for the indices (not required but makes life much easier)
const LABEL = 0;
const AUDIO = 1;
const IMAGE = 2;
  1. Instantiate entities, add components, iterate over subset of components, etc.

There's no hard limit to systems - you can jump around in whatever components you want:

for (const [entity, [t, r, s]] of ecs.iter_components([TRANSLATION, ROTATION, SCALE])) {
    const local_matrix = fromRotationTranslationScale(r, t, s);
    ecs.set_components([
        [LOCAL_MATRIX, local_matrix],
    ]) (entity);
}

Though it's better to update things mutably

See the tests and benchmark for examples

Notes on optimization and features

As noted above - there is no group/pack mechanism. Mainly because there's no way of manually aligning data in JS anyway, so if that level of hand-tuned optimization is required - use C++/Rust/C.

There's also a bunch of other features that would be nice to add, but aren't here (like boolean queries).