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.0.6 to 0.1.0

core-ecs/node_modules/uWebSockets.js/index.d.ts

62

package.json
{
"name": "bitecs",
"version": "0.0.6",
"version": "0.1.0",
"description": "Tiny, data-driven, high performance ECS library written in Javascript",
"main": "index.js",
"type": "module",
"main": "./dist/index.min.js",
"module": "./dist/index.es.js",
"author": {
"name": "Nathaniel Martin",
"email": "mrtn.nathaniel@gmail.com",
"url": "http://n8bit.io/"
},
"contributors": [
{
"name": "Randy Lebeau",
"email": "randylebeau@gmail.com",
"url": "https://github.com/SupremeTechnopriest"
}
],
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"build": "rollup -c",
"test": "jest",
"docs": "node scripts/docs.js",
"dist": "npm run test && npm run build && npm run docs"
},
"repository": {
"type": "git",
"url": "git+https://github.com/NateTheGreatt/bitecs.git"
"devDependencies": {
"@babel/preset-env": "^7.12.1",
"@rollup/plugin-babel": "^5.2.1",
"dmd-readable": "SupremeTechnopriest/dmd-readable",
"globby": "^11.0.1",
"jest": "^26.6.1",
"jsdoc-to-markdown": "^6.0.1",
"rollup": "^2.32.1",
"rollup-plugin-terser": "^7.0.2"
},
"keywords": [
"ecs",
"game",
"performance",
"data-driven"
],
"author": "Nathaniel Martin",
"license": "MIT",
"bugs": {
"url": "https://github.com/NateTheGreatt/bitecs/issues"
"babel": {
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
]
]
},
"homepage": "https://github.com/NateTheGreatt/bitecs#readme"
"jest": {
"testMatch": [
"**/__tests__/**/*.test.js"
]
}
}

@@ -7,5 +7,5 @@ # 👾 bitECS 👾

- `<3kb` gzipped
- zero dependencies
- node or browser
- [_fast_](https://github.com/NateTheGreatt/bitECS/blob/master/examples/benchmark.js)
- Zero dependencies
- Node or Browser
- [_Fast_](https://github.com/noctjs/ecs-benchmark)

@@ -18,72 +18,43 @@ ## Install

## Example
```javascript
// imports a factory function
import bitECS from 'bitECS'
// define the max number of entities in the ecs
const n = 1000000
```js
import World from 'bitecs'
// create a new ECS and destruct desirable functions
const {
addEntity,
addComponent,
removeComponent,
registerComponent,
registerSystem,
update
} = bitECS(n)
// Create a world
const world = World()
// register components
const Vector3 = { x: 'float32', y: 'float32', z: 'float32' } // nested structures are fully supported
registerComponent('position', Vector3)
registerComponent('velocity', Vector3)
// Register some components
world.registerComponent('POSITION', { x: 'float32', y: 'float32' })
world.registerComponent('VELOCITY', { vx: 'int8', vy: 'int8', speed: 'uint16' })
// register a movement system
registerSystem({
name: 'movement',
// update will only apply to these components
// in this case entities with both a position & velocity component will be processed
components: ['position', 'velocity'],
// update function provides component managers and the entity ID to do work on
update: (pos, vel) => eid => {
// entity data is obtained from the respective component managers
// managers are objects with typedarray properties
// this is how high performance is reaped and maintained
pos.x[eid] += vel.x[eid]
pos.y[eid] += vel.y[eid]
pos.z[eid] += vel.z[eid]
},
// called whenever an entity is added to the system (has required components)
onEnter: (pos, vel) => eid => {},
// called whenever an entity is removed from the system (no longer has required components)
onExit: (pos, vel) => eid => {},
// called once, before the system update (not per entity, no eid passed in)
onBefore: (pos, vel) => {},
// called once, after the system update
onAfter: (pos, vel) => {},
// called per entity, before the system updates it
onBeforeEach: (pos, vel) => eid => {},
// called per entity, after the system updates it
onAfterEach: (pos, vel) => eid => {}
// Register a system
world.registerSystem({
name: 'MOVEMENT',
components: ['POSITION', 'VELOCITY'],
update: (position, velocity) => eid => {
position.x[eid] += velocity.vx[eid] * velocity.speed[eid]
position.y[eid] += velocity.vy[eid] * velocity.speed[eid]
}
})
// Create an entity
const eid = world.addEntity()
// create n entities with random position and velocity
for(let i = 0; i < n; i++) {
let eid = addEntity()
addComponent('position', eid, {x: Math.random(), y: Math.random(), z: Math.random()})
addComponent('velocity', eid, {x: Math.random(), y: Math.random(), z: Math.random()})
}
// Add components to entity
world.addComponent('POSITION', eid, { x: 100, y: 100 })
world.addComponent('VELOCITY', eid, { vx: 1, vy: -1, speed: 100 })
// node
// Create an event loop and step world
setInterval(() => {
update()
}, 16) // yes, this ECS can process one million entities in under 16ms (depending on the CPU)
world.step()
}, 1000 / 30) // 30 tick on server
// browser
// For browser, use frame rate
const loop = () => {
requestAnimationFrame(loop)
update()
world.step()
requestAnimationFrame(loop)
}
loop()
```
```
Full documentation and feature rich examples can be found [here](DOCS.md).
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