Package Exports
- simkit-core
- simkit-core/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (simkit-core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
simkit-core
A lightweight, type-safe Entity-Component-System (ECS) library for TypeScript
Performance
Latest benchmark results for version 0.7.5 (10/18/2025):
| Benchmark | Operations/sec |
|---|---|
| Packed Iteration (5 queries) | 9,615 |
| Simple Iteration | 3,320 |
| Fragmented Iteration | 11,225 |
| Entity Cycle | 3,370 |
| Add/Remove Component | 5,481 |
Benchmark Descriptions
- Packed Iteration (5 queries): Tests core iteration overhead with multiple queries on 1,000 entities
- Simple Iteration: Tests independent systems on entities with different component combinations
- Fragmented Iteration: Tests iteration through fragmented dataset (26 component types)
- Entity Cycle: Tests entity creation and destruction performance
- Add/Remove Component: Tests component addition and removal on existing entities
Benchmarks run on Node.js v22.20.0 on linux
Installation
Using npm
npm install simkit-coreUsing yarn
yarn add simkit-coreUsing pnpm
pnpm add simkit-coreFrom GitHub
npm install github:Pekmen/simkit-coreDevelopment Installation
If you want to contribute or run the examples:
# Clone the repository
git clone https://github.com/Pekmen/simkit-core.git
cd simkit-core
# Install dependencies
npm install
# Run tests
npm test
# Build the library
npm run build
# Run the example
npm run start examples/basic.tsFeatures
- 🚀 High Performance: Optimized for game development and simulations
- 🔒 Type Safe: Full TypeScript support with type inference
- 🧩 Simple API: Easy to learn and use
- 🔧 Flexible: Supports complex component relationships
- 📦 Lightweight: Minimal dependencies and small bundle size
Quick Start
import { World, System, defineComponent } from "simkit-core";
// Define components
interface Position {
x: number;
y: number;
}
interface Velocity {
dx: number;
dy: number;
}
const Position = defineComponent<Position>("Position", { x: 0, y: 0 });
const Velocity = defineComponent<Velocity>("Velocity", { dx: 0, dy: 0 });
// Create a system
class MovementSystem extends System {
update(deltaTime: number): void {
const entities = this.world.getAllEntities();
for (const entity of entities) {
const pos = this.world.getComponent(entity, Position);
const vel = this.world.getComponent(entity, Velocity);
if (pos && vel) {
pos.x += vel.dx * deltaTime;
pos.y += vel.dy * deltaTime;
}
}
}
}
// Create world and add system
const world = new World();
world.addSystem(new MovementSystem(world));
// Create entities
const player = world.createEntity();
world.addComponent(player, Position, { x: 0, y: 0 });
world.addComponent(player, Velocity, { dx: 1, dy: 1 });
// Run the simulation
world.update(16); // 16ms delta timeAPI Reference
World
The main ECS container that manages entities, components, and systems.
const world = new World();
// Entity management
const entity = world.createEntity();
world.destroyEntity(entity);
world.getAllEntities();
world.getEntityCount();
// Component management
world.addComponent(entity, ComponentType, data);
world.removeComponent(entity, ComponentType);
world.getComponent(entity, ComponentType);
world.hasComponent(entity, ComponentType);
// System management
world.addSystem(system);
world.update(deltaTime);defineComponent
Creates a component type with default values and type safety.
interface Health {
current: number;
max: number;
}
const Health = defineComponent<Health>("Health", {
current: 100,
max: 100,
});
// Usage
world.addComponent(entity, Health, { current: 80 }); // max will be 100System
Base class for creating systems that operate on entities and components.
class HealthSystem extends System {
update(deltaTime: number): void {
const entities = this.world.getAllEntities();
for (const entity of entities) {
const health = this.world.getComponent(entity, Health);
if (health && health.current <= 0) {
this.world.destroyEntity(entity);
}
}
}
}License
MIT