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.5 to 0.3.6

68

dist/index.es.js

@@ -1,2 +0,2 @@

const TYPE_ENUM = {
const TYPES_ENUM = {
i8: 'i8',

@@ -12,3 +12,3 @@ ui8: 'ui8',

};
const TYPE_NAME = {
const TYPES_NAMES = {
i8: 'Int8',

@@ -41,4 +41,2 @@ ui8: 'Uint8',

const roundToMultiple4 = x => Math.ceil(x / 4) * 4;
const $storeRef = Symbol('storeRef');

@@ -62,3 +60,3 @@ const $storeSize = Symbol('storeSize');

const resize = (ta, size) => {
const newBuffer = new SharedArrayBuffer(size * ta.BYTES_PER_ELEMENT);
const newBuffer = new ArrayBuffer(size * ta.BYTES_PER_ELEMENT);
const newTa = new ta.constructor(newBuffer);

@@ -76,7 +74,7 @@ newTa.set(ta, 0);

const summedLength = Array(arrayCount).fill(0).reduce((a, p) => a + length, 0); // for threaded impl
// const summedBytesPerElement = Array(arrayCount).fill(0).reduce((a, p) => a + TYPES[type].BYTES_PER_ELEMENT, 0)
// const totalBytes = roundToMultiple4(summedBytesPerElement * summedLength * size)
// const buffer = new ArrayBuffer(totalBytes)
const summedBytesPerElement = Array(arrayCount).fill(0).reduce((a, p) => a + TYPES[type].BYTES_PER_ELEMENT, 0);
const totalBytes = roundToMultiple4(summedBytesPerElement * summedLength * size);
const buffer = new SharedArrayBuffer(totalBytes);
const array = new TYPES[type](buffer);
const array = new TYPES[type](summedLength * size);
array.set(metadata[$storeSubarrays][type]);

@@ -86,3 +84,3 @@ metadata[$storeSubarrays][type] = array;

metadata[$storeSubarrays][type][$serializeShadow] = array.slice(0);
array[$indexType] = TYPE_NAME[indexType];
array[$indexType] = TYPES_NAMES[indexType];
array[$indexBytes] = TYPES[indexType].BYTES_PER_ELEMENT;

@@ -145,3 +143,3 @@ let end = 0;

const totalBytes = length * TYPES[type].BYTES_PER_ELEMENT;
const buffer = new SharedArrayBuffer(totalBytes);
const buffer = new ArrayBuffer(totalBytes);
return new TYPES[type](buffer);

@@ -162,11 +160,11 @@ };

const summedLength = Array(arrayCount).fill(0).reduce((a, p) => a + length, 0); // for threaded impl
// const summedBytesPerElement = Array(arrayCount).fill(0).reduce((a, p) => a + TYPES[type].BYTES_PER_ELEMENT, 0)
// const totalBytes = roundToMultiple4(summedBytesPerElement * summedLength * size)
// const buffer = new ArrayBuffer(totalBytes)
const summedBytesPerElement = Array(arrayCount).fill(0).reduce((a, p) => a + TYPES[type].BYTES_PER_ELEMENT, 0);
const totalBytes = roundToMultiple4(summedBytesPerElement * summedLength * size);
const buffer = new SharedArrayBuffer(totalBytes);
const array = new TYPES[type](buffer);
const array = new TYPES[type](summedLength * size);
metadata[$storeSubarrays][type] = array;
metadata[$storeSubarrays][type][$queryShadow] = array.slice(0);
metadata[$storeSubarrays][type][$serializeShadow] = array.slice(0);
array[$indexType] = TYPE_NAME[indexType];
array[$indexType] = TYPES_NAMES[indexType];
array[$indexBytes] = TYPES[indexType].BYTES_PER_ELEMENT;

@@ -187,3 +185,3 @@ } // pre-generate subarrays for each eid

store[eid][$subarray] = true;
store[eid][$indexType] = TYPE_NAME[indexType];
store[eid][$indexType] = TYPES_NAMES[indexType];
store[eid][$indexBytes] = TYPES[indexType].BYTES_PER_ELEMENT;

@@ -262,7 +260,5 @@ end = to;

metadata[$storeFlattened].push(a[k]);
Object.seal(a[k]);
metadata[$storeFlattened].push(a[k]); // Object.freeze(a[k])
} else if (a[k] instanceof Object) {
a[k] = Object.keys(a[k]).reduce(recursiveTransform, a[k]);
Object.seal(a[k]);
a[k] = Object.keys(a[k]).reduce(recursiveTransform, a[k]); // Object.freeze(a[k])
}

@@ -275,5 +271,5 @@

stores[$store][$storeBase] = () => stores[$store];
stores[$store][$storeBase] = () => stores[$store]; // Object.freeze(stores[$store])
Object.seal(stores[$store]);
return stores[$store];

@@ -319,4 +315,3 @@ }

