MCPcopy Create free account
hub / github.com/Rich-Harris/magic-string / writeVlq

Function writeVlq

src/utils/MappingsEncoder.ts:24–34  ·  view source on GitHub ↗
(pos: number, num: number)

Source from the content-addressed store, hash-verified

22const scratch = /* #__PURE__ */ new Uint8Array(BUFFER_SIZE)
23
24function writeVlq(pos: number, num: number): number {
25 num = num < 0 ? (-num << 1) | 1 : num << 1
26 do {
27 let clamped = num & 0b011111
28 num >>>= 5
29 if (num > 0)
30 clamped |= 0b100000
31 scratch[pos++] = intToChar[clamped]
32 } while (num > 0)
33 return pos
34}
35
36const decoder = /* #__PURE__ */ new TextDecoder()
37

Callers 1

drainMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected