Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More โ†’
Socket
Sign inDemoInstall
Socket

bitecs

Package Overview
Dependencies
Maintainers
1
Versions
133
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bitecs - npm Package Compare versions

Comparing version 0.3.16-2 to 0.3.16-3

15

dist/index.es.js

@@ -168,4 +168,4 @@ const TYPES_ENUM = {

const indexType = length < UNSIGNED_MAX.uint8 ? 'ui8' : length < UNSIGNED_MAX.uint16 ? 'ui16' : 'ui32';
if (!length) throw new Error('โŒ Must define a length for component array.');
if (!TYPES[type]) throw new Error(`โŒ Invalid component array property type ${type}.`); // create buffer for type if it does not already exist
if (!length) throw new Error('bitECS - Must define component array length');
if (!TYPES[type]) throw new Error(`bitECS - Invalid component array property type ${type}`); // create buffer for type if it does not already exist

@@ -335,3 +335,3 @@ if (!metadata[$storeSubarrays][type]) {

componentProps = target.map(p => {
if (!p) throw new Error('๐Ÿ‘พ bitECS - undefined component passed into serializer.');
if (!p) throw new Error('bitECS - Cannot serializer undefined component');

@@ -530,8 +530,3 @@ if (typeof p === 'function' && p.name === 'QueryChanged') {

where += 4;
let newEid = newEntities.get(eid);
if (newEid !== undefined) {
eid = newEid;
}
if (mode === DESERIALIZE_MODE.MAP) {

@@ -551,3 +546,3 @@ if (localEntities.has(eid)) {

if (mode === DESERIALIZE_MODE.APPEND || mode === DESERIALIZE_MODE.REPLACE && !world[$entitySparseSet].has(eid)) {
const newEid = addEntity(world);
const newEid = newEntities.get(eid) || addEntity(world);
newEntities.set(eid, newEid);

@@ -990,3 +985,3 @@ eid = newEid;

const registerComponent = (world, component) => {
if (!component) throw new Error(`๐Ÿ‘พ bitECS - cannot register component as it is null or undefined.`);
if (!component) throw new Error(`bitECS - Cannot register null or undefined component`);
const queries = new Set();

@@ -993,0 +988,0 @@ const notQueries = new Set();

@@ -172,4 +172,4 @@ 'use strict';

const indexType = length < UNSIGNED_MAX.uint8 ? 'ui8' : length < UNSIGNED_MAX.uint16 ? 'ui16' : 'ui32';
if (!length) throw new Error('โŒ Must define a length for component array.');
if (!TYPES[type]) throw new Error(`โŒ Invalid component array property type ${type}.`); // create buffer for type if it does not already exist
if (!length) throw new Error('bitECS - Must define component array length');
if (!TYPES[type]) throw new Error(`bitECS - Invalid component array property type ${type}`); // create buffer for type if it does not already exist

@@ -339,3 +339,3 @@ if (!metadata[$storeSubarrays][type]) {

componentProps = target.map(p => {
if (!p) throw new Error('๐Ÿ‘พ bitECS - undefined component passed into serializer.');
if (!p) throw new Error('bitECS - Cannot serializer undefined component');

@@ -534,8 +534,3 @@ if (typeof p === 'function' && p.name === 'QueryChanged') {

where += 4;
let newEid = newEntities.get(eid);
if (newEid !== undefined) {
eid = newEid;
}
if (mode === DESERIALIZE_MODE.MAP) {

@@ -555,3 +550,3 @@ if (localEntities.has(eid)) {

if (mode === DESERIALIZE_MODE.APPEND || mode === DESERIALIZE_MODE.REPLACE && !world[$entitySparseSet].has(eid)) {
const newEid = addEntity(world);
const newEid = newEntities.get(eid) || addEntity(world);
newEntities.set(eid, newEid);

@@ -994,3 +989,3 @@ eid = newEid;

const registerComponent = (world, component) => {
if (!component) throw new Error(`๐Ÿ‘พ bitECS - cannot register component as it is null or undefined.`);
if (!component) throw new Error(`bitECS - Cannot register null or undefined component`);
const queries = new Set();

@@ -997,0 +992,0 @@ const notQueries = new Set();

@@ -1,1 +0,10 @@

strings
# FAQ
Q: How does this ECS differ from other libraries?
A: Iteration performance. See benchmarks.
Q: Why are there no string types for components?
A: Strings are expensive and unnecessary to serialize.
Q: How do I handle strings?
A: Map integers to string values, and store the integers on components. This makes string serialization minimal and fast.

@@ -50,2 +50,32 @@

```
<a name="createWorld"></a>
## createWorld โ‡’ <code>object</code>
> Creates a new world.
<a name="resetWorld"></a>
## resetWorld โ‡’ <code>object</code>
> Resets a world.
| Param | Type |
| --- | --- |
| world | <code>World</code> |
<a name="deleteWorld"></a>
## deleteWorld
> Deletes a world.
| Param | Type |
| --- | --- |
| world | <code>World</code> |
## ๐Ÿ‘พ Entity

@@ -217,2 +247,36 @@

## ๐ŸŽญ Component Proxy
Component proxies are a way to interact with component data using regular objects (not to be confused with JavaScript's `Proxy`, but the behavior is basically identical).
This enables cleaner syntax and easier interop with other libraries, but comes at the cost of performance.
```js
const PositionProxy = defineProxy(Position)
const position = new PositionProxy(eid)
position.x = 123
console.log(Position.x[eid]) // => 123
```
Instances should be reused to maximize iteration performance:
```js
const systemA = defineSystem(world => {
const ents = query(world)
for (let i = 0; i < ents.length; i++) {
const eid = ents[i]
// load data for this eid into reused proxy instances
loadProxy(position, eid)
loadProxy(velocity, eid)
position.x += velocity.x
position.y += velocity.y
}
})
```
## ๐Ÿ’พ Serialization

@@ -219,0 +283,0 @@

{
"name": "bitecs",
"version": "0.3.16-2",
"version": "0.3.16-3",
"description": "Functional, minimal, data-driven, ultra-high performance ECS library written in Javascript",

@@ -5,0 +5,0 @@ "license": "MPL-2.0",

@@ -41,1 +41,41 @@ # ๐Ÿ‘พ bitECS ๐Ÿ‘พ [![npm](https://img.shields.io/npm/v/bitecs.svg)](https://www.npmjs.com/package/bitecs) [![Minzipped](https://badgen.net/bundlephobia/minzip/bitecs)](https://www.npmjs.com/package/bitecs) [![npm](https://img.shields.io/npm/dt/bitecs.svg)](https://www.npmjs.com/package/bitecs) [![License](https://badgen.net/npm/license/bitecs)](https://www.npmjs.com/package/bitecs)

| ๐Ÿ“˜ [API Documentation](https://github.com/NateTheGreatt/bitECS/blob/master/docs/API.md) |
## ๐Ÿ•น Example
```js
import {
createWorld,
addEntity,
defineComponent,
addComponent,
defineQuery,
defineSystem,
Types,
} from 'bitecs'
const world = createWorld()
const Vector3 = { x: Types.f32, y: Types.f32, z: Types.f32 }
const Position = defineComponent(Vector3)
const Velocity = defineComponent(Vector3)
const eid = addEntity(world)
addComponent(world, Position, eid)
addComponent(world, Velocity, eid)
const movementSystem = defineSystem((world) => {
const ents = movementQuery(world)
for (let i = 0; i < ents.length; i++) {
const eid = ents[i]
Position.x[eid] += Velocity.x[eid]
Position.y[eid] += Velocity.y[eid]
Position.z[eid] += Velocity.z[eid]
}
})
setInterval(() => {
movementSystem(world)
}, 16)
```

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with โšก๏ธ by Socket Inc