MCPcopy Create free account
hub / github.com/ErickWendel/processing-30GB-data-with-JavaScript-Streams / transform

Function transform

preclass/app/index.js:57–70  ·  view source on GitHub ↗
(chunk, controller)

Source from the content-addressed store, hash-verified

55 // let ndjsonBuffer = ''
56 return new TransformStream({
57 transform(chunk, controller) {
58 for (const item of chunk.split('\n')) {
59 try {
60 controller.enqueue(JSON.parse(item))
61 } catch (error) {
62 // this exception is a common problem that we won't handle in this class:
63 // if the arrived data is not completed, it should stored in memory until completed
64 // 1st msg received - {"name": "er
65 // 2nd msg received - "ick"}\n
66 //result: {"name": "erick"}\n
67 }
68 }
69
70 }
71 })
72}
73const [

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected