From c30328527a0801a8e9ebf7b7fec057f237992bd6 Mon Sep 17 00:00:00 2001 From: dai Date: Thu, 17 Jul 2025 18:25:37 +0200 Subject: [PATCH] Add typings for bulk operations (#257) * Add typings for bulk operations * Use Id --- jecs.d.ts | 3 +++ jecs.luau | 6 +++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/jecs.d.ts b/jecs.d.ts index b347d12..aad34ee 100755 --- a/jecs.d.ts +++ b/jecs.d.ts @@ -321,3 +321,6 @@ export type ComponentRecord = { } export function component_record(world: World, id: Id): ComponentRecord + +export function bulk_insert(world: World, entity: Entity, ids: C, values: InferComponents): void +export function bulk_remove(world: World, entity: Entity, ids: Id[]): void \ No newline at end of file diff --git a/jecs.luau b/jecs.luau index fb5fa6d..cc3e20d 100755 --- a/jecs.luau +++ b/jecs.luau @@ -2027,7 +2027,7 @@ local function world_children(world: World, parent: Id) return world_each(world, ECS_PAIR(EcsChildOf, parent::number)) end -local function ecs_bulk_insert(world: World, entity: Entity, ids: { Entity }, values: { any }) +local function ecs_bulk_insert(world: World, entity: Entity, ids: { Id }, values: { any }) local entity_index = world.entity_index local r = entity_index_try_get(entity_index, entity) if not r then @@ -2105,7 +2105,7 @@ local function ecs_bulk_insert(world: World, entity: Entity, ids: { Entity }, va end end -local function ecs_bulk_remove(world: World, entity: Entity, ids: { Entity }) +local function ecs_bulk_remove(world: World, entity: Entity, ids: { Id }) local entity_index = world.entity_index local r = entity_index_try_get(entity_index, entity) if not r then @@ -2117,7 +2117,7 @@ local function ecs_bulk_remove(world: World, entity: Entity, ids: { Entity }) return end - local remove: { [Entity]: boolean } = {} + local remove: { [Id]: boolean } = {} local columns_map = from.columns_map