MCPcopy Create free account
hub / github.com/Yaffle/EventSource / valid

Function valid

tests/eventsource.js:103–114  ·  view source on GitHub ↗
(codePoint, shift, octetsCount)

Source from the content-addressed store, hash-verified

101
102 TextDecoderPolyfill.prototype.decode = function (octets) {
103 function valid(codePoint, shift, octetsCount) {
104 if (octetsCount === 1) {
105 return codePoint >= 0x0080 >> shift && codePoint << shift <= 0x07FF;
106 }
107 if (octetsCount === 2) {
108 return codePoint >= 0x0800 >> shift && codePoint << shift <= 0xD7FF || codePoint >= 0xE000 >> shift && codePoint << shift <= 0xFFFF;
109 }
110 if (octetsCount === 3) {
111 return codePoint >= 0x010000 >> shift && codePoint << shift <= 0x10FFFF;
112 }
113 throw new Error();
114 }
115 function octetsCount(bitsNeeded, codePoint) {
116 if (bitsNeeded === 6 * 1) {
117 return codePoint >> 6 > 15 ? 3 : codePoint > 31 ? 2 : 1;

Callers 1

eventsource.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected