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.8 to 0.3.9

19

dist/index.d.ts
declare module 'bitecs' {
export type Type =
'bool' |
'i8' |

@@ -39,3 +38,2 @@ 'ui8' |

export type ArrayByType = {
['bool']: boolean[];
[Types.i8]: Int8Array;

@@ -76,3 +74,3 @@ [Types.ui8]: Uint8Array;

export type Query = (world: IWorld) => number[]
export type Query = (world: IWorld, clearDiff: Boolean = true) => number[]

@@ -82,4 +80,7 @@ export type System = (world: IWorld) => IWorld

export function createWorld(size?: number): IWorld
export function resetWorld(world: IWorld): IWorld
export function deleteWorld(world: IWorld): void
export function addEntity(world: IWorld): number
export function removeEntity(world: IWorld, eid: number): void
export function registerComponent(world: IWorld, component: Component): void

@@ -91,2 +92,3 @@ export function registerComponents(world: IWorld, components: Component[]): void

export function hasComponent(world: IWorld, component: Component, eid: number): boolean
export function defineQuery(components: (Component | QueryModifier)[]): Query

@@ -97,7 +99,12 @@ export function Changed(c: Component): Component | QueryModifier

export function exitQuery(query: Query): Query
export function resetChangedQuery(world: IWorld, query: Query): Query
export function removeQuery(world: IWorld, query: Query): Query
export function commitRemovals(world: IWorld): void
export function defineSystem(update: (world: IWorld, ...args: any[]) => IWorld): System
export function defineSerializer(target: IWorld | Component | IComponentProp | QueryModifier, maxBytes?: number): (target: IWorld | number[]) => ArrayBuffer
export function defineDeserializer(target: IWorld | Component | IComponentProp | QueryModifier): (world: IWorld, packet: ArrayBuffer) => void
export function pipe(...fns: ((...args: any[]) => any)[]): (input: any) => any
export function defineSerializer(target: IWorld | Component[] | IComponentProp[] | QueryModifier, maxBytes?: number): (target: IWorld | number[]) => ArrayBuffer
export function defineDeserializer(target: IWorld | Component[] | IComponentProp[] | QueryModifier): (world: IWorld, packet: ArrayBuffer) => void
export function pipe(...fns: ((...args: any[]) => any)[]): (...input: any[]) => any
}

@@ -145,3 +145,3 @@ const TYPES_ENUM = {

const contiguousArray = store => store[$parentArray];
const parentArray = store => store[$parentArray];

@@ -626,2 +626,3 @@ const createArrayStore = (metadata, type, length) => {

const entities = [];
const archetypes = [];
const changed = [];

@@ -653,4 +654,7 @@ const indices = new Uint32Array(size).fill(NONE);

return a;
}, {});
const flatProps = components.map(c => Object.getOwnPropertySymbols(c).includes($storeFlattened) ? c[$storeFlattened] : [c]).reduce((a, v) => a.concat(v), []);
}, {}); // const orMasks = orComponents
// .map(mapComponents)
// .reduce(reduceBitmasks, {})
const flatProps = components.filter(c => !c[$tagStore]).map(c => Object.getOwnPropertySymbols(c).includes($storeFlattened) ? c[$storeFlattened] : [c]).reduce((a, v) => a.concat(v), []);
const toRemove = [];

@@ -668,2 +672,3 @@ const entered = [];

notMasks,
// orMasks,
generations,

@@ -674,3 +679,4 @@ indices,

entered,
exited
exited,
archetypes
});

@@ -742,3 +748,3 @@ world[$queries].add(query);

generations
} = world[$queryMap].get(query);
} = world[$queryMap].get(query); // let or = true

@@ -748,3 +754,4 @@ for (let i = 0; i < generations.length; i++) {

const qMask = masks[generationId];
const qNotMask = notMasks[generationId];
const qNotMask = notMasks[generationId]; // const qOrMask = orMasks[generationId]
const eMask = world[$entityMasks][generationId][eid];

@@ -754,4 +761,7 @@

return false;
}
} // if (qOrMask && (eMask & qOrMask) !== qOrMask) {
// continue
// }
if (qMask && (eMask & qMask) !== qMask) {

@@ -780,4 +790,3 @@ return false;

q.entities.push(eid);
q.indices[eid] = q.entities.length - 1; // TODO: pop swap so dupes don't enter
q.indices[eid] = q.entities.length - 1;
q.entered.push(eid);

@@ -814,6 +823,12 @@ };

q.toRemove.push(eid);
world[$dirtyQueries].add(q); // TODO: pop swap so dupes don't enter (in the case where an EID is removed twice before query is called again)
world[$dirtyQueries].add(q);
q.exited.push(eid);
};
const resetChangedQuery = (world, query) => {
const q = world[$queryMap].get(query);
q.changed.length = 0;
};
const removeQuery = (world, query) => {
world[$queryMap].delete(query);
};

@@ -936,2 +951,7 @@ const $componentMap = Symbol('componentMap');

const world = {};
resetWorld(world);
worlds.push(world);
return world;
};
const resetWorld = world => {
const size = getGlobalSize();

@@ -948,5 +968,20 @@ world[$size] = size;

world[$dirtyQueries] = new Set();
worlds.push(world);
return world;
};
const deleteWorld = world => {
delete world[$size];
delete world[$entityEnabled];
delete world[$entityMasks];
delete world[$entityArray];
delete world[$entityIndices];
delete world[$bitflag];
delete world[$componentMap];
delete world[$queryMap];
delete world[$queries];
delete world[$dirtyQueries];
Object.keys(world).forEach(key => {
delete world[key];
});
worlds.splice(worlds.indexOf(world), 1);
};

@@ -976,4 +1011,5 @@ const defineSystem = (fn1, fn2) => {

const pipe = (...fns) => input => {
if (!input || Array.isArray(input) && input.length === 0) return;
const pipe = (...fns) => (...args) => {
const input = Array.isArray(args[0]) ? args[0] : args;
if (!input || input.length === 0) return;
fns = Array.isArray(fns[0]) ? fns[0] : fns;

@@ -997,3 +1033,3 @@ let tmp = input;

export { Changed, Not, Types, addComponent, addEntity, commitRemovals, contiguousArray, createWorld, defineComponent, defineDeserializer, defineQuery, defineSerializer, defineSystem, enterQuery, exitQuery, hasComponent, pipe, registerComponent, registerComponents, removeComponent, removeEntity, setDefaultSize };
export { Changed, Not, Types, addComponent, addEntity, commitRemovals, createWorld, defineComponent, defineDeserializer, defineQuery, defineSerializer, defineSystem, deleteWorld, enterQuery, exitQuery, hasComponent, parentArray, pipe, registerComponent, registerComponents, removeComponent, removeEntity, removeQuery, resetChangedQuery, resetWorld, setDefaultSize };
//# sourceMappingURL=index.es.js.map

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

const contiguousArray = store => store[$parentArray];
const parentArray = store => store[$parentArray];

@@ -630,2 +630,3 @@ const createArrayStore = (metadata, type, length) => {

const entities = [];
const archetypes = [];
const changed = [];

@@ -657,4 +658,7 @@ const indices = new Uint32Array(size).fill(NONE);

return a;
}, {});
const flatProps = components.map(c => Object.getOwnPropertySymbols(c).includes($storeFlattened) ? c[$storeFlattened] : [c]).reduce((a, v) => a.concat(v), []);
}, {}); // const orMasks = orComponents
// .map(mapComponents)
// .reduce(reduceBitmasks, {})
const flatProps = components.filter(c => !c[$tagStore]).map(c => Object.getOwnPropertySymbols(c).includes($storeFlattened) ? c[$storeFlattened] : [c]).reduce((a, v) => a.concat(v), []);
const toRemove = [];

@@ -672,2 +676,3 @@ const entered = [];

notMasks,
// orMasks,
generations,

@@ -678,3 +683,4 @@ indices,

entered,
exited
exited,
archetypes
});

@@ -746,3 +752,3 @@ world[$queries].add(query);

generations
} = world[$queryMap].get(query);
} = world[$queryMap].get(query); // let or = true

@@ -752,3 +758,4 @@ for (let i = 0; i < generations.length; i++) {

const qMask = masks[generationId];
const qNotMask = notMasks[generationId];
const qNotMask = notMasks[generationId]; // const qOrMask = orMasks[generationId]
const eMask = world[$entityMasks][generationId][eid];

@@ -758,4 +765,7 @@

return false;
}
} // if (qOrMask && (eMask & qOrMask) !== qOrMask) {
// continue
// }
if (qMask && (eMask & qMask) !== qMask) {

@@ -784,4 +794,3 @@ return false;

q.entities.push(eid);
q.indices[eid] = q.entities.length - 1; // TODO: pop swap so dupes don't enter
q.indices[eid] = q.entities.length - 1;
q.entered.push(eid);

@@ -818,6 +827,12 @@ };

q.toRemove.push(eid);
world[$dirtyQueries].add(q); // TODO: pop swap so dupes don't enter (in the case where an EID is removed twice before query is called again)
world[$dirtyQueries].add(q);
q.exited.push(eid);
};
const resetChangedQuery = (world, query) => {
const q = world[$queryMap].get(query);
q.changed.length = 0;
};
const removeQuery = (world, query) => {
world[$queryMap].delete(query);
};

@@ -940,2 +955,7 @@ const $componentMap = Symbol('componentMap');

const world = {};
resetWorld(world);
worlds.push(world);
return world;
};
const resetWorld = world => {
const size = getGlobalSize();

@@ -952,5 +972,20 @@ world[$size] = size;

world[$dirtyQueries] = new Set();
worlds.push(world);
return world;
};
const deleteWorld = world => {
delete world[$size];
delete world[$entityEnabled];
delete world[$entityMasks];
delete world[$entityArray];
delete world[$entityIndices];
delete world[$bitflag];
delete world[$componentMap];
delete world[$queryMap];
delete world[$queries];
delete world[$dirtyQueries];
Object.keys(world).forEach(key => {
delete world[key];
});
worlds.splice(worlds.indexOf(world), 1);
};

