This site describes solve-engine as it is on main: 2.43.0, which npm does not have yet. npm installs 2.40.0, so a page may show an answer that version does not give yet.
countLines
function countLines(text, stopAfter?): number;Defined in: packages/engine/src/utilities/Strings.ts:82
How many lines text has, without splitting it into an array.
splitLines(text).length answers the same question and allocates the whole
document to do it, which is the wrong shape for a caller whose next move may
be to refuse the document for being too large. Counting stops as soon as the
answer is “more than the caller cares about”. A line ends where
splitLines ends one.
Parameters
Section titled “Parameters”| Parameter | Type | Default value | Description |
|---|---|---|---|
text | string | undefined | The document. |
stopAfter | number | Number.MAX_SAFE_INTEGER | Stop counting once past this many lines. |
Returns
Section titled “Returns”number
The line count, or stopAfter + 1 for anything longer. A document
with no line break in it is one line, matching split.