const buffer = new ArrayBuffer(maxBytes);
const view = new DataView(buffer); // const write = defineWriter(view, componentProps, changedProps)
const view = new DataView(buffer);
return ents => {

@@ -344,16 +339,3 @@ if (resized) {

if (!ents.length) return; // view.where = 0
// // save space for entity count
// const countWhere = where
// view.where += 4
// // write eid,val,val,val..., eid,val,val...
// for (let i = 0; i < ents.length; i++) {
// const eid = ents[i]
// write(world, eid)
// }
// // view.setUint32(countWhere, count)
// const end = view.where
// view.where = 0
// return buffer.slice(0, end)
if (!ents.length) return;
let where = 0; // iterate over component props

@@ -819,9 +801,9 @@

const $componentMap = Symbol('componentMap');
const storeComponents = [];
const components = [];
const resizeComponents = size => {
storeComponents.forEach(component => resizeStore(component, size));
components.forEach(component => resizeStore(component, size));
};
const defineComponent = schema => {
const component = createStore(schema, defaultSize);
if (schema && Object.keys(schema).length) storeComponents.push(component);
if (schema && Object.keys(schema).length) components.push(component);
return component;

@@ -978,5 +960,5 @@ };

};
const Types = TYPE_ENUM;
const Types = TYPES_ENUM;
export { Changed, Not, Types, addComponent, addEntity, commitRemovals, createWorld, defineComponent, defineDeserializer, defineQuery, defineSerializer, defineSystem, enterQuery, exitQuery, hasComponent, pipe, registerComponent, registerComponents, removeComponent, removeEntity };
//# sourceMappingURL=index.es.js.map

@@ -5,3 +5,3 @@ 'use strict';

const TYPE_ENUM = {
const TYPES_ENUM = {
i8: 'i8',

@@ -17,3 +17,3 @@ ui8: 'ui8',

};
const TYPE_NAME = {
const TYPES_NAMES = {
i8: 'Int8',

@@ -46,4 +46,2 @@ ui8: 'Uint8',

const roundToMultiple4 = x => Math.ceil(x / 4) * 4;
const $storeRef = Symbol('storeRef');

@@ -67,3 +65,3 @@ const $storeSize = Symbol('storeSize');

const resize = (ta, size) => {
const newBuffer = new SharedArrayBuffer(size * ta.BYTES_PER_ELEMENT);
const newBuffer = new ArrayBuffer(size * ta.BYTES_PER_ELEMENT);
const newTa = new ta.constructor(newBuffer);

@@ -81,7 +79,7 @@ newTa.set(ta, 0);

const summedLength = Array(arrayCount).fill(0).reduce((a, p) => a + length, 0); // for threaded impl
// const summedBytesPerElement = Array(arrayCount).fill(0).reduce((a, p) => a + TYPES[type].BYTES_PER_ELEMENT, 0)
// const totalBytes = roundToMultiple4(summedBytesPerElement * summedLength * size)
// const buffer = new ArrayBuffer(totalBytes)
const summedBytesPerElement = Array(arrayCount).fill(0).reduce((a, p) => a + TYPES[type].BYTES_PER_ELEMENT, 0);
const totalBytes = roundToMultiple4(summedBytesPerElement * summedLength * size);
const buffer = new SharedArrayBuffer(totalBytes);
const array = new TYPES[type](buffer);
const array = new TYPES[type](summedLength * size);
array.set(metadata[$storeSubarrays][type]);

@@ -91,3 +89,3 @@ metadata[$storeSubarrays][type] = array;

metadata[$storeSubarrays][type][$serializeShadow] = array.slice(0);
array[$indexType] = TYPE_NAME[indexType];
array[$indexType] = TYPES_NAMES[indexType];
array[$indexBytes] = TYPES[indexType].BYTES_PER_ELEMENT;

@@ -150,3 +148,3 @@ let end = 0;

const totalBytes = length * TYPES[type].BYTES_PER_ELEMENT;
const buffer = new SharedArrayBuffer(totalBytes);
const buffer = new ArrayBuffer(totalBytes);
return new TYPES[type](buffer);

@@ -167,11 +165,11 @@ };

const summedLength = Array(arrayCount).fill(0).reduce((a, p) => a + length, 0); // for threaded impl
// const summedBytesPerElement = Array(arrayCount).fill(0).reduce((a, p) => a + TYPES[type].BYTES_PER_ELEMENT, 0)
// const totalBytes = roundToMultiple4(summedBytesPerElement * summedLength * size)
// const buffer = new ArrayBuffer(totalBytes)
const summedBytesPerElement = Array(arrayCount).fill(0).reduce((a, p) => a + TYPES[type].BYTES_PER_ELEMENT, 0);
const totalBytes = roundToMultiple4(summedBytesPerElement * summedLength * size);
const buffer = new SharedArrayBuffer(totalBytes);
const array = new TYPES[type](buffer);
const array = new TYPES[type](summedLength * size);
metadata[$storeSubarrays][type] = array;
metadata[$storeSubarrays][type][$queryShadow] = array.slice(0);
metadata[$storeSubarrays][type][$serializeShadow] = array.slice(0);
array[$indexType] = TYPE_NAME[indexType];
array[$indexType] = TYPES_NAMES[indexType];
array[$indexBytes] = TYPES[indexType].BYTES_PER_ELEMENT;

@@ -192,3 +190,3 @@ } // pre-generate subarrays for each eid

store[eid][$subarray] = true;
store[eid][$indexType] = TYPE_NAME[indexType];
store[eid][$indexType] = TYPES_NAMES[indexType];
store[eid][$indexBytes] = TYPES[indexType].BYTES_PER_ELEMENT;

@@ -267,7 +265,5 @@ end = to;

metadata[$storeFlattened].push(a[k]);
Object.seal(a[k]);
metadata[$storeFlattened].push(a[k]); // Object.freeze(a[k])
} else if (a[k] instanceof Object) {
a[k] = Object.keys(a[k]).reduce(recursiveTransform, a[k]);
Object.seal(a[k]);
a[k] = Object.keys(a[k]).reduce(recursiveTransform, a[k]); // Object.freeze(a[k])
}

@@ -280,5 +276,5 @@

stores[$store][$storeBase] = () => stores[$store];
stores[$store][$storeBase] = () => stores[$store]; // Object.freeze(stores[$store])
Object.seal(stores[$store]);
return stores[$store];

@@ -324,4 +320,3 @@ }

const buffer = new ArrayBuffer(maxBytes);
const view = new DataView(buffer); // const write = defineWriter(view, componentProps, changedProps)
const view = new DataView(buffer);
return ents => {

@@ -349,16 +344,3 @@ if (resized) {

if (!ents.length) return; // view.where = 0
// // save space for entity count
// const countWhere = where
// view.where += 4
// // write eid,val,val,val..., eid,val,val...
// for (let i = 0; i < ents.length; i++) {
// const eid = ents[i]
// write(world, eid)
// }
// // view.setUint32(countWhere, count)
// const end = view.where
// view.where = 0
// return buffer.slice(0, end)
if (!ents.length) return;
let where = 0; // iterate over component props

@@ -824,9 +806,9 @@

const $componentMap = Symbol('componentMap');
const storeComponents = [];
const components = [];
const resizeComponents = size => {
storeComponents.forEach(component => resizeStore(component, size));
components.forEach(component => resizeStore(component, size));
};
const defineComponent = schema => {
const component = createStore(schema, defaultSize);
if (schema && Object.keys(schema).length) storeComponents.push(component);
if (schema && Object.keys(schema).length) components.push(component);
return component;

@@ -983,3 +965,3 @@ };

};
const Types = TYPE_ENUM;
const Types = TYPES_ENUM;

@@ -986,0 +968,0 @@ exports.Changed = Changed;

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

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

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