```typescript
/**
 * The words grouped by their length, in first-seen order.
 */
export function groupByLength(words: readonly string[]): Map<number, string[]> {
  const groups = new Map();
  for (const word of words) {
    const bucketId = word.length;
    if (!groups.has(bucketId)) {
      groups.set(bucketId, [word]);
    } else {
      groups.get(bucketId)!.push(word);
    }
  }
  return groups;
}
```