MCPcopy Index your code
hub / github.com/di-sukharev/opencommit / toLine

Function toLine

out/cli.cjs:78043–78112  ·  view source on GitHub ↗
(chunkIter)

Source from the content-addressed store, hash-verified

78041function createMessage() {
78042 return {
78043 data: void 0,
78044 event: "",
78045 id: "",
78046 retry: void 0
78047 };
78048}
78049function toLine(chunkIter) {
78050 return __asyncGenerator(this, arguments, function* toLine_1() {
78051 var _a5, e_1, _b2, _c2;
78052 let buf;
78053 let bufIdx = 0;
78054 let fieldLen = -1;
78055 let discardTrailingNewline = false;
78056 try {
78057 for (var _d2 = true, chunkIter_1 = __asyncValues(chunkIter), chunkIter_1_1; chunkIter_1_1 = yield __await(chunkIter_1.next()), _a5 = chunkIter_1_1.done, !_a5; _d2 = true) {
78058 _c2 = chunkIter_1_1.value;
78059 _d2 = false;
78060 const chunk = _c2;
78061 if (buf === void 0) {
78062 buf = chunk;
78063 bufIdx = 0;
78064 fieldLen = -1;
78065 } else {
78066 buf = concatBuffer(buf, chunk);
78067 }
78068 const bufLen = buf.length;
78069 let start = 0;
78070 while (bufIdx < bufLen) {
78071 if (discardTrailingNewline) {
78072 if (buf[bufIdx] === ControlChars.NewLine) {
78073 start = ++bufIdx;
78074 }
78075 discardTrailingNewline = false;
78076 }
78077 let end = -1;
78078 for (; bufIdx < bufLen && end === -1; ++bufIdx) {
78079 switch (buf[bufIdx]) {
78080 case ControlChars.Colon:
78081 if (fieldLen === -1) {
78082 fieldLen = bufIdx - start;
78083 }
78084 break;
78085 case ControlChars.CarriageReturn:
78086 discardTrailingNewline = true;
78087 end = bufIdx;
78088 break;
78089 case ControlChars.NewLine:
78090 end = bufIdx;
78091 break;
78092 }
78093 }
78094 if (end === -1) {
78095 break;
78096 }
78097 yield yield __await({ line: buf.subarray(start, end), fieldLen });
78098 start = bufIdx;
78099 fieldLen = -1;
78100 }

Callers 1

createSseStreamFunction · 0.85

Calls 5

__asyncGeneratorFunction · 0.85
__asyncValuesFunction · 0.85
__awaitFunction · 0.85
concatBufferFunction · 0.85
nextMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…