MCPcopy Index your code
hub / github.com/ErickWendel/processing-30GB-data-with-JavaScript-Streams / transform

Function transform

recorded/app/index.js:35–49  ·  view source on GitHub ↗
(chunk, controller)

Source from the content-addressed store, hash-verified

33function parseNDJSON() {
34 return new TransformStream({
35 transform(chunk, controller) {
36 for (const item of chunk.split('\n')) {
37 if (!item.length) continue
38 try {
39 controller.enqueue(JSON.parse(item))
40 } catch (error) {
41 // this exception is a common problem that we won't handle in this class:
42 // if the arrived data is not completed, it should be stored in memory
43 // until completed
44 // 1st msg received - {"name": "er"
45 // 2st msg received - "ick"}\n
46 // result {"name": "erick"}\n
47 }
48 }
49 }
50 })
51}
52let counter = 0

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected