MCPcopy
hub / github.com/apify/crawlee / processBuffer

Method processBuffer

packages/utils/src/internals/sitemap.ts:54–77  ·  view source on GitHub ↗
(input: string, finalize: boolean)

Source from the content-addressed store, hash-verified

52 }
53
54 private processBuffer(input: string, finalize: boolean): void {
55 this.buffer += input;
56
57 if (finalize || this.buffer.includes('\n')) {
58 const parts = this.buffer
59 .split('\n')
60 .map((part) => part.trim())
61 .filter((part) => part.length > 0);
62
63 if (finalize) {
64 for (const url of parts) {
65 this.push({ type: 'url', loc: url } satisfies SitemapItem);
66 }
67
68 this.buffer = '';
69 } else if (parts.length > 0) {
70 for (const url of parts.slice(0, -1)) {
71 this.push({ type: 'url', loc: url } satisfies SitemapItem);
72 }
73
74 this.buffer = parts.at(-1)!;
75 }
76 }
77 }
78}
79
80class SitemapXmlParser extends Transform {

Callers 1

constructorMethod · 0.95

Calls 2

mapMethod · 0.80
pushMethod · 0.80

Tested by

no test coverage detected