function truncateHelper(item, length) {
    // Setting .length to a lower value truncates the array in-place:
    // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length
    for (const key of Object.keys(item)) {
        item[key].length = length;
    }
}
Helper function for truncating values of an object, which are each arrays.
NOTE: No additional checks are made here for validity of arguments.
@param {Record<string, any[]>} item The input object.
@param {number} length The length to truncate to.
@private