MCPcopy
hub / github.com/Kong/insomnia / bufferSplit

Function bufferSplit

packages/insomnia/bin/yarn-standalone.js:4598–4624  ·  view source on GitHub ↗
(buf, chr)

Source from the content-addressed store, hash-verified

4596}
4597
4598function bufferSplit(buf, chr) {
4599 assert.buffer(buf);
4600 assert.string(chr);
4601
4602 var parts = [];
4603 var lastPart = 0;
4604 var matches = 0;
4605 for (var i = 0; i < buf.length; ++i) {
4606 if (buf[i] === chr.charCodeAt(matches))
4607 ++matches;
4608 else if (buf[i] === chr.charCodeAt(0))
4609 matches = 1;
4610 else
4611 matches = 0;
4612
4613 if (matches >= chr.length) {
4614 var newPart = i + 1;
4615 parts.push(buf.slice(lastPart, newPart - matches));
4616 lastPart = newPart;
4617 matches = 0;
4618 }
4619 }
4620 if (lastPart <= buf.length)
4621 parts.push(buf.slice(lastPart, buf.length));
4622
4623 return (parts);
4624}
4625
4626function ecNormalize(buf, addZero) {
4627 assert.buffer(buf);

Callers

nothing calls this directly

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected