/** * Converts a string to an ArrayBuffer. * @param {string} str String to convert * @returns {ArrayBuffer} * @private */ static str2ab(str) { const buffer = new ArrayBuffer(str.length * 2); const view = new Uint16Array(buffer); for (var i = 0, strLen = str.length; i < strLen; i++) view[i] = str.charCodeAt(i); return buffer; }
['B', 'C', 'Q', 'P', 'F', 'p', 'D', 'E', 'H', 'S'].reduce((acc, x) => { const v = x.charCodeAt(0) acc[x] = () => { buffer[0] = v b.i = 5 return b } return acc }, {})
function urlB64ToUint8Array(base64String) { const padding = '='.repeat((4 - (base64String.length % 4)) % 4); const base64 = (base64String + padding).replace(/-/g, '+').replace(/_/g, '/'); const rawData = window.atob(base64); const outputArray = new Uint8Array(rawData.length); for (let i = 0; i < rawData.length; ++i) { outputArray[i] = rawData.charCodeAt(i); } return outputArray; }
const byteCount = (str: string) => { // returns the byte length of an utf8 string let s = str.length; for (let i = str.length - 1; i >= 0; i--) { let code = str.charCodeAt(i); if (code > 0x7f && code <= 0x7ff) s++; else if (code > 0x7ff && code <= 0xffff) s += 2; if (code >= 0xdc00 && code <= 0xdfff) i--; //trail surrogate } return s; }
const code0 = options.charCodeAt(0)
const data = []; for (let i = 0; i < str.length; i++) { data.push(str.charCodeAt(i));
arr[ i ] = binStr.charCodeAt( i );
string.charCodeAt(0) === QUOTE) { return string
switch (str.charCodeAt(index)) { case 34:
} else if (s <= '\x1a') { key.name = String.fromCharCode(s.charCodeAt(0) + 'a'.charCodeAt(0) - 1); key.ctrl = true; } else if (s.length === 1 && s >= '0' && s <= '9') {
var ch; var j; if ( txt.charCodeAt( 0 ) === 34 ) { j = 1; for ( j = 1; j < txt.length; j++ ) { ch = txt.charCodeAt( j ); if ( ch === 34 ) { txt = txt.slice( 1, j ); txt = ch + txt.slice( 1 ); if ( txt.charCodeAt( txt.length-1 ) !== 46 ) { // . txt += '.';
nextIndex(i) { const s = this.source const l = s.length if (i >= l) { return l } let c = s.charCodeAt(i), next if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l || (next = s.charCodeAt(i + 1)) < 0xDC00 || next > 0xDFFF) { return i + 1 } return i + 2 }
extra; while (counter < length) { value = string.charCodeAt(counter++); if (value >= 0xD800 && value <= 0xDBFF && counter < length) { extra = string.charCodeAt(counter++); if ((extra & 0xFC00) == 0xDC00) { // low surrogate output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); if (input.charCodeAt(j) >= 0x80) { error('not-basic'); output.push(input.charCodeAt(j)); digit = basicToDigit(input.charCodeAt(index++));
while ( leftLength > 0 && left.charCodeAt(leftLength) === right.charCodeAt(rightLength) ) { leftLength -= 1; while ( start < leftLength && left.charCodeAt(start) === right.charCodeAt(start) ) { start += 1; charCodeCache[i] = left.charCodeAt(start + i); array[i] = i + 1; let j = 0; while (j < rightLength) { bCharCode = right.charCodeAt(start + j); temp = j; j += 1;
// If u flag is given, this returns the code point at the index (it combines a surrogate pair). // Otherwise, this returns the code unit of the index (can be a part of a surrogate pair). at(i) { const s = this.source const l = s.length if (i >= l) { return -1 } const c = s.charCodeAt(i) if (!this.switchU || c <= 0xD7FF || c >= 0xE000 || i + 1 >= l) { return c } const next = s.charCodeAt(i + 1) return next >= 0xDC00 && next <= 0xDFFF ? (c << 10) + next - 0x35FDC00 : c }