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.2.16 to 0.2.18

43

dist/index.es.js

@@ -49,2 +49,3 @@ const TYPES_ENUM = {

const $storeFlattened = Symbol('storeFlattened');
const $storeBase = Symbol('storeBase');
const $storeArrayCount = Symbol('storeArrayCount');

@@ -165,2 +166,3 @@ const $storeSubarrays = Symbol('storeSubarrays');

const isArrayType = x => Array.isArray(x) && typeof x[0] === 'object' && x[0].hasOwnProperty('type') && x[0].hasOwnProperty('length');
const createStore = (schema, size = 1000000) => {

@@ -199,19 +201,9 @@ const $store = Symbol('store');

if (typeof schema === 'string') {
stores[$store] = Object.assign(createTypeStore(schema, size), metadata);
metadata[$storeFlattened].push(stores[$store]);
createShadows(stores[$store]);
return stores[$store];
} else if (isArrayType(schema)) {
const {
type,
length
} = schema[0];
stores[$store] = Object.assign(createArrayStore(metadata, type, length), metadata);
metadata[$storeFlattened].push(stores[$store]);
return stores[$store];
} else if (schema instanceof Object && Object.keys(schema).length) {
if (schema instanceof Object && Object.keys(schema).length) {
const recursiveTransform = (a, k) => {
if (typeof a[k] === 'string') {
a[k] = createTypeStore(a[k], size);
a[k][$storeBase] = () => stores[$store];
metadata[$storeFlattened].push(a[k]);

@@ -225,2 +217,5 @@ createShadows(a[k]);

a[k] = createArrayStore(metadata, type, length);
a[k][$storeBase] = () => stores[$store];
metadata[$storeFlattened].push(a[k]);

@@ -235,2 +230,5 @@ } else if (a[k] instanceof Object) {

stores[$store] = Object.assign(Object.keys(schema).reduce(recursiveTransform, schema), metadata);
stores[$store][$storeBase] = () => stores[$store];
return stores[$store];

@@ -434,3 +432,3 @@ }

const [componentProps] = canonicalize(target);
return packet => {
return (world, packet) => {
const view = new DataView(packet);

@@ -450,5 +448,16 @@ let where = 0;

for (let i = 0; i < entityCount; i++) {
const eid = view.getUint32(where);
where += 4;
let eid = view.getUint32(where);
where += 4; // if this world hasn't seen this eid yet
if (!world[$entityEnabled][eid]) {
// make a new entity for the data
eid = addEntity(world);
}
const component = ta[$storeBase]();
if (!hasComponent(world, component, eid)) {
addComponent(world, component, eid);
}
if (ArrayBuffer.isView(ta[eid])) {

@@ -455,0 +464,0 @@ const array = ta[eid];

@@ -53,2 +53,3 @@ 'use strict';

const $storeFlattened = Symbol('storeFlattened');
const $storeBase = Symbol('storeBase');
const $storeArrayCount = Symbol('storeArrayCount');

@@ -169,2 +170,3 @@ const $storeSubarrays = Symbol('storeSubarrays');

const isArrayType = x => Array.isArray(x) && typeof x[0] === 'object' && x[0].hasOwnProperty('type') && x[0].hasOwnProperty('length');
const createStore = (schema, size = 1000000) => {

@@ -203,19 +205,9 @@ const $store = Symbol('store');

if (typeof schema === 'string') {
stores[$store] = Object.assign(createTypeStore(schema, size), metadata);
metadata[$storeFlattened].push(stores[$store]);
createShadows(stores[$store]);
return stores[$store];
} else if (isArrayType(schema)) {
const {
type,
length
} = schema[0];
stores[$store] = Object.assign(createArrayStore(metadata, type, length), metadata);
metadata[$storeFlattened].push(stores[$store]);
return stores[$store];
} else if (schema instanceof Object && Object.keys(schema).length) {
if (schema instanceof Object && Object.keys(schema).length) {
const recursiveTransform = (a, k) => {
if (typeof a[k] === 'string') {
a[k] = createTypeStore(a[k], size);
a[k][$storeBase] = () => stores[$store];
metadata[$storeFlattened].push(a[k]);

@@ -229,2 +221,5 @@ createShadows(a[k]);

a[k] = createArrayStore(metadata, type, length);
a[k][$storeBase] = () => stores[$store];
metadata[$storeFlattened].push(a[k]);

@@ -239,2 +234,5 @@ } else if (a[k] instanceof Object) {

stores[$store] = Object.assign(Object.keys(schema).reduce(recursiveTransform, schema), metadata);
stores[$store][$storeBase] = () => stores[$store];
return stores[$store];

@@ -438,3 +436,3 @@ }

const [componentProps] = canonicalize(target);
return packet => {
return (world, packet) => {
const view = new DataView(packet);

@@ -454,5 +452,16 @@ let where = 0;

for (let i = 0; i < entityCount; i++) {
const eid = view.getUint32(where);
where += 4;
let eid = view.getUint32(where);
where += 4; // if this world hasn't seen this eid yet
if (!world[$entityEnabled][eid]) {
// make a new entity for the data
eid = addEntity(world);
}
const component = ta[$storeBase]();
if (!hasComponent(world, component, eid)) {
addComponent(world, component, eid);
}
if (ArrayBuffer.isView(ta[eid])) {

@@ -459,0 +468,0 @@ const array = ta[eid];

{
"name": "bitecs",
"version": "0.2.16",
"version": "0.2.18",
"description": "Tiny, data-driven, high performance ECS library written in Javascript",

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

@@ -5,20 +5,30 @@ # ๐Ÿ‘พ bitECS ๐Ÿ‘พ

## Features
๐Ÿ”ฎ Functional
๐Ÿค `<3kb` gzipped
๐Ÿ”ฎ Simple & functional API
๐Ÿ™…โ€โ™‚๏ธ Zero dependencies
๐Ÿ”ฅ Blazing fast iteration
๐Ÿ’พ Serialization
๐Ÿ” Powerful & performant queries
โœจ Queries with modifiers
๐Ÿ’พ Swift serialization
๐Ÿƒ Zero dependencies
๐ŸŒ Node or browser
๐Ÿ”ฅ Blazing fast
๐Ÿค `~5kb` gzipped
- [ecs-benchmark](https://github.com/noctjs/ecs-benchmark)
- [js-ecs-benchmark](https://github.com/ddmills/js-ecs-benchmark)
๐Ÿš€ Unparalleled performance
- [noctjs/ecs-benchmark](https://github.com/noctjs/ecs-benchmark)
- [ddmills/js-ecs-benchmarks](https://github.com/ddmills/js-ecs-benchmarks)
### In Development
๐Ÿงต Multithreading
## Install

@@ -29,2 +39,3 @@ ```

## Example

@@ -72,2 +83,4 @@

// can store whatever you need on the world
world.metadata = 123

@@ -140,3 +153,3 @@ /**

/**
* Entity
* addEntity
*

@@ -202,7 +215,8 @@ * An entity is a single ID which components can be associated with.

// deserializes the state back onto the world
// note: creates entities/components if they do not exist
deserialize(world, packet)
// creates a serializer/deserializer which will serialize select component stores
const serializePositions = createSerializer([Positions])
const deserializePositions = createDeserializer([Positions])
const serializePositions = createSerializer([Position])
const deserializePositions = createDeserializer([Position])

@@ -213,7 +227,7 @@ // serializes the Position data of entities which match the movementQuery

// deserializes the Position data back onto the world
deserializePositions(packet)
deserializePositions(world, packet)
// creates a serializer which will serialize select component stores of entities
// whose component state has changed since the last call of the function
const serializeOnlyChangedPositions = createSerializer([Changed(Positions)])
const serializeOnlyChangedPositions = createSerializer([Changed(Position)])

@@ -225,3 +239,1 @@ // serializes the Position data of entities which match the movementQuery

```
Full documentation and feature rich examples can be found [here](DOCS.md).

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