Skip to content

Conversation

lionel-rowe
Copy link

@lionel-rowe lionel-rowe commented Sep 15, 2025

Closes #52
Closes #51

Usage with iterable protocol (see also updated readme):

console.log([...new LineBreaker('...')]) // [{ position: 3, required: false, substring: '...' }]

for (const bk of new LineBreaker('...')) {
  console.log(bk); // { position: 3, required: false, substring: '...' }
}

Exposed types — I've omitted the low-level methods like getSimpleBreak even though they're technically public:

interface Break {
  position: number;
  required: boolean;
}
interface BreakInfo extends Break {
  substring: string;
}
interface LineBreaker {
  new(input: string): LineBreaker;
  nextBreak(): Break | null;
  [Symbol.iterator](): Generator<BreakInfo, undefined, undefined>;
}

Let me know if this would be preferable as two separate PRs, one for types and the other for Symbol.iterator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Iteration with [...new LineBreaker('...')] etc TS types
1 participant