@@ -980,4 +1015,5 @@ const defineSystem = (fn1, fn2) => {

const pipe = (...fns) => input => {
if (!input || Array.isArray(input) && input.length === 0) return;
const pipe = (...fns) => (...args) => {
const input = Array.isArray(args[0]) ? args[0] : args;
if (!input || input.length === 0) return;
fns = Array.isArray(fns[0]) ? fns[0] : fns;

@@ -1007,3 +1043,2 @@ let tmp = input;

exports.commitRemovals = commitRemovals;
exports.contiguousArray = contiguousArray;
exports.createWorld = createWorld;

@@ -1015,5 +1050,7 @@ exports.defineComponent = defineComponent;

exports.defineSystem = defineSystem;
exports.deleteWorld = deleteWorld;
exports.enterQuery = enterQuery;
exports.exitQuery = exitQuery;
exports.hasComponent = hasComponent;
exports.parentArray = parentArray;
exports.pipe = pipe;

@@ -1024,3 +1061,6 @@ exports.registerComponent = registerComponent;

exports.removeEntity = removeEntity;
exports.removeQuery = removeQuery;
exports.resetChangedQuery = resetChangedQuery;
exports.resetWorld = resetWorld;
exports.setDefaultSize = setDefaultSize;
//# sourceMappingURL=index.js.map
declare module 'bitecs' {
export type Type =
'bool' |
'i8' |

@@ -39,3 +38,2 @@ 'ui8' |

export type ArrayByType = {
['bool']: boolean[];
[Types.i8]: Int8Array;

@@ -76,3 +74,3 @@ [Types.ui8]: Uint8Array;

export type Query = (world: IWorld) => number[]
export type Query = (world: IWorld, clearDiff: Boolean = true) => number[]

@@ -82,4 +80,7 @@ export type System = (world: IWorld) => IWorld

export function createWorld(size?: number): IWorld
export function resetWorld(world: IWorld): IWorld
export function deleteWorld(world: IWorld): void
export function addEntity(world: IWorld): number
export function removeEntity(world: IWorld, eid: number): void
export function registerComponent(world: IWorld, component: Component): void

@@ -91,2 +92,3 @@ export function registerComponents(world: IWorld, components: Component[]): void

export function hasComponent(world: IWorld, component: Component, eid: number): boolean
export function defineQuery(components: (Component | QueryModifier)[]): Query

@@ -97,7 +99,12 @@ export function Changed(c: Component): Component | QueryModifier

export function exitQuery(query: Query): Query
export function resetChangedQuery(world: IWorld, query: Query): Query
export function removeQuery(world: IWorld, query: Query): Query
export function commitRemovals(world: IWorld): void
export function defineSystem(update: (world: IWorld, ...args: any[]) => IWorld): System
export function defineSerializer(target: IWorld | Component | IComponentProp | QueryModifier, maxBytes?: number): (target: IWorld | number[]) => ArrayBuffer
export function defineDeserializer(target: IWorld | Component | IComponentProp | QueryModifier): (world: IWorld, packet: ArrayBuffer) => void
export function pipe(...fns: ((...args: any[]) => any)[]): (input: any) => any
export function defineSerializer(target: IWorld | Component[] | IComponentProp[] | QueryModifier, maxBytes?: number): (target: IWorld | number[]) => ArrayBuffer
export function defineDeserializer(target: IWorld | Component[] | IComponentProp[] | QueryModifier): (world: IWorld, packet: ArrayBuffer) => void
export function pipe(...fns: ((...args: any[]) => any)[]): (...input: any[]) => any
}
{
"name": "bitecs",
"version": "0.3.8",
"version": "0.3.9",
"description": "Functional, minimal, data-driven, ultra-high performance ECS library written in Javascript",
"license": "MPL-2.0",
"type": "module",
"main": "./dist/index.js",

@@ -57,2 +56,2 @@ "module": "./dist/index.es.js",

}
}
}

@@ -5,8 +5,3 @@ # ๐Ÿ‘พ 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)

Used in:
- [ModNGN]()
- [Phaser 4]()
- [XREngine]()
## โœจ Features

@@ -32,5 +27,7 @@

### ๐Ÿ‘ฉโ€๐Ÿ’ป In Development
| |
| ---------------- |
|๐Ÿงต Multithreading |
| |
| ----------------- |
| ๐Ÿงฌ Archetypes |
| ๐Ÿงฉ Sparse Sets |
| ๐Ÿงต Multithreading |

@@ -45,3 +42,3 @@

This is the entire API:
Essentials of the API:

@@ -48,0 +45,0 @@ ```js

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