UNPKG

scrivito

Version:

Scrivito is a professional, yet easy to use SaaS Enterprise Content Management Service, built for digital agencies and medium to large businesses. It is completely maintenance-free, cost-effective, and has unprecedented performance and security.

23 lines (18 loc) 621 B
export class ExtractCollector { private currentLength: number = 0; private readonly extracts: string[] = []; constructor(private readonly maxLength: number) {} isMaxLengthReached(): boolean { return this.currentLength >= this.maxLength; } push(extract: string): void { if (!extract) return; this.currentLength += extract.length + (this.extracts.length ? 1 : 0); this.extracts.push(extract); } toString(): string { const extractedText = this.extracts.join(' '); const shortenedText = extractedText.substring(0, this.maxLength); return shortenedText.replace(/ $/, ''); } }