Add typings for bulk operations (#257)

* Add typings for bulk operations

* Use Id
This commit is contained in:
dai 2025-07-17 18:25:37 +02:00 committed by GitHub
parent c3853023d0
commit c30328527a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

3
jecs.d.ts vendored
View file

@ -321,3 +321,6 @@ export type ComponentRecord = {
}
export function component_record(world: World, id: Id): ComponentRecord
export function bulk_insert<const C extends Id[]>(world: World, entity: Entity, ids: C, values: InferComponents<C>): void
export function bulk_remove(world: World, entity: Entity, ids: Id[]): void

View file

@ -2027,7 +2027,7 @@ local function world_children<a>(world: World, parent: Id<a>)
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