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

js13k-ecs

v0.1.4

Published

Tiny 1kb entity component system, designed for js13k

Downloads

18

Readme

js13k-ecs

A 1kb entity component system, designed for js13k.

NPM versionBuild Status

  • Tiny: weighs about one kilobyte gzipped

Install

This project uses node and npm. Go check them out if you don't have them locally installed.

$ npm install js13k-ecs

Then with a module bundler like rollup or webpack, use as you would anything else:

// using ES6 modules
import ecs from 'js13k-ecs';

// using CommonJS modules
var ecs = require('js13k-ecs');

The UMD build is also available on unpkg:

<script src="https://unpkg.com/js13k-ecs/dist/ecs.umd.js"></script>

You can find the library on window.ecs.

Usage

See example folder. Live example

API

ecs

register(...Components)

Registers components for use by the library. Components must be classes or constructor functions. No other requirements are imposed on the components.

process(...systems)

Adds systems for use by the library. Systems must be instances of classes or objects. Systems must implement the update method.

create(id)

Creates the entity with the specified id. If id is not specified, serial numbers starting with 1 are generated and encoded in base36. Returns the created entity.

get(id)

Returns the entity with the specified id or undefined if it is not present.

select(...Components)

Returns a selection of entities that have the specified set of components. The sample is updated real-time and always relevant.

The selector has the length property, which stores the number of entities in the sample and the iterate(fn) method, with which you can loop through all entities.

update(delta)

Successively calls update methods on all systems, passing them the delta parameter. Returns the object that contains the duration of the execution of the systems.

Entity

add(...components)

Adds the components to the entity.

remove(...Components)

Removes components of the Components class from the entity. Calls the destructor method of each component if it is present.

has(Component)

Returns true if the entity has a component of the Component class and false otherwise.

get(Component)

Returns a component of the Component class or undefined if it is not present.

eject()

Removes the entity from all selectors and sets its id to zero. Calls the destructor method of each component if it is present.