MCPcopy Create free account
hub / github.com/sindresorhus/query-string / readPercentByte

Function readPercentByte

base.js:271–275  ·  view source on GitHub ↗
(value, position)

Source from the content-addressed store, hash-verified

269
270// The byte that the percent escape at `position` stands for, or -1 when there is no escape there. A `%` that is not followed by two hexadecimal digits is not an escape, and neither is one that starts the value.
271function readPercentByte(value, position) {
272 percentEscape.lastIndex = position;
273 const match = percentEscape.exec(value);
274 return match === null ? -1 : Number.parseInt(match[0].slice(1), 16);
275}
276
277// The number of bytes in the UTF-8 sequence that starts with this lead byte, or zero when the byte cannot start one. That is a continuation byte (0x80 to 0xBF), and the lead bytes that are only ever invalid: 0xC0 and 0xC1 can only start an overlong encoding, and 0xF5 to 0xFF can only start a code point above U+10FFFF.
278function utf8SequenceLength(leadByte) {

Callers 1

decodeSequenceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected