MCPcopy
hub / github.com/microsoft/playwright / _encodeLength

Method _encodeLength

packages/utils/crypto.ts:103–114  ·  view source on GitHub ↗
(length: number)

Source from the content-addressed store, hash-verified

101 return Buffer.concat([Buffer.from([tag]), lengthBytes, data]);
102 }
103 private static _encodeLength(length: number): Buffer {
104 if (length < 128) {
105 return Buffer.from([length]);
106 } else {
107 const lengthBytes = [];
108 while (length > 0) {
109 lengthBytes.unshift(length & 0xFF);
110 length >>= 8;
111 }
112 return Buffer.from([0x80 | lengthBytes.length, ...lengthBytes]);
113 }
114 }
115}
116
117// X.509 Specification: https://datatracker.ietf.org/doc/html/rfc2459#section-4.1

Callers 1

_encodeMethod · 0.95

Calls 1

fromMethod · 0.45

Tested by

no test coverage detected