qbcore-framework / qb-core

FiveM RP Framework Core :muscle:
GNU General Public License v3.0
590 stars 960 forks source link

MapTableBySubfield - New Shared Function #1042

Closed AnishBplayz closed 9 months ago

AnishBplayz commented 12 months ago

The Lua function QBShared.MapTableBySubfield takes two parameters: subfield and table. It maps the input table based on the specified subfield, creating a new table (mappedTable) where each unique value of the subfield corresponds to a subtable containing all entries with that value. The function iterates through the input table, checks for the existence of the subfield in each entry, and creates subtables in mappedTable accordingly. Entries are then appended to their respective subtables. While the use of the goto statement for skipping iterations is unconventional, it efficiently skips to the next iteration when the subfield is absent. The resulting mappedTable is returned as the output.

github-actions[bot] commented 9 months ago

This PR has had 60 days of inactivity & will close within 7 days