So far consequitive identical lines were collapsed if there were at
least three. Now they are only collapsed from five identical lines on.
This also simplifies the implementation a tiny bit by abstracting some
logic.
PR-URL: https://github.com/nodejs/node/pull/28058
Reviewed-By: Rich Trott <rtrott@gmail.com>