```ts
/**
 * The words grouped by their length, in first-seen order.
 * @param words - An array of strings to be grouped by length.
 * @returns A Map where keys are word lengths and values are arrays of words with that length.
 */
export function groupByLength(words: readonly string[]): Map<number, string[]> {
  const groups = new Map<number, string[]>();
  for (const word of words) {
    const bucket = groups.get(word.length);
    if (bucket === undefined) {
      groups.set(word.length, [word]);
    } else {
      bucket.push(word);
    }
  }
  return groups;
}
```